From 7d7466441c4f5912fadfec4a8fa81a0d40415660 Mon Sep 17 00:00:00 2001 From: Jessica <33695848+jessicarich1980@users.noreply.github.com> Date: Wed, 15 Nov 2017 15:00:20 -0600 Subject: [PATCH] adding support for OnMenuToggle and IsMenuShown Added support for when the menu is shown or hidden it would raise event New event: OnMenuToggle > this event is raised when the menu is hidden or shown New property: IsMenuShown > this is a property that is accurate of whether the menu is shown or hidden --- SlideOverKit/SlideMenuView.cs | 47 +++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/SlideOverKit/SlideMenuView.cs b/SlideOverKit/SlideMenuView.cs index ea01cff..a3abe5d 100644 --- a/SlideOverKit/SlideMenuView.cs +++ b/SlideOverKit/SlideMenuView.cs @@ -1,4 +1,4 @@ -using System; +using System; using Xamarin.Forms; @@ -13,7 +13,18 @@ public enum MenuOrientation RightToLeft, } - public class SlideMenuView : ContentView + public class MenuShowEventArgs : EventArgs + { + public bool IsShown { get; private set; } + public MenuShowEventArgs(bool isShown) + { + IsShown = isShown; + } + } + public delegate void MenuShowEventHandler(object source, MenuShowEventArgs e); + + + public class SlideMenuView : ContentView { public SlideMenuView () { @@ -21,7 +32,8 @@ public SlideMenuView () this.BackgroundColor = Color.White; } - public static readonly BindableProperty MenuOrientationsProperty = BindableProperty.Create ( + + public static readonly BindableProperty MenuOrientationsProperty = BindableProperty.Create ( "MenuOrientations", typeof(MenuOrientation), typeof(SlideMenuView), @@ -141,9 +153,34 @@ public Color BackgroundViewColor { } } - internal Action HideEvent { get; set; } + public static readonly BindableProperty IsMenuShownProperty = BindableProperty.Create( + "IsMenuShownProperty", + typeof(bool), + typeof(SlideMenuView), + false); + + public bool IsMenuShown + { + get + { + return (bool)GetValue(IsMenuShownProperty); + } + set + { + if (IsMenuShown != value) + { + SetValue(IsMenuShownProperty, value); + if (OnMenuToggle != null) + { + OnMenuToggle(this, new MenuShowEventArgs(IsMenuShown)); + } + } + } + } + public event MenuShowEventHandler OnMenuToggle; + internal Action HideEvent { get; set; } - public void HideWithoutAnimations () + public void HideWithoutAnimations () { if (HideEvent != null) HideEvent ();