Skip to content

Commit

Permalink
[TaskyPro] iOS PCL example works in MonoDevelop
Browse files Browse the repository at this point in the history
BUT requires you edit Microsoft.Portable.Csharp.targets to force the
PCL to compile against .NET4
  • Loading branch information
conceptdev committed Jun 26, 2012
1 parent 2481204 commit 8965253
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
21 changes: 20 additions & 1 deletion TaskyPro/TaskyiOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Tasky.BL.Managers;
using Tasky.DL.SQLite;
using System.IO;

namespace Tasky {
[Register ("AppDelegate")]
Expand All @@ -11,9 +14,15 @@ public partial class AppDelegate : UIApplicationDelegate {
UIWindow window;
UINavigationController navController;
UITableViewController homeViewController;


public static AppDelegate Current { get; private set; }
public TaskManager TaskMgr { get; set; }
Connection conn;

public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
Current = this;

// create a new window instance based on the screen size
window = new UIWindow (UIScreen.MainScreen.Bounds);

Expand All @@ -39,6 +48,16 @@ public override bool FinishedLaunching (UIApplication app, NSDictionary options)
UIBarButtonItem.Appearance.SetTitleTextAttributes(ta, UIControlState.Normal);


var sqliteFilename = "TaskDB.db3";
// we need to put in /Library/ on iOS5.1 to meet Apple's iCloud terms
// (they don't want non-user-generated data in Documents)
string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
string libraryPath = Path.Combine (documentsPath, "../Library/"); // Library folder
var path = Path.Combine(libraryPath, sqliteFilename);
conn = new Connection(path);
TaskMgr = new TaskManager(conn);


// push the view controller onto the nav controller and show the window
navController.PushViewController(homeViewController, false);
window.RootViewController = navController;
Expand Down
8 changes: 4 additions & 4 deletions TaskyPro/TaskyiOS/Screens/iPhone/Home/controller_iPhone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public void SaveTask()
currentTask.Name = taskDialog.Name;
currentTask.Notes = taskDialog.Notes;
currentTask.Done = taskDialog.Done;
BL.Managers.TaskManager.SaveTask(currentTask);
AppDelegate.Current.TaskMgr.SaveTask(currentTask);
NavigationController.PopViewControllerAnimated (true);
context.Dispose (); // per documentation
}
public void DeleteTask ()
{
if (currentTask.ID >= 0)
BL.Managers.TaskManager.DeleteTask (currentTask.ID);
AppDelegate.Current.TaskMgr.DeleteTask (currentTask.ID);
NavigationController.PopViewControllerAnimated (true);
}

Expand All @@ -66,7 +66,7 @@ public override void ViewWillAppear (bool animated)

protected void PopulateTable ()
{
tasks = BL.Managers.TaskManager.GetTasks ().ToList ();
tasks = AppDelegate.Current.TaskMgr.GetTasks ().ToList ();
var newTask = MonoTouch.Foundation.NSBundle.MainBundle.LocalizedString ("<new task>", "<new task>");
Root = new RootElement ("Tasky") {
new Section() {
Expand All @@ -86,7 +86,7 @@ public override Source CreateSizingSource (bool unevenRows)
}
public void DeleteTaskRow(int rowId)
{
BL.Managers.TaskManager.DeleteTask(tasks[rowId].ID);
AppDelegate.Current.TaskMgr.DeleteTask(tasks[rowId].ID);
}
}
}

0 comments on commit 8965253

Please sign in to comment.