public void CheckBoxTapped(CheckBox sender) { NSIndexPath indexPath = IndexPathForView(sender); if (indexPath.Row >= 1 && indexPath.Row <= List.Count) { ListItem item = List[indexPath.Row - 1]; ListOperationInfo info = List.ToggleItem(item, -1); if (info.FromIndex == info.ToIndex) { TableView.ReloadRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Automatic); } else { // Animate the row up or down depending on whether it was complete/incomplete. NSIndexPath target = NSIndexPath.FromRowSection(info.ToIndex + 1, 0); TableView.BeginUpdates(); TableView.MoveRow(indexPath, target); TableView.EndUpdates(); TableView.ReloadRows(new NSIndexPath[] { target }, UITableViewRowAnimation.Automatic); } TriggerNewDataForWidget(); // notify the document that we've made a change document.UpdateChangeCount(UIDocumentChangeKind.Done); } }
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); }