Ejemplo n.º 1
0
        public void TestSwipeItemView()
        {
            var swipeView = new SwipeView();

            var swipeItemViewContent = new Grid();

            swipeItemViewContent.BackgroundColor = Colors.Red;

            swipeItemViewContent.Children.Add(new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "SwipeItemView"
            });

            var swipeItemView = new SwipeItemView
            {
                Content = swipeItemViewContent
            };

            swipeView.LeftItems = new SwipeItems
            {
                swipeItemView
            };

            Assert.NotNull(swipeItemView);
            Assert.NotNull(swipeItemView.Content);
            Assert.AreNotEqual(0, swipeView.LeftItems.Count);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public Issue8753()
        {
            Title = "Issue 8753";

            var layout = new StackLayout();

            var instructions = new Label
            {
                BackgroundColor = Color.Black,
                TextColor       = Color.White,
                Text            = "If you can see and open the SwipeView below, the test has passed."
            };

            var deleteSwipeItem = new SwipeItem {
                BackgroundColor = Color.Red, Text = "Delete", IconImageSource = "coffee.png"
            };

            deleteSwipeItem.Invoked += (sender, e) =>
            {
                DisplayAlert("SwipeView", "Delete Invoked", "OK");
            };

            var swipeView = new SwipeView
            {
                HeightRequest   = 60,
                BackgroundColor = Color.LightGray,
                LeftItems       = new SwipeItems(new List <SwipeItem> {
                    deleteSwipeItem
                })
                {
                    Mode = SwipeMode.Reveal
                },
                RightItems = new SwipeItems
                {
                    deleteSwipeItem
                }
            };

            var content = new Grid
            {
                BackgroundColor = Color.LightGoldenrodYellow
            };

            var info = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to the Right"
            };

            content.Children.Add(info);

            swipeView.Content = content;

            layout.Children.Add(instructions);
            layout.Children.Add(swipeView);

            Content = layout;
        }
Ejemplo n.º 4
0
 void OnSwipedUp(System.Object sender, Xamarin.Forms.SwipedEventArgs e)
 {
     if (!_isExpanded)
     {
         SwipeView.TranslateTo(0, 0, 200, Easing.Linear);
         _isExpanded = true;
     }
 }
Ejemplo n.º 5
0
 void OnSwipedDown(System.Object sender, Xamarin.Forms.SwipedEventArgs e)
 {
     if (_isExpanded)
     {
         SwipeView.TranslateTo(0, 400, 200, Easing.Linear);
         _isExpanded = false;
     }
 }
Ejemplo n.º 6
0
        protected override void Init()
        {
            Title = "Issue 11286";

            var layout = new StackLayout();

            var instructions = new Label
            {
                Padding         = 12,
                BackgroundColor = Color.Black,
                TextColor       = Color.White,
                Text            = "Swipe to the right and tap the SwipeItem. If the text below the SwipeView is updated, the test has passed."
            };

            var swipeView = new SwipeView();

            var swipeItem = new SwipeItem
            {
                BackgroundColor = Color.Red,
                Text            = "Text"
            };

            swipeView.LeftItems = new SwipeItems
            {
                swipeItem
            };

            var swipeContent = new Grid
            {
                HeightRequest   = 80,
                BackgroundColor = Color.LightGray
            };

            var label = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Right"
            };

            swipeContent.Children.Add(label);

            swipeView.Content = swipeContent;

            var result = new Label();

            layout.Children.Add(instructions);
            layout.Children.Add(swipeView);
            layout.Children.Add(result);

            Content = layout;

            swipeItem.Clicked += (sender, args) =>
            {
                result.TextColor = Color.Green;
                result.Text      = "The test has passed";
            };
        }
Ejemplo n.º 7
0
        public void TestConstructor()
        {
            var swipeView = new SwipeView();

            Assert.AreEqual(0, swipeView.LeftItems.Count);
            Assert.AreEqual(0, swipeView.TopItems.Count);
            Assert.AreEqual(0, swipeView.RightItems.Count);
            Assert.AreEqual(0, swipeView.BottomItems.Count);
        }
Ejemplo n.º 8
0
        protected override void Init()
        {
            Title = "Issue 11251";

            BindingContext = this;

            var layout = new StackLayout();

            var instructions = new Label
            {
                Padding         = 12,
                BackgroundColor = Color.Black,
                TextColor       = Color.White,
                Text            = "Swipe to the right and tap the SwipeItem. Verify that the command has only been executed once."
            };

            var swipeView = new SwipeView();

            var swipeContent = new Grid
            {
                BackgroundColor = Color.LightGray,
                HeightRequest   = 80
            };

            var info = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe To Right"
            };

            swipeContent.Children.Add(info);

            swipeView.Content = swipeContent;

            var swipeItem = new SwipeItem
            {
                BackgroundColor = Color.Red,
                Text            = "Execute Command",
                Command         = ExecuteMe
            };

            swipeView.LeftItems = new SwipeItems
            {
                swipeItem
            };

            layout.Children.Add(instructions);
            layout.Children.Add(swipeView);

            Content = layout;

            swipeItem.Invoked += (sender, args) =>
            {
                Debug.WriteLine("SwipeItem Invoked...");
            };
        }
Ejemplo n.º 9
0
        protected override void Init()
        {
            Title = "Issue 8777";

            var layout = new StackLayout
            {
                Margin = new Thickness(12)
            };

            var instructions = new Label
            {
                BackgroundColor = Color.Black,
                TextColor       = Color.White,
                Text            = "Swipe to the right, if can open the SwipeView the test has passed."
            };

            var swipeItem = new SwipeItem
            {
                BackgroundColor = Color.Red,
                IconImageSource = "calculator.png"
            };

            swipeItem.Invoked += (sender, e) => { DisplayAlert("SwipeView", "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 Right (No Text)"
            };

            swipeContent.Children.Add(swipeLabel);

            var swipeView = new SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                LeftItems     = swipeItems,
                Content       = swipeContent
            };

            layout.Children.Add(instructions);
            layout.Children.Add(swipeView);

            Content = layout;
        }
Ejemplo n.º 10
0
        public static SwipeView SetItems(this SwipeView view, Func <IList <SwipeItem> > bottom = null, Func <IList <SwipeItem> > left = null, Func <IList <SwipeItem> > right = null, Func <IList <SwipeItem> > top = null)
        {
            bottom?.Invoke().ForEach(item => view.BottomItems.Add(item));
            left?.Invoke().ForEach(item => view.LeftItems.Add(item));
            right?.Invoke().ForEach(item => view.RightItems.Add(item));
            top?.Invoke().ForEach(item => view.TopItems.Add(item));

            return(view);
        }
Ejemplo n.º 11
0
        public static SwipeView LeftItems(this SwipeView view, Func <IList <SwipeItem> > items)
        {
            if (items is null)
            {
                throw new ArgumentNullException();
            }

            items.Invoke().ForEach(item => view.LeftItems.Add(item));
            return(view);
        }
Ejemplo n.º 12
0
        public static SwipeView RightItems(this SwipeView view, IList <SwipeItem> items)
        {
            if (items is null)
            {
                throw new ArgumentNullException();
            }

            items.ForEach(item => view.RightItems.Add(item));
            return(view);
        }
Ejemplo n.º 13
0
        public static SwipeView LeftItems(this SwipeView view, SwipeItem item)
        {
            if (item is null)
            {
                throw new ArgumentNullException();
            }

            view.LeftItems.Add(item);
            return(view);
        }
Ejemplo n.º 14
0
        public static SwipeView LeftItems(this SwipeView view, params SwipeItem[] items)
        {
            if (items is null)
            {
                throw new ArgumentNullException();
            }

            items.ForEach(item => view.LeftItems.Add(item));
            return(view);
        }
Ejemplo n.º 15
0
        protected override void Init()
        {
            Title = "Issue 8973";

            var swipeLayout = new StackLayout
            {
                Margin = new Thickness(12)
            };

            var instructions = new Label
            {
                BackgroundColor = Color.Black,
                TextColor       = Color.White,
                Text            = "Swipe to the right and verify that the opening animation of the SwipeView is correct."
            };

            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();

            var swipeLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Right (File)"
            };

            swipeContent.Children.Add(swipeLabel);

            var swipeView = new SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                LeftItems     = swipeItems,
                Content       = swipeContent
            };

            swipeLayout.Children.Add(instructions);
            swipeLayout.Children.Add(swipeView);

            Content = swipeLayout;
        }
Ejemplo n.º 16
0
        SwipeView CreateMySwipeView()
        {
            var leftSwipeItem = new SwipeItemView
            {
                AutomationId = SwipeItemId,
                Content      = new Label
                {
                    Text              = "Right",
                    TextColor         = Color.White,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center
                },
                BackgroundColor = Color.Green,
                WidthRequest    = 80,
                Command         = new Command(() =>
                {
                    _leftCount++;
                    _leftSwipeCountLabel.Text = _leftCount.ToString();
                })
            };

            var leftSwipeItems = new SwipeItems {
                leftSwipeItem
            };

            leftSwipeItems.SwipeBehaviorOnInvoked = SwipeBehaviorOnInvoked.Close;
            leftSwipeItems.Mode = SwipeMode.Reveal;

            var swipeContent = new ContentView
            {
                Content = new StackLayout
                {
                    AutomationId    = SwipeViewId,
                    BackgroundColor = Color.LightSkyBlue,
                    Children        =
                    {
                        new Label
                        {
                            Text = "SwipeItem Content",
                            HorizontalOptions = LayoutOptions.Center,
                            VerticalOptions   = LayoutOptions.Center
                        }
                    }
                }
            };

            var mySwipeView = new SwipeView
            {
                LeftItems     = leftSwipeItems,
                Content       = swipeContent,
                HeightRequest = 80
            };

            return(mySwipeView);
        }
Ejemplo n.º 17
0
        public NoIconTextSwipeItemGallery()
        {
            Title = "No Icon or Text SwipeItem Gallery";

            var swipeLayout = new StackLayout
            {
                Margin = new Thickness(12)
            };

            var noIconSwipeItem = new SwipeItem
            {
                BackgroundColor = Colors.Red,
                Text            = "File"
            };

            var noTextSwipeItem = new SwipeItem
            {
                BackgroundColor = Colors.BlueViolet,
                IconImageSource = "calculator.png"
            };

            var swipeItems = new SwipeItems {
                noIconSwipeItem, noTextSwipeItem
            };

            swipeItems.Mode = SwipeMode.Reveal;

            var swipeContent = new Grid
            {
                BackgroundColor = Colors.Gray
            };

            var swipeLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Right (File)"
            };

            swipeContent.Children.Add(swipeLabel);

            var swipeView = new SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                LeftItems     = swipeItems,
                Content       = swipeContent
            };

            swipeLayout.Children.Add(swipeView);

            Content = swipeLayout;
        }
Ejemplo n.º 18
0
        public PartyPickerPage()
        {
            var listView = new ListView(ListViewCachingStrategy.RecycleElement)
            {
                ItemTemplate           = new DataTemplate(typeof(PartyTemplate)),
                RowHeight              = 150,
                IsPullToRefreshEnabled = true
            };

            var swipeView =
                new SwipeView();

            swipeView.SetTemplate <SwipeViewTemplate>();


            var changeViewToolbarItem = new ToolbarItem()
            {
                Text    = AppResources.ToOtherView,
                Command = new Command(() =>
                {
                    if (Content == swipeView)
                    {
                        Content = listView;
                    }
                    else
                    {
                        Content = swipeView;
                    }
                }),
                Icon = "swipe.png"
            };

            ToolbarItems.Add(changeViewToolbarItem);

            swipeView.SetBinding(SwipeView.ItemsSourceProperty, "Parties");
            swipeView.SetBinding(SwipeView.SwipedOutLeftCommandProperty, "NotePartyCommand");
            swipeView.SetBinding(SwipeView.SwipeOutRightCommandProperty, "AcceptPartyCommand");


            //List view bindings
            listView.SetBinding(ListView.ItemsSourceProperty, "Parties");
            listView.SetBinding(ListView.RefreshCommandProperty, "RefreshCommand");
            listView.SetBinding(ListView.IsRefreshingProperty, "IsRefreshing");
            listView.ItemSelected += ListViewOnItemSelected;

            this.SetBinding(CustomContentPage.ShowNoContentWarningProperty, nameof(PartyPickerViewModel.NearPartyAvailable),
                            converter: new InvertBooleanConverter());

            Content = listView;
        }
Ejemplo n.º 19
0
        public void TestLeftItems()
        {
            var swipeView = new SwipeView();

            var swipeItem = new SwipeItem
            {
                BackgroundColor = Colors.Red,
                Text            = "Text"
            };

            swipeView.LeftItems = new SwipeItems
            {
                swipeItem
            };

            Assert.AreNotEqual(0, swipeView.LeftItems.Count);
        }
Ejemplo n.º 20
0
        public void TestDefaultSwipeItems()
        {
            var swipeView = new SwipeView();

            var swipeItem = new SwipeItem
            {
                BackgroundColor = Colors.Red,
                Text            = "Text"
            };

            swipeView.LeftItems = new SwipeItems
            {
                swipeItem
            };

            Assert.AreEqual(SwipeMode.Reveal, swipeView.LeftItems.Mode);
            Assert.AreEqual(SwipeBehaviorOnInvoked.Auto, swipeView.LeftItems.SwipeBehaviorOnInvoked);
        }
Ejemplo n.º 21
0
        public void TestSwipeItemsSwipeBehaviorOnInvoked()
        {
            var swipeView = new SwipeView();

            var swipeItem = new SwipeItem
            {
                BackgroundColor = Colors.Red,
                Text            = "Text"
            };

            var swipeItems = new SwipeItems
            {
                SwipeBehaviorOnInvoked = SwipeBehaviorOnInvoked.Close
            };

            swipeItems.Add(swipeItem);

            swipeView.LeftItems = swipeItems;

            Assert.AreEqual(SwipeBehaviorOnInvoked.Close, swipeView.LeftItems.SwipeBehaviorOnInvoked);
        }
Ejemplo n.º 22
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.SubGallery);

            SetSupportActionBar(MainToolbar);

            layoutManager = new GridAutofitLayoutManager(this, 120);
            SubGalleryRecyclerView.SetLayoutManager(layoutManager);

            SwipeView.SetCommand("Refresh", Vm.RefreshCommand);

            bindings.Add(this.SetBinding(() => Vm.Images).WhenSourceChanges(BindCollection));
            bindings.Add(this.SetBinding(() => Vm.Sub.Title, () => SupportActionBar.Title));
            bindings.Add(this.SetBinding(() => Vm.Images.IsBusy, () => SwipeView.Refreshing));

            var param = Nav.GetAndRemoveParameter <string>(Intent);

            Vm.Activate(param);
            AnalyticsHelper.SendView("SubredditGallery");
        }
Ejemplo n.º 23
0
        public void TestSwipeItemsExecuteMode()
        {
            var swipeView = new SwipeView();

            var swipeItem = new SwipeItem
            {
                BackgroundColor = Colors.Red,
                Text            = "Text"
            };

            var swipeItems = new SwipeItems
            {
                Mode = SwipeMode.Execute
            };

            swipeItems.Add(swipeItem);

            swipeView.LeftItems = swipeItems;

            Assert.AreEqual(SwipeMode.Execute, swipeView.LeftItems.Mode);
        }
        private void rightImage_BindingContextChanged(object sender, EventArgs e)
        {
            Image              rightImage         = sender as Image;
            Grid               grid1              = (Grid)rightImage.Parent;
            Grid               grid2              = (Grid)grid1.Parent;
            Grid               grid3              = (Grid)grid2.Parent;
            SwipeView          swipeView          = (SwipeView)grid3.Parent;
            VisualContainer    visualContainer    = (VisualContainer)swipeView.Parent;
            ExtendedScrollView extendedScrollView = (ExtendedScrollView)visualContainer.Parent;
            SfListView         sfListView         = (SfListView)extendedScrollView.Parent;
            Collection <Lado>  Source             = (Collection <Lado>)sfListView.ItemsSource;
            Lado               item = Source[itemIndex];

            DeleteEvent evento = new DeleteEvent(item);

            evento.executeEvent += Evento_executeEvent;
            (rightImage.Parent as View).GestureRecognizers.Clear();
            (rightImage.Parent as View).GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = evento
            });
            rightImage.Source = "Delete.png";
        }
Ejemplo n.º 25
0
        public MainPage()
        {
            var label = new Label
            {
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalOptions       = LayoutOptions.CenterAndExpand,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                Text            = "Swipe Right-to-Left to Crash App\n\nSwipe Left-to-Right for Working Example",
                BackgroundColor = Color.LightGoldenrodYellow
            };

            var swipeItemWithText = new SwipeItem
            {
                IconImageSource = "AppIcon",
                BackgroundColor = Color.Green,
                Text            = "Test"
            };

            var swipeItemWithNoText = new SwipeItem
            {
                IconImageSource = "AppIcon",
                BackgroundColor = Color.Red
            };

            var swipeView = new SwipeView
            {
                Margin            = new Thickness(20),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                LeftItems         = { swipeItemWithText },
                RightItems        = { swipeItemWithNoText },
                Content           = label
            };

            Content = swipeView;
        }
Ejemplo n.º 26
0
        public SwipeItemIconGallery()
        {
            Title = "SwipeItem Icon Gallery";

            var scroll = new ScrollView();

            var swipeLayout = new StackLayout
            {
                Margin = new Thickness(12)
            };

            var fileSwipeItem = new SwipeItem
            {
                BackgroundColor = Colors.Red,
                IconImageSource = "coffee.png",
                Text            = "File"
            };

            fileSwipeItem.Invoked += (sender, e) => { DisplayAlert("SwipeView", "File Invoked", "Ok"); };

            var fileSwipeItems = new SwipeItems {
                fileSwipeItem
            };

            fileSwipeItems.Mode = SwipeMode.Reveal;

            var fileSwipeContent = new Grid
            {
                BackgroundColor = Colors.Gray
            };

            var fileSwipeLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Right (File)"
            };

            fileSwipeContent.Children.Add(fileSwipeLabel);

            var fileSwipeView = new SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                LeftItems     = fileSwipeItems,
                Content       = fileSwipeContent
            };

            swipeLayout.Children.Add(fileSwipeView);

            var urlSwipeItem = new SwipeItem
            {
                BackgroundColor = Colors.Red,
                IconImageSource = "https://image.flaticon.com/icons/png/512/61/61848.png",
                Text            = "Url"
            };

            urlSwipeItem.Invoked += (sender, e) => { DisplayAlert("SwipeView", "Url Invoked", "Ok"); };

            var urlSwipeItems = new SwipeItems {
                urlSwipeItem
            };

            urlSwipeItems.Mode = SwipeMode.Reveal;

            var urlSwipeContent = new Grid
            {
                BackgroundColor = Colors.Gray
            };

            var urlSwipeLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Right (Url)"
            };

            urlSwipeContent.Children.Add(urlSwipeLabel);

            var urlSwipeView = new SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                LeftItems     = urlSwipeItems,
                Content       = urlSwipeContent
            };

            swipeLayout.Children.Add(urlSwipeView);

            var fontFamily = string.Empty;

            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
                fontFamily = "Ionicons";
                break;

            case Device.UWP:
                fontFamily = "Assets/Fonts/ionicons.ttf#ionicons";
                break;

            case Device.Android:
            default:
                fontFamily = "fonts/ionicons.ttf#";
                break;
            }

            var fontSwipeItem = new SwipeItem
            {
                BackgroundColor = Colors.Red,
                IconImageSource = new FontImageSource
                {
                    Glyph      = "\uf101",
                    FontFamily = fontFamily,
                    Size       = 16
                },
                Text = "Font"
            };

            fontSwipeItem.Invoked += (sender, e) => { DisplayAlert("SwipeView", "Font Invoked", "Ok"); };

            var fontSwipeItems = new SwipeItems {
                fontSwipeItem
            };

            fontSwipeItems.Mode = SwipeMode.Reveal;

            var fontSwipeContent = new Grid
            {
                BackgroundColor = Colors.Gray
            };

            var fontSwipeLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Right (Font)"
            };

            fontSwipeContent.Children.Add(fontSwipeLabel);

            var fontSwipeView = new SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                LeftItems     = fontSwipeItems,
                Content       = fontSwipeContent
            };

            swipeLayout.Children.Add(fontSwipeView);

            scroll.Content = swipeLayout;

            Content = scroll;
        }
Ejemplo n.º 27
0
        public Issue11314Page(string title)
        {
            Title = title;

            for (int i = 0; i < 5; i++)
            {
                Items.Add(DateTime.Now.ToString());
            }

            var layout = new StackLayout
            {
                Padding = 0
            };

            var instructions = new Label
            {
                Padding         = 12,
                BackgroundColor = Color.Black,
                TextColor       = Color.White,
                Text            = "Try to open the SwipeView doing swipe, if you can open it, the test has passed."
            };

            var listView = new ListView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HasUnevenRows     = true,
                ItemsSource       = Items,
                ItemTemplate      = new DataTemplate(() =>
                {
                    var itemLayout = new StackLayout();

                    var swipeView = new SwipeView();

                    var content = new Grid
                    {
                        HeightRequest   = 80,
                        BackgroundColor = Color.LightGray
                    };

                    content.Children.Add(new Label
                    {
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions   = LayoutOptions.Center,
                        Text = "Swipe to Left"
                    });

                    swipeView.Content = content;

                    var swipeItem = new SwipeItem
                    {
                        BackgroundColor = Color.Red,
                        Text            = "Text"
                    };

                    swipeView.RightItems = new SwipeItems
                    {
                        swipeItem
                    };

                    itemLayout.Children.Add(swipeView);

                    return(new ViewCell {
                        View = itemLayout
                    });
                })
            };

            layout.Children.Add(instructions);
            layout.Children.Add(listView);

            Content = layout;
        }
Ejemplo n.º 28
0
        protected override void Init()
        {
            Title = "Issue 8806";

            var layout = new StackLayout
            {
                Margin = new Thickness(12)
            };

            var instructions = new Label
            {
                BackgroundColor = Color.Black,
                TextColor       = Color.White,
                Text            = "Swipe left and right several times and verify that the layout is always correct."
            };

            var leftSwipeItem = new SwipeItem
            {
                BackgroundColor = Color.Red,
                IconImageSource = "calculator.png",
                Text            = "Delete"
            };

            leftSwipeItem.Invoked += (sender, e) => { DisplayAlert("SwipeView", "Delete Invoked", "Ok"); };

            var rightSwipeItem = new SwipeItem
            {
                BackgroundColor = Color.LightGoldenrodYellow,
                IconImageSource = "calculator.png",
                Text            = "Edit"
            };

            rightSwipeItem.Invoked += (sender, e) => { DisplayAlert("SwipeView", "Edit Invoked", "Ok"); };

            var leftSwipeItems = new SwipeItems {
                leftSwipeItem
            };

            leftSwipeItems.Mode = SwipeMode.Reveal;

            var rightSwipeItems = new SwipeItems {
                leftSwipeItem, rightSwipeItem
            };

            rightSwipeItems.Mode = SwipeMode.Reveal;

            var swipeContent = new Grid
            {
                BackgroundColor = Color.Gray
            };

            var swipeLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Left or Right"
            };

            swipeContent.Children.Add(swipeLabel);

            var swipeView = new SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                LeftItems     = leftSwipeItems,
                RightItems    = rightSwipeItems,
                Content       = swipeContent
            };

            layout.Children.Add(instructions);
            layout.Children.Add(swipeView);

            Content = layout;
        }
Ejemplo n.º 29
0
        public SwipeViewEventsGallery()
        {
            Title = "SwipeView Events Gallery";

            var swipeLayout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    }
                },
                Margin = new Thickness(12)
            };

            var deleteSwipeItem = new SwipeItem
            {
                BackgroundColor = Color.Orange,
                IconImageSource = "calculator.png",
                Text            = "SwipeItem1"
            };

            deleteSwipeItem.Invoked += (sender, e) => { DisplayAlert("SwipeView", "Delete Invoked", "Ok"); };

            var leftSwipeItems = new SwipeItems
            {
                deleteSwipeItem
            };

            leftSwipeItems.Mode = SwipeMode.Reveal;

            var swipeContent = new Grid
            {
                BackgroundColor = Color.Gray
            };

            var swipeLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Right"
            };

            swipeContent.Children.Add(swipeLabel);

            var scroll     = new ScrollView();
            var eventsInfo = new Label();

            scroll.Content = eventsInfo;

            var swipeView = new SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                LeftItems     = leftSwipeItems,
                Content       = swipeContent
            };

            swipeLayout.Children.Add(swipeView, 0, 0);
            swipeLayout.Children.Add(scroll, 0, 1);

            Content = swipeLayout;

            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}, IsOpen: {e.IsOpen}" + Environment.NewLine;
            };
        }
Ejemplo n.º 30
0
        public SwipeView CreateMySwipeView()
        {
            // Define Right Swipe
            var rightSwipeItem = new SwipeItem
            {
                Text            = "Right",
                BackgroundColor = Color.Green,
                Command         = new Command(() =>
                {
                    _leftCount++;
                    _leftSwipeCountLabel.Text = _leftCount.ToString();
                })
            };

            var rightSwipeItems = new SwipeItems {
                rightSwipeItem
            };

            rightSwipeItems.SwipeBehaviorOnInvoked = SwipeBehaviorOnInvoked.Close;
            rightSwipeItems.Mode = SwipeMode.Execute;

            // Define Left Swipe
            var leftSwipeItem = new SwipeItem
            {
                Text            = "Left",
                BackgroundColor = Color.Red,
                Command         = new Command(() =>
                {
                    _rightCount++;
                    _rightSwipeCountLabel.Text = _rightCount.ToString();
                })
            };

            var leftSwipeItems = new SwipeItems {
                leftSwipeItem
            };

            leftSwipeItems.SwipeBehaviorOnInvoked = SwipeBehaviorOnInvoked.Close;
            leftSwipeItems.Mode = SwipeMode.Execute;


            // Define Swipe Content
            var swipeContent = new ContentView
            {
                Content = new StackLayout
                {
                    AutomationId    = SwipeViewId,
                    BackgroundColor = Color.Coral,
                    Children        =
                    {
                        new Label
                        {
                            Text = "Standalone SwipeItem",
                            HorizontalOptions = LayoutOptions.Center,
                            VerticalOptions   = LayoutOptions.Center
                        }
                    }
                }
            };


            // Create SwipeView
            var mySwipeView = new SwipeView
            {
                RightItems    = rightSwipeItems,
                LeftItems     = leftSwipeItems,
                Content       = swipeContent,
                HeightRequest = 80
            };

            return(mySwipeView);
        }