-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Radio Button Improvements for V3 (#80)
* #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
Showing
31 changed files
with
3,068 additions
and
698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
InputKit/Platforms/Droid/StackLayoutWithVisualStatesRenderer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
36
InputKit/Platforms/iOS/StackLayoutWithVisualStatesRenderer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.