Skip to content

Commit

Permalink
VisualStates exported to StatefulStackLayoutRenderer ( #102 )
Browse files Browse the repository at this point in the history
  • Loading branch information
enisn committed Mar 23, 2019
1 parent e484ed7 commit 01229bb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion InputKit/Platforms/Droid/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void Init(Activity activity, Bundle bundle)
Console.WriteLine($"[{typeof(EmptyEntryRenderer).FullName}] Initialized.");
Console.WriteLine($"[{typeof(MenuEffect).FullName}] Initialized.");
Console.WriteLine($"[{typeof(NewIconViewRenderer).FullName}] Initialized.");
Console.WriteLine($"[{typeof(StackLayoutWithVisualStatesRenderer).FullName}] Initialized.");
Console.WriteLine($"[{typeof(StatefulStackLayoutRenderer).FullName}] Initialized.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@
using Android.Views;
using Plugin.InputKit.Platforms.Droid;
using Plugin.InputKit.Shared.Controls;
using Plugin.InputKit.Shared.Layouts;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

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

}

public override bool OnTouchEvent(MotionEvent e)
{
System.Diagnostics.Debug.WriteLine("[OnTouchEvent] - " + e.Action);
//System.Diagnostics.Debug.WriteLine("[OnTouchEvent] - " + e.Action);
if (e.Action == MotionEventActions.Down)
{
VisualStateManager.GoToState(Element, "Pressed");
Expand Down
2 changes: 1 addition & 1 deletion InputKit/Platforms/iOS/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void Init()
Console.WriteLine($"[{typeof(EmptyEntryRenderer).FullName}] Initialized.");
Console.WriteLine($"[{typeof(MenuEffect).FullName}] Initialized.");
Console.WriteLine($"[{typeof(IconViewRenderer).FullName}] Initialized.");
Console.WriteLine($"[{typeof(StackLayoutWithVisualStatesRenderer).FullName}] Initialized.");
Console.WriteLine($"[{typeof(StatefulStackLayoutRenderer).FullName}] Initialized.");

Console.WriteLine($"[{typeof(AutoCompleteDefaultDataSource).FullName}] Initialized.");
Console.WriteLine($"[{typeof(AutoCompleteViewSource).FullName}] Initialized.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using Foundation;
using Plugin.InputKit.Platforms.iOS;
using Plugin.InputKit.Shared.Layouts;
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))]
[assembly:ExportRenderer(typeof(StatefulStackLayout),typeof(StatefulStackLayoutRenderer))]
namespace Plugin.InputKit.Platforms.iOS
{
public class StackLayoutWithVisualStatesRenderer : VisualElementRenderer<StackLayout>
public class StatefulStackLayoutRenderer : VisualElementRenderer<StackLayout>
{
public StackLayoutWithVisualStatesRenderer()
public StatefulStackLayoutRenderer()
{

}
Expand Down
16 changes: 16 additions & 0 deletions InputKit/Shared/Layouts/StatefulStackLayout.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;

namespace Plugin.InputKit.Shared.Layouts
{

/// <summary>
/// This class generated for prevent future errors with VisualStates of StackLayout. This StackLayout has VisaulStates like 'Pressed', 'Normal' etc.
/// </summary>
public class StatefulStackLayout : StackLayout
{

}
}

0 comments on commit 01229bb

Please sign in to comment.