public void TestProgramaticallyClose() { bool isOpen = false; var swipeView = new SwipeView(); swipeView.OpenRequested += (sender, args) => isOpen = true; swipeView.CloseRequested += (sender, args) => isOpen = false; var swipeItem = new SwipeItem { BackgroundColor = Colors.Red, Text = "Text" }; swipeView.LeftItems = new SwipeItems { swipeItem }; swipeView.Open(OpenSwipeItem.LeftItems); swipeView.Close(); Assert.IsFalse(isOpen); }
protected override void Init() { Title = "Issue 10563"; var swipeLayout = new StackLayout { Margin = new Thickness(12) }; var openLeftButton = new Button { AutomationId = OpenLeftId, Text = "Open Left SwipeItem" }; var openRightButton = new Button { AutomationId = OpenRightId, Text = "Open Right SwipeItem" }; var openTopButton = new Button { AutomationId = OpenTopId, Text = "Open Top SwipeItem" }; var openBottomButton = new Button { AutomationId = OpenBottomId, Text = "Open Bottom SwipeItem" }; var closeButton = new Button { AutomationId = CloseId, Text = "Close SwipeView" }; swipeLayout.Children.Add(openLeftButton); swipeLayout.Children.Add(openRightButton); swipeLayout.Children.Add(openTopButton); swipeLayout.Children.Add(openBottomButton); swipeLayout.Children.Add(closeButton); var swipeItem = new SwipeItem { BackgroundColor = Color.Red, IconImageSource = "calculator.png", Text = "Issue 10563" }; swipeItem.Invoked += (sender, e) => { DisplayAlert("SwipeView", "SwipeItem Invoked", "Ok"); }; var swipeItems = new SwipeItems { swipeItem }; swipeItems.Mode = SwipeMode.Reveal; var swipeContent = new Grid { BackgroundColor = Color.Gray }; var swipeLabel = new Label { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Text = "Swipe to any direction" }; swipeContent.Children.Add(swipeLabel); var swipeView = new SwipeView { HeightRequest = 60, WidthRequest = 300, LeftItems = swipeItems, RightItems = swipeItems, TopItems = swipeItems, BottomItems = swipeItems, Content = swipeContent, Margin = new Thickness(0, 48) }; swipeLayout.Children.Add(swipeView); Content = swipeLayout; openLeftButton.Clicked += (sender, e) => { swipeView.Open(OpenSwipeItem.LeftItems); }; openRightButton.Clicked += (sender, e) => { swipeView.Open(OpenSwipeItem.RightItems); }; openTopButton.Clicked += (sender, e) => { swipeView.Open(OpenSwipeItem.TopItems); }; openBottomButton.Clicked += (sender, e) => { swipeView.Open(OpenSwipeItem.BottomItems); }; closeButton.Clicked += (sender, e) => { swipeView.Close(); }; }
public CloseSwipeGallery() { Title = "Open/Close SwipeView Gallery"; var swipeLayout = new StackLayout { Margin = new Thickness(12) }; var openButton = new Button { Text = "Open SwipeView" }; var closeButton = new Button { Text = "Close SwipeView" }; swipeLayout.Children.Add(openButton); swipeLayout.Children.Add(closeButton); var swipeItem = new SwipeItem { BackgroundColor = Color.Red, IconImageSource = "calculator.png", Text = "File" }; swipeItem.Invoked += (sender, e) => { DisplayAlert("SwipeView", "File Invoked", "Ok"); }; var swipeItems = new SwipeItems { swipeItem }; swipeItems.Mode = SwipeMode.Reveal; var swipeContent = new Grid { BackgroundColor = Color.Gray }; var fileSwipeLabel = new Label { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Text = "Swipe to Right (File)" }; swipeContent.Children.Add(fileSwipeLabel); var swipeView = new SwipeView { HeightRequest = 60, WidthRequest = 300, LeftItems = swipeItems, Content = swipeContent }; swipeLayout.Children.Add(swipeView); Content = swipeLayout; openButton.Clicked += (sender, e) => { swipeView.Open(OpenSwipeItem.LeftItems); }; closeButton.Clicked += (sender, e) => { swipeView.Close(); }; }
public Programmatical() { Title = "Programmatically"; var swipeLayout = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Star } }, Margin = new Thickness(12) }; var openButton = new Button { Text = "Open SwipeView" }; var closeButton = new Button { Text = "Close SwipeView" }; swipeLayout.Children.Add(openButton, 0, 0); swipeLayout.Children.Add(closeButton, 0, 1); var swipeItem = new SwipeItem { BackgroundColor = Color.Red, IconImageSource = "calculator.png", Text = "File" }; swipeItem.Invoked += (sender, e) => { DisplayAlert("SwipeView", "File Invoked", "Ok"); }; var swipeItems = new SwipeItems { swipeItem }; swipeItems.Mode = SwipeMode.Reveal; var swipeContent = new Grid { BackgroundColor = Color.Gray }; var fileSwipeLabel = new Label { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Text = "Swipe to Right (File)" }; swipeContent.Children.Add(fileSwipeLabel); var swipeView = new SwipeView { HeightRequest = 60, WidthRequest = 300, LeftItems = swipeItems, Content = swipeContent }; swipeLayout.Children.Add(swipeView, 0, 2); var scroll = new ScrollView(); var eventsInfo = new Label(); scroll.Content = eventsInfo; swipeLayout.Children.Add(scroll, 0, 3); Content = swipeLayout; openButton.Clicked += (sender, e) => { swipeView.Open(OpenSwipeItem.LeftItems); }; closeButton.Clicked += (sender, e) => { swipeView.Close(); }; swipeView.SwipeStarted += (sender, e) => { eventsInfo.Text += $"SwipeStarted - Direction:{e.SwipeDirection}" + Environment.NewLine; }; swipeView.SwipeChanging += (sender, e) => { eventsInfo.Text += $"SwipeChanging - Direction:{e.SwipeDirection}, Offset:{e.Offset}" + Environment.NewLine; }; swipeView.SwipeEnded += (sender, e) => { eventsInfo.Text += $"SwipeEnded - Direction:{e.SwipeDirection}" + Environment.NewLine; }; }