Skip to content

Commit b0158ee

Browse files
committed
Same deal for ViewControllers
1 parent ea957bc commit b0158ee

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

ReactiveUI.Platforms/Cocoa/ReactiveCollectionViewController.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
using MonoTouch.Foundation;
1717
using MonoTouch.UIKit;
1818
using Splat;
19+
using System.Reactive;
1920

2021
namespace ReactiveUI.Cocoa
2122
{
22-
public abstract class ReactiveCollectionViewController : UICollectionViewController, IReactiveNotifyPropertyChanged, IHandleObservableErrors, IReactiveObjectExtension
23+
public abstract class ReactiveCollectionViewController : UICollectionViewController, IReactiveNotifyPropertyChanged, IHandleObservableErrors, IReactiveObjectExtension, ICanActivate
2324
{
2425
protected ReactiveCollectionViewController(UICollectionViewLayout withLayout) : base(withLayout) { setupRxObj(); }
2526
protected ReactiveCollectionViewController(string nibName, NSBundle bundle) : base(nibName, bundle) { setupRxObj(); }
@@ -81,5 +82,22 @@ public IDisposable SuppressChangeNotifications()
8182
{
8283
return this.suppressChangeNotifications();
8384
}
85+
86+
Subject<Unit> activated = new Subject<Unit>();
87+
public IObservable<Unit> Activated { get { return activated; } }
88+
Subject<Unit> deactivated = new Subject<Unit>();
89+
public IObservable<Unit> Deactivated { get { return deactivated; } }
90+
91+
public override void ViewDidLoad()
92+
{
93+
base.ViewDidLoad();
94+
activated.OnNext(Unit.Default);
95+
}
96+
97+
public override void ViewDidUnload()
98+
{
99+
base.ViewDidUnload();
100+
deactivated.OnNext(Unit.Default);
101+
}
84102
}
85103
}

ReactiveUI.Platforms/Cocoa/ReactiveImageView.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using MonoTouch.UIKit;
2121
using NSImageView = MonoTouch.UIKit.UIImageView;
2222
using NSImage = MonoTouch.UIKit.UIImage;
23+
using NSView = MonoTouch.UIKit.UIView;
2324
#else
2425
using MonoMac.AppKit;
2526
#endif

ReactiveUI.Platforms/Cocoa/ReactiveNSViewController.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Runtime.CompilerServices;
1313
using System.Collections.Generic;
1414
using Splat;
15+
using System.Reactive;
1516

1617
#if UIKIT
1718
using MonoTouch.UIKit;
@@ -103,5 +104,22 @@ public IDisposable SuppressChangeNotifications()
103104
{
104105
return this.suppressChangeNotifications();
105106
}
107+
108+
Subject<Unit> activated = new Subject<Unit>();
109+
public IObservable<Unit> Activated { get { return activated; } }
110+
Subject<Unit> deactivated = new Subject<Unit>();
111+
public IObservable<Unit> Deactivated { get { return deactivated; } }
112+
113+
public override void ViewDidLoad()
114+
{
115+
base.ViewDidLoad();
116+
activated.OnNext(Unit.Default);
117+
}
118+
119+
public override void ViewDidUnload()
120+
{
121+
base.ViewDidUnload();
122+
deactivated.OnNext(Unit.Default);
123+
}
106124
}
107125
}

ReactiveUI.Platforms/Cocoa/ReactiveTableViewController.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
using MonoTouch.UIKit;
1919
using NSTableViewController = MonoTouch.UIKit.UITableViewController;
2020
using NSTableViewStyle = MonoTouch.UIKit.UITableViewStyle;
21+
using System.Reactive;
2122

2223
namespace ReactiveUI.Cocoa
2324
{
24-
public abstract class ReactiveTableViewController : NSTableViewController, IReactiveNotifyPropertyChanged, IHandleObservableErrors, IReactiveObjectExtension
25+
public abstract class ReactiveTableViewController : NSTableViewController, IReactiveNotifyPropertyChanged, IHandleObservableErrors, IReactiveObjectExtension, ICanActivate
2526
{
2627
protected ReactiveTableViewController(NSTableViewStyle withStyle) : base(withStyle) { setupRxObj(); }
2728
protected ReactiveTableViewController(string nibName, NSBundle bundle) : base(nibName, bundle) { setupRxObj(); }
@@ -83,6 +84,23 @@ public IDisposable SuppressChangeNotifications()
8384
{
8485
return this.suppressChangeNotifications();
8586
}
87+
88+
Subject<Unit> activated = new Subject<Unit>();
89+
public IObservable<Unit> Activated { get { return activated; } }
90+
Subject<Unit> deactivated = new Subject<Unit>();
91+
public IObservable<Unit> Deactivated { get { return deactivated; } }
92+
93+
public override void ViewDidLoad()
94+
{
95+
base.ViewDidLoad();
96+
activated.OnNext(Unit.Default);
97+
}
98+
99+
public override void ViewDidUnload()
100+
{
101+
base.ViewDidUnload();
102+
deactivated.OnNext(Unit.Default);
103+
}
86104
}
87105
}
88106

0 commit comments

Comments
 (0)