Skip to content

Commit

Permalink
[todo11] minor tweaks for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
conceptdev committed Nov 30, 2017
1 parent b1207ad commit b6f2c27
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
17 changes: 9 additions & 8 deletions Todo11/Todo11/MapViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public override void ViewDidLoad()
View.AddSubview(CloseButton);

Map.ShowsUserLocation = true;
Map.ShowsCompass = true;
Map.AddGestureRecognizer((longPressGestureRecognizer = new UILongPressGestureRecognizer(OnMapLongPress)));
doubleTapGestureRecognizer = new UITapGestureRecognizer() { NumberOfTapsRequired = 2 };

Expand All @@ -51,14 +52,14 @@ public override void ViewDidLoad()
Map.AddGestureRecognizer(doubleTapGestureRecognizer);


Map.DidUpdateUserLocation += (sender, e) => {
if (Map.UserLocation != null)
{
CLLocationCoordinate2D coords = Map.UserLocation.Coordinate;
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(2), MilesToLongitudeDegrees(2, coords.Latitude));
Map.Region = new MKCoordinateRegion(coords, span);
}
};
//Map.DidUpdateUserLocation += (sender, e) => {
// if (Map.UserLocation != null)
// {
// CLLocationCoordinate2D coords = Map.UserLocation.Coordinate;
// MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(2), MilesToLongitudeDegrees(2, coords.Latitude));
// Map.Region = new MKCoordinateRegion(coords, span);
// }
//};
if (Map.UserLocation != null)
{
CLLocationCoordinate2D coords = Map.UserLocation.Coordinate;
Expand Down
11 changes: 5 additions & 6 deletions Todo11/Todo11/TableViewController+Drop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@ public partial class TableViewController : IUITableViewDropDelegate
/// <summary>
/// Ensure that the drop session contains a drag item with a data representation that the view can consume.
/// </summary>
[Export("tableView:canHandleDropSession:")]
public bool CanHandleDropSession(UITableView tableView, IUIDropSession session)
{
return session.CanLoadObjects(typeof(NSString));
}

/// <summary>
/// A drop proposal from a table view includes two items: a drop operation,
/// typically .move or .copy; and an intent, which declares the action the
/// typically Move or Copy; and an intent, which declares the action the
/// table view will take upon receiving the items. (A drop proposal from a
/// custom view does includes only a drop operation, not an intent.)
/// </summary>
[Export("tableView:dropSessionDidUpdate:withDestinationIndexPath:")]
public UITableViewDropProposal DropSessionDidUpdate(UITableView tableView, IUIDropSession session, NSIndexPath destinationIndexPath)
{
// The .move operation is available only for dragging within a single app.
// The Move operation is available only for dragging within a single app.
if (tableView.HasActiveDrag)
{
if (session.Items.Length > 1)
Expand Down Expand Up @@ -87,12 +85,13 @@ public void PerformDrop(UITableView tableView, IUITableViewDropCoordinator coord
for (var j = 0; j < stringItems.Count; j++)
{
var indexPath1 = NSIndexPath.FromRowSection(destinationIndexPath.Row + j, 0);

// update backing data
InsertTodo(new TodoItem { Name = stringItems[j] }, destinationIndexPath.Row);
todoItems = AppDelegate.Current.TodoMgr.GetOrderedTodos().ToList();

indexPaths.Add(indexPath1);
}
todoItems = AppDelegate.Current.TodoMgr.GetOrderedTodos().ToList();
// animate table view to match
if (indexPaths.Count > 0 && indexPaths.Count == stringItems.Count)
{
tableView.InsertRows(indexPaths.ToArray(), UITableViewRowAnimation.Automatic);
Expand Down
3 changes: 2 additions & 1 deletion Todo11/Todo11/TableViewController+Search.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ void ConfigureSearch()
DimsBackgroundDuringPresentation = false
};
search.SearchResultsUpdater = this; // implemented the interface above
DefinesPresentationContext = true; // IMPORTANT: ensures segue works
NavigationItem.SearchController = search;

DefinesPresentationContext = true; // IMPORTANT: ensures segue works
}

public void UpdateSearchResultsForSearchController(UISearchController searchController)
Expand Down
22 changes: 11 additions & 11 deletions Todo11/Todo11/TableViewController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Foundation;
using System;
using UIKit;
using System.Collections.Generic;
using System.Linq;
using CoreGraphics;
using CoreLocation;
using Foundation;
using UIKit;

namespace Todo11App
{
Expand All @@ -26,6 +25,15 @@ public override void ViewDidLoad()
{
base.ViewDidLoad();

// Impelement delegate and datasource for tableview to operate
TableView.DataSource = this;
TableView.Delegate = this;

// for Drag and Drop
TableView.DragDelegate = this;
TableView.DropDelegate = this;


AddButton.Clicked += (sender, e) =>
{
CreateTodo();
Expand Down Expand Up @@ -65,14 +73,6 @@ public override void ViewDidLoad()
};
NavigationController.View.AddSubview(MapButton);

// Impelement delegate and datasource for tableview to operate
TableView.DataSource = this;
TableView.Delegate = this;

// for Drag and Drop
TableView.DragDelegate = this;
TableView.DropDelegate = this;

// for 3DTouch
if (TraitCollection.ForceTouchCapability == UIForceTouchCapability.Available)
{
Expand Down

0 comments on commit b6f2c27

Please sign in to comment.