Пример #1
0
        //ContextualAction zum Bearbeiten des Namens
        public UIContextualAction contextualEditAction(int row, UITableView tableView)
        {
            var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                      "Edit",
                                                                      (UIContextualAction EditItem, UIView view, UIContextualActionCompletionHandler success) =>
            {
                var alertController = UIAlertController.Create("Editiere Pizza", "Bitte neuen Pizzanamen angeben", UIAlertControllerStyle.Alert);

                UITextField EditTask = null;
                alertController.AddTextField(EditTaskTxt =>
                {
                    EditTask      = EditTaskTxt;
                    EditTask.Text = zutatList[row].name;
                });
                alertController.AddAction(UIAlertAction.Create("OK",
                                                               UIAlertActionStyle.Default,
                                                               onClick =>
                {
                    zutatList[row].name = EditTask.Text;
                    tableView.BeginUpdates();
                    tableView.ReloadRows(tableView.IndexPathsForVisibleRows, UITableViewRowAnimation.Automatic);
                    tableView.EndUpdates();
                }));
                alertController.AddAction(UIAlertAction.Create("Abbrechen",
                                                               UIAlertActionStyle.Default,
                                                               onClick =>
                {
                }));
                zutatViewController.PresentViewController(alertController, true, null);
                success(true);
            });

            action.BackgroundColor = UIColor.Green;
            return(action);
        }
Пример #2
0
        //ContextualAction zum Bearbeiten des TaskItems
        public UIContextualAction contextualEditAction(int row, UITableView tableView)
        {
            var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                      "Edit",
                                                                      (UIContextualAction EditItem, UIView view, UIContextualActionCompletionHandler success) =>
            {
                var alertController = UIAlertController.Create("Edit Person", "Please enter new name", UIAlertControllerStyle.Alert);

                UITextField EditTask = null;
                alertController.AddTextField(EditTaskTxt =>
                {
                    EditTask      = EditTaskTxt;
                    EditTask.Text = personList[row].gsName;
                });
                alertController.AddAction(UIAlertAction.Create("OK",
                                                               UIAlertActionStyle.Default,
                                                               onClick =>
                {
                    personList[row].gsName = EditTask.Text;
                    tableView.BeginUpdates();
                    tableView.ReloadRows(tableView.IndexPathsForVisibleRows, UITableViewRowAnimation.Automatic);
                    tableView.EndUpdates();
                }));
                alertController.AddAction(UIAlertAction.Create("Cancel",
                                                               UIAlertActionStyle.Default,
                                                               onClick =>
                {
                }));
                personListController.PresentViewController(alertController, true, null);
                success(true);
            });

            return(action);
        }
Пример #3
0
        public UIContextualAction MarkTaskAsCompleteAction(UITableView tableView, NSIndexPath indexPath)
        {
            var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                      "Completed",
                                                                      (FlagAction, view, success) =>
            {
                var cell = tableView.CellAt(indexPath);
                if (cell.Accessory == UITableViewCellAccessory.Checkmark)
                {
                    Console.WriteLine("Oh no, you didnt GotItDone!");
                    cell.Accessory = UITableViewCellAccessory.None;
                    DetailViewController.didChangeChecked = false;
                }
                else
                {
                    Console.WriteLine("Congratulations, you have GotItDone!");
                    cell.Accessory = UITableViewCellAccessory.Checkmark;
                    cell.TintColor = UIColor.FromRGB(253, 81, 201);
                    DetailViewController.didChangeChecked = true;
                }
            });

            action.Image           = UIImage.FromFile("GetItDone.png");
            action.BackgroundColor = UIColor.FromRGB(253, 81, 201);
            return(action);
        }
Пример #4
0
        public UIContextualAction ContextualToFavoriteAction(int row)
        {
            var news   = ViewModel.News[row];
            var action = UIContextualAction.FromContextualActionStyle
                             (UIContextualActionStyle.Normal,
                             "",
                             (toFavorieAction, view, success) =>
            {
                var item = ViewModel.News[row];
                ViewModel.AddToFavoriteCommand.Execute(item);
                success(true);
            });

            if (!news.IsInFavorite)
            {
                action.Image = UIImage.FromBundle("baseline_favorite_border_white_24");
            }
            else
            {
                action.Image = UIImage.FromBundle("baseline_favorite_white_24");
            }
            action.BackgroundColor = UIColor.Blue;

            return(action);
        }
Пример #5
0
        public UIContextualAction clearAction(int row)
        {
            var action = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Normal, "Svuota",
                (insertAction, view, success) =>
            {
                var source      = Source as BoxViewController;
                var boxSelected = source.Boxes[row];

                var items = itemDAO.getAllItemInBox(boxSelected.Id);
                foreach (var b in items)
                {
                    b.Container = 0;
                    itemDAO.updateItem(b);
                    boxSelected.RemainVolume += b.Volume;
                }
                boxDAO.updateBox(boxSelected);

                var alertController = UIAlertController.Create("Box Vuoto", "Il tuo box è stato svuotato", UIAlertControllerStyle.Alert);

                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));

                Source.PresentViewController(alertController, true, null);

                success(true);
            });

            action.BackgroundColor = UIColor.LightGray;

            return(action);
        }
Пример #6
0
        public UIContextualAction ContextualDefinitionAction(int row)
        {
            string word = taskList[row].Name;

            var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                      "Definition",
                                                                      (ReadLaterAction, view, success) => {
                var def = new UIReferenceLibraryViewController(word);

                var alertController = UIAlertController.Create("No Dictionary Installed", "To install a Dictionary, Select Definition again, click `Manage` on the next screen and select a dictionary to download", UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));

                if (UIReferenceLibraryViewController.DictionaryHasDefinitionForTerm(word) || hasViewedAlert == true)
                {
                    viewController.PresentViewController(def, true, null);
                    success(true);
                }
                else
                {
                    viewController.PresentViewController(alertController, true, null);
                    hasViewedAlert = true;
                    success(false);
                }
            });

            action.BackgroundColor = UIColor.Orange;
            return(action);
        }
Пример #7
0
        private UIContextualAction ContextualCodeAction(int row)
        {
            UIContextualAction action = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Normal,
                "Code",
                (ReadLaterAction, view, success) => {
                NavigationController.PushViewController(_menuItems[row].ViewControllerCode, false);
            });

            action.BackgroundColor = UIColor.Orange;

            return(action);
        }
Пример #8
0
        public override UISwipeActionsConfiguration GetTrailingSwipeActionsConfiguration(UITableView tableView, NSIndexPath indexPath)
        {
            var deleteAction = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Destructive,
                "Delete",
                async(contextualAction, view, success) =>
            {
                await DeleteTodoItem(indexPath);
                success(true);
            });

            return(UISwipeActionsConfiguration.FromActions(new[] { deleteAction }));
        }
Пример #9
0
        //ContextualAction zum Bearbeiten des Namens
        public UIContextualAction contextualAddAction(int row, UITableView tableView)
        {
            var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                      "Add Ingredient",
                                                                      (AddItem, view, success) =>
            {
                ZutatViewController zutatViewController = (ZutatViewController)pizzaViewController.Storyboard.InstantiateViewController("ZutatViewController");
                pizzaViewController.NavigationController.PushViewController(zutatViewController, true);
                success(true);
            });

            action.BackgroundColor = UIColor.Orange;
            return(action);
        }
Пример #10
0
        public UIContextualAction ContextualFlagAction(int row)
        {
            var action = UIContextualAction.FromContextualActionStyle
                             (UIContextualActionStyle.Normal,
                             NSBundle.MainBundle.GetLocalizedString(Strings.EDIT),
                             (FlagAction, view, success) =>
            {
                success(true);
            });

            //action.Image = UIImage.FromFile("feedback.png");
            action.BackgroundColor = UIColor.FromRGB(84, 160, 255);

            return(action);
        }
Пример #11
0
        private UIContextualAction deleteSwipeActionFor(LogItemViewModel viewModel)
        {
            var deleteAction = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Destructive,
                Resources.Delete,
                (action, sourceView, completionHandler) =>
            {
                swipeToDeleteSubject.OnNext(viewModel);
                completionHandler.Invoke(finished: true);
            }
                );

            deleteAction.BackgroundColor = Core.UI.Helper.Colors.TimeEntriesLog.DeleteSwipeActionBackground.ToNativeColor();
            return(deleteAction);
        }
        private UIContextualAction continueSwipeActionFor(LogItemViewModel viewModel)
        {
            var continueAction = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Normal,
                Resources.Continue,
                (action, sourceView, completionHandler) =>
            {
                continueSwipeSubject.OnNext(viewModel);
                completionHandler.Invoke(finished: true);
            }
                );

            continueAction.BackgroundColor = Core.UI.Helper.Colors.TimeEntriesLog.ContinueSwipeActionBackground.ToNativeColor();
            return(continueAction);
        }
Пример #13
0
        private UIContextualAction deleteSwipeActionFor(TimeEntryViewModel timeEntry)
        {
            var deleteAction = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Destructive,
                Resources.Delete,
                (action, sourceView, completionHandler) =>
            {
                swipeToDeleteSubject.OnNext(timeEntry);
                completionHandler.Invoke(finished: true);
            }
                );

            deleteAction.BackgroundColor = Foundation.MvvmCross.Helper.Color.TimeEntriesLog.DeleteSwipeActionBackground.ToNativeColor();
            return(deleteAction);
        }
Пример #14
0
        private UIContextualAction continueSwipeActionFor(TimeEntryViewModel timeEntry)
        {
            var continueAction = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Normal,
                Resources.Continue,
                (action, sourceView, completionHandler) =>
            {
                ContinueTimeEntryCommand.Execute(timeEntry);
                completionHandler.Invoke(finished: true);
            }
                );

            continueAction.BackgroundColor = Color.TimeEntriesLog.ContinueSwipeActionBackground.ToNativeColor();
            return(continueAction);
        }
Пример #15
0
        private UIContextualAction ContextualXibAction(int row)
        {
            UIContextualAction action = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Normal,
                "XIB",
                (ReadLaterAction, view, success) => {
                NavigationController.PushViewController(_menuItems[row].ViewControllerXib, false);

                success(true);
            });

            action.BackgroundColor = UIColor.Blue;

            return(action);
        }
Пример #16
0
        public UIContextualAction ContextualFlagAction(NSIndexPath indexPath, UITableView tableView)
        {
            var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                      "",
                                                                      (FlagAction, view, success) =>
            {
                Lunches.RemoveAt(indexPath.Row);
                tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                success(true);
            });

            action.Image           = UIImage.FromBundle("Trash");
            action.BackgroundColor = UIColor.Red;
            return(action);
        }
Пример #17
0
        // Swipe right
        public UIContextualAction ContextualDoneAction(int row)
        {
            var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                      NSBundle.MainBundle.LocalizedString("Done", ""),
                                                                      (FlagAction, view, success) => {
                ToggleTodoDone(todoItems[row]);
                TableView.ReloadData();                                                           // otherwise ticks don't get updated
                success(true);
            });

            action.Image           = todoItems[row].Done ? UIImage.FromBundle("box") : UIImage.FromBundle("checkbox");
            action.BackgroundColor = UIColor.FromRGB(0x5A, 0x86, 0x22); // dark green

            return(action);
        }
Пример #18
0
        private UIContextualAction deleteSwipeActionFor(TimeEntryViewModel timeEntry)
        {
            var deleteAction = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Destructive,
                Resources.Delete,
                (action, sourceView, completionHandler) =>
            {
                SwipeToDeleteWasUsed?.Invoke(this, EventArgs.Empty);
                swipeToDeleteSubject.OnNext(timeEntry);
                completionHandler.Invoke(finished: true);
            }
                );

            deleteAction.BackgroundColor = Color.TimeEntriesLog.DeleteSwipeActionBackground.ToNativeColor();
            return(deleteAction);
        }
Пример #19
0
        //ContextualAction zum Löschen eines Eintrags
        public UIContextualAction contextualDeleteAction(NSIndexPath indexPath, UITableView tableView)
        {
            var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                      "Delete",
                                                                      (deleteItem, view, success) =>
            {
                listPersons.RemoveAt(indexPath.Row);
                tableView.BeginUpdates();
                tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                tableView.EndUpdates();
                success(true);
            });

            action.BackgroundColor = UIColor.Red;
            return(action);
        }
Пример #20
0
        //ContextualAction zum Bearbeiten der Person
        public UIContextualAction contextualEditAction(int row, UITableView tableView)
        {
            var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                      "Edit",
                                                                      (UIContextualAction EditItem, UIView view, UIContextualActionCompletionHandler success) => {
                DetailViewController detailViewController  = (DetailViewController)tablePersonController.Storyboard.InstantiateViewController("DetailViewController");
                detailViewController.currentPerson         = listPersons[row];
                detailViewController.personList            = listPersons;
                detailViewController.tablePersonController = tablePersonController;
                tablePersonController.NavigationController.PushViewController(detailViewController, true);
                success(true);
            });

            action.BackgroundColor = UIColor.Orange;
            return(action);
        }
Пример #21
0
        public UIContextualAction ContextualDeleteAction(int row)
        {
            var action = UIContextualAction.FromContextualActionStyle
                             (UIContextualActionStyle.Destructive,
                             "",
                             (deleteAction, view, success) =>
            {
                var item = ViewModel.News[row];
                ViewModel.RemoveNewsCommand.Execute(item);
                success(true);
            });

            action.Image           = UIImage.FromBundle("baseline_delete_white_24");
            action.BackgroundColor = UIColor.Red;

            return(action);
        }
Пример #22
0
        public UIContextualAction ContextualFlagAction(int row)
        {
            var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                      "Flag",
                                                                      (FlagAction, view, success) => {
                var alertController = UIAlertController.Create($"Report {words[row]}?", "", UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null));
                alertController.AddAction(UIAlertAction.Create("Yes", UIAlertActionStyle.Destructive, null));
                PresentViewController(alertController, true, null);

                success(true);
            });

            action.Image           = UIImage.FromFile("feedback.png");
            action.BackgroundColor = UIColor.Blue;

            return(action);
        }
Пример #23
0
        public UIContextualAction ContextualDefinitionAction(int row)
        {
            var place = ViewModel.Places[row];
            var store = AppStore.Instance;

            store.CurrentPlace = place;

            var action = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Normal,
                Strings.EDIT,
                (ReadLaterAction, view, success) =>
            {
                PerformSegue("ToEditPlace", this);
            });

            action.BackgroundColor = UIColor.FromRGB(16, 172, 132);
            return(action);
        }
Пример #24
0
        private UIContextualAction GetAction(UITableView tableView, NSIndexPath indexPath)
        {
            var item   = DataSource[indexPath.Row];
            var action = UIContextualAction.FromContextualActionStyle
                         (
                UIContextualActionStyle.Normal,
                item.IsMarked ? "UnMark Target" : "Mark Target",
                (markTarget, view, success) =>
            {
                DataSource[indexPath.Row].IsMarked = !item.IsMarked;
                ViewModel.UpdateMarking(item.IsMarked, item.Id, item.Date);
                tableView.ReloadRows(new[] { indexPath }, UITableViewRowAnimation.None);
                success(true);
            });

            action.BackgroundColor = UIColor.Blue;

            return(action);
        }
Пример #25
0
        public UIContextualAction ContextualDefinitionAction(int row)
        {
            var medi   = ViewModel.Medis[row];
            var action = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Normal,
                Strings.STOCK,
                (ReadLaterAction, view, success) =>
            {
                //var editStockDialog = UIAlertController.Create("HeyHo", "Let's go", UIAlertControllerStyle.Alert);
                //editStockDialog.ShowViewController(editStockDialog, this);
                // TODO - Deprecated, implement with "UIAlertController.Create"
                var editStockDialog = new UIAlertView
                {
                    Title          = NSBundle.MainBundle.GetLocalizedString(Strings.STOCK),
                    Message        = $"Enter new stock for '{medi.Name}'",
                    AlertViewStyle = UIAlertViewStyle.PlainTextInput
                };
                editStockDialog.GetTextField(0).Text         = medi.Stock.ToString();
                editStockDialog.GetTextField(0).KeyboardType = UIKeyboardType.DecimalPad;

                editStockDialog.AddButton("OK");
                editStockDialog.AddButton(NSBundle.MainBundle.GetLocalizedString(Strings.CANCEL));
                editStockDialog.Clicked += async(object sender, UIButtonEventArgs e) =>
                {
                    if (e.ButtonIndex == 0)
                    {
                        var stock = editStockDialog.GetTextField(0).Text;
                        if (double.TryParse(stock, out var newStock))
                        {
                            medi.Stock = ++newStock;
                            success(true);
                            await UpdateList(medi);
                        }
                    }
                };
                editStockDialog.Show();
            });

            action.BackgroundColor = UIColor.FromRGB(16, 172, 132);
            return(action);
        }
Пример #26
0
        //ContextualAction zum Löschen des Items
        public UIContextualAction contextualDeleteAction(NSIndexPath indexPath, UITableView tableView)
        {
            var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                      "Delete Pizza",
                                                                      (UIContextualAction DeleteItem, UIView view, UIContextualActionCompletionHandler success) => {
                var alertController = UIAlertController.Create("Lösche Pizza?", "Möchten Sie die Pizza entfernen?", UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("Abbrechen", UIAlertActionStyle.Cancel, null));
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, onClick =>
                {
                    tableView.BeginUpdates();
                    zutatList.RemoveAt(indexPath.Row);
                    tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                    tableView.EndUpdates();
                }));
                zutatViewController.PresentViewController(alertController, true, null);
                success(true);
            });

            action.BackgroundColor = UIColor.Red;
            return(action);
        }
        public override UISwipeActionsConfiguration GetTrailingSwipeActionsConfiguration(UITableView tableView, NSIndexPath indexPath)
        {
            var delete = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Destructive, "X", (action, sourceView, completionHandler) =>
            {
                _customListView.NotifyDeleteItemSelected(indexPath.Section);
                completionHandler(true);
            });

            var reduce = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal, "-1", (action, sourceView, completionHandler) =>
            {
                _customListView.NotifyReduceQuantitySelected(indexPath.Section);
                completionHandler(true);
            });

            reduce.BackgroundColor = UIColor.FromRGB(95, 95, 95);
            delete.BackgroundColor = UIColor.Red;
            var swipeAction = UISwipeActionsConfiguration.FromActions(new UIContextualAction[] { delete, reduce });

            swipeAction.PerformsFirstActionWithFullSwipe = false;
            return(swipeAction);
        }
Пример #28
0
        public UIContextualAction contexttualDeleteAction(NSIndexPath indexPath, UITableView tableView)
        {
            var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal, "Delete Person", (UIContextualAction DeleteItem, UIView view, UIContextualActionCompletionHandler success) =>
            {
                var alertController = UIAlertController.Create("Delete entry?", "Wanna delete?", UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null));
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, onClick =>
                {
                    tableView.BeginUpdates();
                    personList.RemoveAt(indexPath.Row);
                    //tableView.DeleteRows(new NSIndexPath[] { NSIndexPath.FromRowSection(tableView.NumberOfRowsInSection(0) - 1, 0) }, UITableViewRowAnimation.Fade);
                    tableView.DeleteRows(new NSIndexPath[] { tableView.IndexPathForSelectedRow }, UITableViewRowAnimation.Fade);
                    tableView.EndUpdates();
                }));
                personListController.PresentViewController(alertController, true, null);
                success(true);
            }
                                                                      );

            return(action);
        }
Пример #29
0
        public UIContextualAction duplicateAction(int row)
        {
            var action = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Normal, "Duplica",
                (insertAction, view, success) =>
            {
                var source      = Source as BoxViewController;
                var boxSelected = source.Boxes[row];

                var tmp = new Box(new MyObject(boxSelected.Name, boxSelected.Height, boxSelected.Width, boxSelected.Depth, boxSelected.Description));

                boxDAO.insertBox(tmp);

                source.reloadData();

                success(true);
            });

            action.BackgroundColor = UIColor.Blue;

            return(action);
        }
Пример #30
0
        public override UISwipeActionsConfiguration GetLeadingSwipeActionsConfiguration(UITableView tableView, NSIndexPath indexPath)
        {
            var checkInAlertActionTitle = _restaurantsMO[indexPath.Row].IsVisited ? AppResources.UndoCheckIn : AppResources.CheckIn;
            var checkInAction           = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Normal,
                checkInAlertActionTitle,
                (Check_in, sourceView, completionHandler)
                =>
            {
                var cell = tableView.CellAt(indexPath) as RestaurantTableViewCell;
                if (cell != null)
                {
                    cell.OnCheckInClicked();
                }
            });

            checkInAction.BackgroundColor = UIColor.FromRGB(0, 190, 0);
            checkInAction.Image           = _restaurantsMO[indexPath.Row].GetCheckInImage();
            var swipeconfiguration = UISwipeActionsConfiguration.FromActions(new UIContextualAction[] { checkInAction });

            return(swipeconfiguration);
        }