Created
February 7, 2015 23:53
-
-
Save thedillonb/cce05511f14b3fa71873 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reactive.Linq; | |
using System.Linq; | |
using ReactiveUI; | |
using UIKit; | |
namespace Banana | |
{ | |
public class FuckYou : ReactiveTableViewController | |
{ | |
public ReactiveList<Item> Stupid = new ReactiveList<Item>(); | |
public override void ViewDidLoad() | |
{ | |
NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Add, (s, e) => { | |
PresentViewController(new UINavigationController(new FuckMe(this)), true, null); | |
}); | |
Stupid.Add(new Item { Name = "Something" }); | |
Stupid.Add(new Item { Name = "Bad" }); | |
Stupid.Add(new Item { Name = "Will" }); | |
base.ViewDidLoad(); | |
TableView.Source = new Stupid(TableView, Stupid, new Foundation.NSString("Hello"), 44f, null); | |
} | |
} | |
public class FuckMe : ReactiveViewController | |
{ | |
public FuckMe(FuckYou f) | |
{ | |
NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Save, (s, e) => { | |
f.Stupid.Add(new Item { Name = "Happen" }); | |
NavigationController.DismissViewController(true, null); | |
}); | |
} | |
} | |
public class Stupid : ReactiveTableViewSource<Item> | |
{ | |
public Stupid(UIKit.UITableView tableView, IReactiveNotifyCollectionChanged<Item> collection, Foundation.NSString cellKey, float sizeHint, Action<UIKit.UITableViewCell> initializeCellAction) : base(tableView, collection, cellKey, sizeHint, initializeCellAction) | |
{ | |
tableView.RegisterClassForCellReuse(typeof(Cell), "Hello"); | |
} | |
} | |
public class Cell : ReactiveTableViewCell, IViewFor<Item> | |
{ | |
public Item _viewModel; | |
public Item ViewModel | |
{ | |
get { return _viewModel; } | |
set { this.RaiseAndSetIfChanged(ref _viewModel, value); } | |
} | |
object IViewFor.ViewModel | |
{ | |
get { return ((IViewFor<Item>)this).ViewModel; } | |
set { ((IViewFor<Item>)this).ViewModel = (Item)value; } | |
} | |
public Cell(IntPtr ptr) | |
: base(ptr) | |
{ | |
this.OneWayBind(this.ViewModel, x => x.Name, x => x.TextLabel.Text); | |
} | |
} | |
public class Item : ReactiveObject | |
{ | |
public string Name { get; set; } | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment