Пример #1
0
        public override void SetEditing(bool editing, bool animated)
        {
            base.SetEditing(editing, animated);

            // Prevent navigating back in edit mode.
            NavigationItem.SetHidesBackButton(editing, animated);

            // Reload the first row to switch from "Add Item" to "Change Color"
            NSIndexPath indexPath = NSIndexPath.FromRowSection(0, 0);

            TableView.ReloadRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Automatic);

            // If moving out of edit mode, notify observers about the list color and trigger a save.
            if (!editing)
            {
                // Notify the document of a change.
                document.UpdateChangeCount(UIDocumentChangeKind.Done);

                MasterController.UpdateDocumentColor(DocumentURL, List.Color);

                TriggerNewDataForWidget();
            }

            NavigationController.SetToolbarHidden(!editing, animated);
            NavigationController.Toolbar.SetItems(listToolbarItems, animated);
        }
Пример #2
0
        public void CheckBoxTapped(CheckBox sender)
        {
            NSIndexPath indexPath = IndexPathForView(sender);

            ListItem          item = List[indexPath.Row];
            ListOperationInfo info = List.ToggleItem(item, -1);

            if (info.FromIndex == info.ToIndex)
            {
                TableView.ReloadRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Automatic);
            }
            else
            {
                int itemCount = List.Count;

                if (!ShowingAll && itemCount != TodayBaseRowCount && info.ToIndex > TodayBaseRowCount - 1)
                {
                    // Completing has moved an item off the bottom of the short list.
                    // Delete the completed row and insert a new row above "Show All...".
                    NSIndexPath targetIndexPath = NSIndexPath.FromRowSection(TodayBaseRowCount - 1, 0);

                    TableView.BeginUpdates();
                    TableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Automatic);
                    TableView.InsertRows(new NSIndexPath[] { targetIndexPath }, UITableViewRowAnimation.Automatic);
                    TableView.EndUpdates();
                }
                else
                {
                    // Need to animate the row up or down depending on its completion state.
                    NSIndexPath targetIndexPath = NSIndexPath.FromRowSection(info.ToIndex, 0);

                    TableView.BeginUpdates();
                    TableView.MoveRow(indexPath, targetIndexPath);
                    TableView.EndUpdates();
                    TableView.ReloadRows(new NSIndexPath[] { targetIndexPath }, UITableViewRowAnimation.Automatic);
                }
            }

            // Notify the document of a change.
            document.UpdateChangeCount(UIDocumentChangeKind.Done);
        }