예제 #1
0
 private void OnCategoriesListViewSwiping(object sender, Gestures.ListViewSwipeEventArgs e)
 {
     if (e.SwipedItem is Grid grid && grid.Children.Count == 2 && e.OffsetX <= 0.0d && grid.BindingContext is DreamCategoryViewModel model)
     {
         if (Math.Abs(e.OffsetX) >= grid.Width / 3.0d != grid.Children[0].IsEnabled)
         {
             grid.Children[0].IsEnabled = !grid.Children[0].IsEnabled && model.DreamLogEntries?.Count == 0;
         }
         grid.Children[1].TranslationX = e.OffsetX;
     }
 }
예제 #2
0
        private async void OnCategoriesListViewSwiped(object sender, Gestures.ListViewSwipeEventArgs e)
        {
            if (e.SwipedItem is Grid grid && grid.Children.Count == 2)
            {
                grid.Children[1].TranslationX = 0;

                if (e.Direction == SwipeDirection.Left && grid.Children[0].IsEnabled && grid.BindingContext is DreamCategoryViewModel model)
                {
                    await grid.Children[1].TranslateToAbsolute(-grid.Width, 0);

                    if (this.datalayer.RemoveDreamCategory(model.CategoryId))
                    {
                        this.viewModel.Items.Remove(model);
                    }

                    //TODO: Timed undo action
                }
                else
                {
                    await grid.Children[1].TranslateToAbsolute(0, 0);
                }
            }
        }