Skip to content

Commit

Permalink
Radio Button Improvements for V3 (#80)
Browse files Browse the repository at this point in the history
* #75 iOS Initalization added

* release preparations

* Feature/experimental/checkbox (#79)

* IconView can render from streams now and Source changed to ImageSource

* CheckBox updated with custom images

* CheckBox unnecessary types removed

* Animators Added

* Animators implemented to CheckBox & RadioButton

* included all files under folders on csproj

* States Handled for StackLayout

* RadioButton completed with Pressed state
  • Loading branch information
enisn authored Mar 2, 2019
1 parent 95a767a commit c2158ee
Show file tree
Hide file tree
Showing 31 changed files with 3,068 additions and 698 deletions.
7 changes: 3 additions & 4 deletions InputKit.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<id>Xamarin.Forms.InputKit</id>

<!-- The package version number that is used when resolving dependencies -->
<version>2.3.7</version>
<version>3.0.0-pre2</version>

<!-- Authors contain text that appears directly on the gallery -->
<authors>enisn</authors>
Expand Down Expand Up @@ -37,9 +37,8 @@
...
This package includes awesome controls to get inputs easily from users and make validation easier.
Just import NuGet package to your project and use it!

There is no any Init() methods for your each platform!

Visit Project Site Link to get more information
...
</description>

<!-- Copyright information -->
Expand Down
7 changes: 7 additions & 0 deletions InputKit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.InputKit.Android", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InputKit", "InputKit\InputKit.csproj", "{0D4EDD99-6439-48E9-8F9A-8B4DC0CA5431}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{ADC7C69D-0749-4C60-82AE-6385D4CDD940}"
ProjectSection(SolutionItems) = preProject
.gitattributes = .gitattributes
.gitignore = .gitignore
readme.txt = readme.txt
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
Expand Down
Empty file added InputKit.sln.vsext.disable
Empty file.
27 changes: 12 additions & 15 deletions InputKit/InputKit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<ItemGroup>
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.6.55" PrivateAssets="All" />
<PackageReference Include="Xamarin.Forms" Version="3.2.0.839982" PrivateAssets="All" />
<PackageReference Include="Xamarin.Forms" Version="3.5.0.169047" PrivateAssets="All" />
<Compile Include="Shared\**\*.cs" />
</ItemGroup>

Expand Down Expand Up @@ -111,24 +111,21 @@


<ItemGroup>
<None Remove="Shared\Abstraction\ISelection.cs" />
<None Remove="Shared\Abstraction\IValidatable.cs" />
<None Remove="Shared\Abstraction\**\*.cs" />
<None Remove="Shared\Configuration\GlobalSetting.cs" />
<None Remove="Shared\Controls\AdvancedEntry.cs" />
<None Remove="Shared\Controls\AdvancedSlider.cs" />
<None Remove="Shared\Controls\CheckBox.cs" />
<None Remove="Shared\Controls\Dropdown.cs" />
<None Remove="Shared\Controls\EmptyEntry.cs" />
<None Remove="Shared\Controls\FormView.cs" />
<None Remove="Shared\Controls\IconView.cs" />
<None Remove="Shared\Controls\RadioButton.cs" />
<None Remove="Shared\Controls\SelectionView.cs" />
<None Remove="Shared\Helpers\ColorExtensions.cs" />
<None Remove="Shared\Utils\PopupMenu.cs" />
<None Remove="Shared\Utils\SelectedItemChangedArgs.cs" />
<None Remove="Shared\Controls\**\*.cs" />
<None Remove="Shared\Helpers\**\*.cs" />
<None Remove="Shared\Utils\**\*.cs" />
</ItemGroup>



<ItemGroup>
<EmbeddedResource Include="Shared\Resources\**\*.png" />
<EmbeddedResource Include="Shared\Resources\**\*.jpg" />
</ItemGroup>


<!--
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<Compile Include="Platforms\DotNet\**\*.cs" />
Expand Down
40 changes: 40 additions & 0 deletions InputKit/Platforms/Droid/StackLayoutWithVisualStatesRenderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Text;
using Android.Content;
using Android.Views;
using Plugin.InputKit.Platforms.Droid;
using Plugin.InputKit.Shared.Controls;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly:ExportRenderer(typeof(StackLayout),typeof(StackLayoutWithVisualStatesRenderer))]
namespace Plugin.InputKit.Platforms.Droid
{
public class StackLayoutWithVisualStatesRenderer : VisualElementRenderer<StackLayout>, Android.Views.View.IOnTouchListener
{
public StackLayoutWithVisualStatesRenderer(Context context) : base(context)
{

}

public override bool OnTouchEvent(MotionEvent e)
{
System.Diagnostics.Debug.WriteLine("[OnTouchEvent] - " + e.Action);
if (e.Action == MotionEventActions.Down)
{
VisualStateManager.GoToState(Element, "Pressed");
}
else if (e.Action == MotionEventActions.Up || e.Action == MotionEventActions.Cancel)
{
VisualStateManager.GoToState(Element, "Normal");
}
return base.OnTouchEvent(e);
}

public bool OnTouch(Android.Views.View v, MotionEvent e)
{
return base.OnTouchEvent(e);
}
}
}
10 changes: 10 additions & 0 deletions InputKit/Platforms/iOS/Config.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Plugin.InputKit.Platforms.iOS
{
public static class Config
{
public static void Init()
{

}
}
}
36 changes: 36 additions & 0 deletions InputKit/Platforms/iOS/StackLayoutWithVisualStatesRenderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Foundation;
using Plugin.InputKit.Platforms.iOS;
using System;
using System.Collections.Generic;
using System.Text;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly:ExportRenderer(typeof(StackLayout),typeof(StackLayoutWithVisualStatesRenderer))]
namespace Plugin.InputKit.Platforms.iOS
{
public class StackLayoutWithVisualStatesRenderer : VisualElementRenderer<StackLayout>
{
public StackLayoutWithVisualStatesRenderer()
{

}
public override void TouchesBegan(NSSet touches, UIEvent evt)
{
VisualStateManager.GoToState(Element, "Pressed");
base.TouchesBegan(touches, evt);
}

public override void TouchesCancelled(NSSet touches, UIEvent evt)
{
VisualStateManager.GoToState(Element, "Normal");
base.TouchesCancelled(touches, evt);
}
public override void TouchesEnded(NSSet touches, UIEvent evt)
{
VisualStateManager.GoToState(Element, "Normal");
base.TouchesEnded(touches, evt);
}
}
}
68 changes: 68 additions & 0 deletions InputKit/Shared/Abstraction/DefaultAnimator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Plugin.InputKit.Shared.Controls;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using Xamarin.Forms;

namespace Plugin.InputKit.Shared.Abstraction
{
public class DefaultAnimator<T> : IAnimator<T> where T : View
{
public void Animate(T view)
{
try
{
if (actions.TryGetValue(view.GetType(), out Action<View> _action))
_action(view);
else
actions[typeof(View)](view);
}
catch (Exception ex)
{
Debug.WriteLine(ex?.ToString());
}
}
//DECLERATION
static readonly Dictionary<Type, Action<View>> actions = new Dictionary<Type, Action<View>>
{
{
typeof(View), //default
async (v) =>
{
await v.ScaleTo(.9,100);
await v.ScaleTo(1,100);
}
},
{
typeof(CheckBox),
async (v)=>
{
var chk = v as CheckBox;
//await chk.boxBackground.ScaleTo(0.9, 100, Easing.BounceIn);
if (chk.Type == CheckBox.CheckType.Material)
chk.boxBackground.BackgroundColor = chk.IsChecked ? chk.Color : Color.Transparent;
else
chk.boxBackground.BorderColor = chk.IsChecked ? chk.Color : chk.BorderColor;
//await chk.boxBackground.ScaleTo(1, 100, Easing.BounceIn);
}
},
{
typeof(RadioButton),
async (v) =>
{
var rb = v as RadioButton;
//if (rb.IsChecked)
//{
// await rb.iconCircle.ScaleTo(.5,100, Easing.BounceIn);
// rb.iconCircle.FillColor = rb.IsChecked ? rb.Color : rb.CircleColor;
// await rb.iconCircle.ScaleTo(1,100, Easing.BounceIn);
//}
//else
rb.iconCircle.FillColor = rb.IsChecked ? rb.Color : rb.CircleColor;

}
}
};
}
}
12 changes: 12 additions & 0 deletions InputKit/Shared/Abstraction/IAnimator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;

namespace Plugin.InputKit.Shared.Abstraction
{
public interface IAnimator<T> where T : View
{
void Animate(T view);
}
}
Loading

0 comments on commit c2158ee

Please sign in to comment.