private void UnmarkAsCompletedPurchase(object obj)
        {
            PurchaseViewModel purchase = obj as PurchaseViewModel;

            if (purchase != null && purchase.isValid)
            {
                App.CurrentPurchases.FirstOrDefault(p => p.Name == purchase.Name).Completed = false;
                if (!App.CurrentPurchases.Any(p => p.Completed))
                {
                    var t = (Tab)(Main.CompletedPurchasesStackLayout.Parent.Parent.Parent.Parent);
                    t.IsEnabled = false;
                    var fi = (FlyoutItem)(t.Parent);
                    fi.CurrentItem = fi.Items[0];
                }
            }
            Back();
        }
        private async void MoveItem(object obj)
        {
            var item = (GroupItemViewModel)obj;

            if (string.IsNullOrEmpty(item.Name))
            {
                ListVM.Main.DisplayAlert("Внимание!", "Заполните название.", "Ок");
                return;
            }
            var dirs = ListVM.GroupsList.Where(g => g.Name != ListVM.ActiveGroup.Name && g.Name != "Без названия").Select(g => g.Name).ToArray();

            string[] directions = new string[dirs.Length + 2];
            directions[0] = "В активный список";
            for (int i = 1; i <= dirs.Length; i++)
            {
                directions[i] = dirs[i - 1];
            }
            directions[directions.Length - 1] = "В планы";

            var direct = await ListVM.Main.DisplayActionSheet("Переместить элемент в ...", "Отмена", null, directions);

            if (direct == directions[directions.Length - 1])//в планы
            {
                App.Database.SavePlanItem(new Plan()
                {
                    Name = item.Name
                });
                ListVM.Main.plan.Back();
                DeleteItem(item);
                ListVM.Main.DisplayAlert("", "Перемещено в планы", "Ок");
            }
            else if (direct == directions[0])//к активным
            {
                PurchaseViewModel purchase = new PurchaseViewModel()
                {
                    Name = item.Name, Count = item.Count, Units = item.Units, Completed = item.Completed, ListVM = ListVM.Main.activePurchases
                };

                if (App.CurrentPurchases.Any(p => p.Name.ToLower() == purchase.Name.ToLower()))
                {
                    ListVM.Main.DisplayAlert("Внимание!", "Такой элемент уже имеется в списке.", "Ok");
                    return;
                }
                App.CurrentPurchases.Add(purchase);
                ListVM.Main.activePurchases.Back();

                DeleteItem(item);

                if (App.CurrentPurchases.Any(p => p.Completed))
                {
                    ((Tab)(ListVM.Main.CompletedPurchasesStackLayout.Parent.Parent.Parent.Parent)).IsEnabled = true;
                }
                ListVM.Main.DisplayAlert("", "Добавлено к активному списку", "Ок");
            }
            else if (directions.Any(d => d == direct))
            {
                var grIndex = ListVM.GroupsList.IndexOf(ListVM.GroupsList.FirstOrDefault(g => g.Name == direct));
                if (ListVM.GroupsList[grIndex].PurchasesList == null)
                {
                    ListVM.GroupsList[grIndex].PurchasesList = new List <Purchase>();
                }
                else if (ListVM.GroupsList[grIndex].PurchasesList.Any(p => p.Name.ToLower() == direct.ToLower()))
                {
                    ListVM.Main.DisplayAlert("Внимание!", "Такой элемент уже имеется в списке.", "Ok");
                    return;
                }
                ListVM.GroupsList[grIndex].PurchasesList.Add(new Purchase()
                {
                    Name = item.Name, Count = item.Count, Completed = item.Completed, Units = item.Units
                });
                App.Database.SaveGroupItem(ListVM.GroupsList[grIndex].Group);
                DeleteItem(item);
                ListVM.Main.DisplayAlert("", $"Перемещено в группу {direct}", "Ок");
                ListVM.BackToList();
            }
        }