Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ReactiveUI/Cocoa/ReactiveCollectionView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace ReactiveUI
{
public abstract class ReactiveCollectionView : UICollectionView,
IReactiveNotifyPropertyChanged<ReactiveCollectionView>, IHandleObservableErrors, IReactiveObject, ICanActivate
IReactiveNotifyPropertyChanged<ReactiveCollectionView>, IHandleObservableErrors, IReactiveObject, ICanActivate, ICanForceManualActivation
{
protected ReactiveCollectionView(RectangleF frame, UICollectionViewLayout layout) : base(frame, layout) { setupRxObj(); }
protected ReactiveCollectionView(IntPtr handle) : base(handle) { setupRxObj(); }
Expand Down Expand Up @@ -97,5 +97,9 @@ public override void RemoveFromSuperview()
base.RemoveFromSuperview();
deactivated.OnNext(Unit.Default);
}

void ICanForceManualActivation.Activate(bool activate) {
RxApp.MainThreadScheduler.Schedule(() => (activate ? activated : deactivated).OnNext(Unit.Default));
}
}
}
2 changes: 2 additions & 0 deletions ReactiveUI/Cocoa/ReactiveCollectionViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
activated.OnNext(Unit.Default);
this.ActivateSubviews(true);
}

public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);
deactivated.OnNext(Unit.Default);
this.ActivateSubviews(false);
}
}
}
6 changes: 5 additions & 1 deletion ReactiveUI/Cocoa/ReactiveControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace ReactiveUI
{
public class ReactiveControl : UIControl, IReactiveNotifyPropertyChanged<ReactiveControl>, IHandleObservableErrors, IReactiveObject, ICanActivate
public class ReactiveControl : UIControl, IReactiveNotifyPropertyChanged<ReactiveControl>, IHandleObservableErrors, IReactiveObject, ICanActivate, ICanForceManualActivation
{
protected ReactiveControl() : base()
{
Expand Down Expand Up @@ -105,5 +105,9 @@ public override void ViewWillMoveToSuperview(NSView newsuper)
#endif
RxApp.MainThreadScheduler.Schedule(() => (newsuper != null ? activated : deactivated).OnNext(Unit.Default));
}

void ICanForceManualActivation.Activate(bool activate) {
RxApp.MainThreadScheduler.Schedule(() => (activate ? activated : deactivated).OnNext(Unit.Default));
}
}
}
6 changes: 5 additions & 1 deletion ReactiveUI/Cocoa/ReactiveImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace ReactiveUI
{
public abstract class ReactiveImageView : NSImageView, IReactiveNotifyPropertyChanged<ReactiveImageView>, IHandleObservableErrors, IReactiveObject, ICanActivate
public abstract class ReactiveImageView : NSImageView, IReactiveNotifyPropertyChanged<ReactiveImageView>, IHandleObservableErrors, IReactiveObject, ICanActivate, ICanForceManualActivation
{
public ReactiveImageView(RectangleF frame) : base(frame) { }
public ReactiveImageView(IntPtr handle) : base(handle) { }
Expand Down Expand Up @@ -100,6 +100,10 @@ public override void ViewWillMoveToSuperview(NSView newsuper)
#endif
RxApp.MainThreadScheduler.Schedule(() => (newsuper != null ? activated : deactivated).OnNext(Unit.Default));
}

void ICanForceManualActivation.Activate(bool activate) {
RxApp.MainThreadScheduler.Schedule(() => (activate ? activated : deactivated).OnNext(Unit.Default));
}
}
}

6 changes: 5 additions & 1 deletion ReactiveUI/Cocoa/ReactiveNSView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace ReactiveUI
/// This is an View that is both an NSView and has ReactiveObject powers
/// (i.e. you can call RaiseAndSetIfChanged)
/// </summary>
public class ReactiveView : NSView, IReactiveNotifyPropertyChanged<ReactiveView>, IHandleObservableErrors, IReactiveObject, ICanActivate
public class ReactiveView : NSView, IReactiveNotifyPropertyChanged<ReactiveView>, IHandleObservableErrors, IReactiveObject, ICanActivate, ICanForceManualActivation
{
protected ReactiveView() : base()
{
Expand Down Expand Up @@ -121,5 +121,9 @@ public override void ViewWillMoveToSuperview(NSView newsuper)
#endif
RxApp.MainThreadScheduler.Schedule(() => (newsuper != null ? activated : deactivated).OnNext(Unit.Default));
}

void ICanForceManualActivation.Activate(bool activate) {
RxApp.MainThreadScheduler.Schedule(() => (activate ? activated : deactivated).OnNext(Unit.Default));
}
}
}
21 changes: 21 additions & 0 deletions ReactiveUI/Cocoa/ReactiveNSViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,34 @@ public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
activated.OnNext(Unit.Default);
this.ActivateSubviews(true);
}

public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);
deactivated.OnNext(Unit.Default);
this.ActivateSubviews(false);
}
#endif
}

static class UIViewControllerMixins {
internal static void ActivateSubviews(this UIViewController This, bool activate)
{
This.View.ActivateSubviews(activate);
}

private static void ActivateSubviews(this UIView This, bool activate)
{
foreach (var view in This.Subviews) {
var subview = view as ICanForceManualActivation;
if (subview != null) {
subview.Activate(activate);
}

view.ActivateSubviews(activate);
}
}
}
}
2 changes: 2 additions & 0 deletions ReactiveUI/Cocoa/ReactivePageViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
activated.OnNext(Unit.Default);
this.ActivateSubviews(true);
}

public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);
deactivated.OnNext(Unit.Default);
this.ActivateSubviews(false);
}
}
}
2 changes: 2 additions & 0 deletions ReactiveUI/Cocoa/ReactiveTabBarController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
activated.OnNext(Unit.Default);
this.ActivateSubviews(true);
}

public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);
deactivated.OnNext(Unit.Default);
this.ActivateSubviews(false);
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion ReactiveUI/Cocoa/ReactiveTableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace ReactiveUI
{
public abstract class ReactiveTableView : UITableView, IReactiveNotifyPropertyChanged<ReactiveTableView>, IHandleObservableErrors, IReactiveObject, ICanActivate
public abstract class ReactiveTableView : UITableView, IReactiveNotifyPropertyChanged<ReactiveTableView>, IHandleObservableErrors, IReactiveObject, ICanActivate, ICanForceManualActivation
{
public ReactiveTableView(RectangleF frame) : base(frame) { }
public ReactiveTableView(IntPtr handle) : base(handle) { }
Expand Down Expand Up @@ -82,6 +82,10 @@ public override void WillMoveToSuperview(UIView newsuper)
base.WillMoveToSuperview(newsuper);
RxApp.MainThreadScheduler.Schedule(() => (newsuper != null ? activated : deactivated).OnNext(Unit.Default));
}

void ICanForceManualActivation.Activate(bool activate) {
RxApp.MainThreadScheduler.Schedule(() => (activate ? activated : deactivated).OnNext(Unit.Default));
}
}
}

2 changes: 2 additions & 0 deletions ReactiveUI/Cocoa/ReactiveTableViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
activated.OnNext(Unit.Default);
this.ActivateSubviews(true);
}

public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);
deactivated.OnNext(Unit.Default);
this.ActivateSubviews(false);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions ReactiveUI/Interfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ public interface ICanActivate
IObservable<Unit> Deactivated { get; }
}

internal interface ICanForceManualActivation {
void Activate(bool activate);
}

/// <summary>
/// Allows an additional string to make view resolution more specific than
/// just a type.
Expand Down