public static IObservable <NSIndexPath> ItemSelected <TParent>(this Reactive <TParent> rx) where TParent : UITableView { Debug.Assert(rx.Parent.Source != null, "Source is not set"); return(((_RxTableViewSourceBase)rx.Parent.Source).ItemSelected); }
/// <summary> /// Binding for <c>Title</c> property on <c>UIButton</c> /// </summary> /// <param name="rx"></param> /// <example> /// <code> /// button.Rx().Tap() /// .Subscribe(b => Console.WriteLine("Button tapped") /// .DisposedBy(disposable); /// </code> /// </example> /// <returns></returns> public static ControlEvent <UIButton> Tap(this Reactive <UIButton> rx) => rx.ControlEvent(UIControlEvent.TouchUpInside);
public static IObserver <IEnumerable <TElement> > Items <TParent, TElement, TCell>(this Reactive <TParent> rx, string cellIdentifier, Action <int, TElement, TCell> cellInitializer) where TParent : UITableView where TCell : UITableViewCell { Debug.Assert(rx.Parent.Source == null, "Source is already set"); _RxTableViewIdentifierSource <TElement, TCell> source = new _RxTableViewIdentifierSource <TElement, TCell>(cellIdentifier, new List <TElement>(), cellInitializer); return(Observer.Create <IEnumerable <TElement> >(nextElements => { source.Elements = new List <IGrouping <Unit, TElement> > { new SimpleList <TElement>(nextElements) }; if (rx.Parent.Source == null) { rx.Parent.Source = source; } rx.Parent.ReloadData(); })); }
/// <summary> /// Binding for <c>AttibutedText</c> property on <c>UILabel</c>. /// <example> /// <code> /// Observable.Return("my text") /// .Select(text => new NSAttibutedText(new NSString(text))) /// .BindTo(label.Rx().Text()) /// .DisposedBy(disposable); /// </code> /// </example> /// </summary> /// <param name="rx"></param> /// <returns>BindingObserver for text property on UILabel.</returns> /// <seealso cref="AttributedText"/>> public static UIBindingObserver <UILabel, NSAttributedString> AttributedText(this Reactive <UILabel> rx) => new UIBindingObserver <UILabel, NSAttributedString>(rx.Parent, (label, s) => label.AttributedText = s);
/// <summary> /// Binding for <c>Title</c> property on <c>UIButton</c> /// </summary> /// <typeparam name="T">T is UIButton</typeparam> /// <param name="rx"></param> /// <param name="state">The <c>UIControlState</c> for the <c>Title</c></param> /// <example> /// <code> /// Observable.Return("press me") /// .BindTo(button.Rx().Title(UIControlState.Normal)) /// .DisposedBy(disposable); /// </code> /// </example> /// <returns></returns> public static UIBindingObserver <T, string> Title <T>(this Reactive <T> rx, UIControlState state) where T : UIButton => new UIBindingObserver <T, string>(rx.Parent, (button, s) => button.SetTitle(s, state));
/// <summary> /// ControlProperty for <c>UISegmentedControl.SelectedSegment</c>. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rx"></param> /// <returns></returns> /// <example> /// <code> /// Observable.Return(0) /// .BindTo(segmentedControl.Rx().SelectedSegment()) /// .DisposedBy(disposable); /// </code> /// </example> /// <example> /// <code> /// segmentedControl.Rx().SelectedSegment() /// .Subscribe(i => Console.WriteLine(i.ToString)) /// .DisposedBy(disposable); /// </code> /// </example> /// <returns></returns> public static ControlProperty <nint> SelectedSegment <T>(this Reactive <T> rx) where T : UISegmentedControl => rx.SegValue();
/// <summary> /// Same as <c>SelectedSegment</c> /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rx"></param> /// <returns></returns> /// <seealso cref="SelectedSegment{T}"/> public static ControlProperty <nint> SegValue <T>(this Reactive <T> rx) where T : UISegmentedControl => RxUIControl.Value(rx.Parent, seg => seg.SelectedSegment, (seg, segIndex) => seg.SelectedSegment = segIndex);
/// Binding for <c>Title</c> property on <c>UIViewController</c> /// </summary> /// <typeparam name="T">T is UIButton</typeparam> /// <param name="rx"></param> /// <example> /// <code> /// Observable.Return("Title") /// .BindTo(viewController.Rx().Title()) /// .DisposedBy(disposable); /// </code> /// </example> /// <returns></returns> public static UIBindingObserver <T, string> Title <T>(this Reactive <T> rx) where T : UIViewController => new UIBindingObserver <T, string>(rx.Parent, (vc, s) => vc.Title = s);
/// <summary> /// Binding for UIAlertAction.AlertActionEnabled /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rx"></param> /// <returns></returns> public static UIBindingObserver <T, bool> AlertActionEnabled <T>(this Reactive <T> rx) where T : UIAlertAction => new UIBindingObserver <T, bool>(rx.Parent, (aa, b) => aa.Enabled = b);
/// <summary> /// Binding for <c>Text</c> property on <c>UILabel</c>. /// <example> /// <code> /// Observable.Return("my text").BindTo(label.Rx().Text()).DisposedBy(disposable); /// </code> /// </example> /// </summary> /// <param name="rx"></param> /// <returns>BindingObserver for text property on UILabel.</returns> /// <seealso cref="AttributedText"/>> public static UIBindingObserver <UILabel, string> Text(this Reactive <UILabel> rx) => new UIBindingObserver <UILabel, string>(rx.Parent, (label, s) => label.Text = s);
/// <summary> /// ControlEvent for UIRefreshControl -> ValueChanged /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rx"></param> /// <returns></returns> /// <example> /// <code> /// refreshControl.Rx().Refresh() /// .Subscribe(r => Console.WriteLine("refresh control changed")) /// .DisposedBy(disposable); /// </code> /// </example> public static ControlEvent <T> Refresh <T>(this Reactive <T> rx) where T : UIRefreshControl => rx.ControlEvent(UIControlEvent.ValueChanged);
/// <summary> /// Binding observer for <c>view.Alpha</c> /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rx"></param> /// <returns></returns> /// <example> /// <code> /// Observable.Return(0.5).BindTo(view.Rx().Alpha()).DisposedBy(disposable); /// </code> /// </example> public static UIBindingObserver <T, float> Alpha <T>(this Reactive <T> rx) where T : UIView => new UIBindingObserver <T, float>(rx.Parent, (view, f) => view.Alpha = f);
/// <summary> /// Binding observer for <c>view.Hidden</c> /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rx"></param> /// <returns></returns> /// <example> /// <code> /// Observable.Return(false).BindTo(view.Rx().Hidden()).DisposedBy(disposable); /// </code> /// </example> public static UIBindingObserver <T, bool> Hidden <T>(this Reactive <T> rx) where T : UIView => new UIBindingObserver <T, bool>(rx.Parent, (view, b) => view.Hidden = b);
/// <summary> /// Binding observer for <c>application.NetworkActivityIndicatorVisible</c>> /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rx"></param> /// <returns></returns> public static UIBindingObserver <T, bool> NetworkActivityIndicatorVisible <T>(this Reactive <T> rx) where T : UIApplication => new UIBindingObserver <T, bool>(rx.Parent, (application, b) => application.NetworkActivityIndicatorVisible = b);
/// <summary> /// Control property for the <c>Text</c> on the UITextField. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rx"></param> /// <example> /// <code> /// Observable.Return("") /// .BindTo(textField.Rx().Text()) /// .DisposedBy(disposable); /// </code> /// </example> /// <example> /// <code> /// textField.Rx().Text() /// .Subscribe(Console.WriteLine) /// .DisposedBy(disposable); /// </code> /// </example> /// <returns></returns> public static ControlProperty <string> Text <T>(this Reactive <T> rx) where T : UITextField => rx.Value();
/// <summary> /// Observers a <c>bool</c> that sets the UIControl to <c>Selected</c> /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rx"></param> /// <param name="controlEvent"></param> public static UIBindingObserver <T, bool> Selected <T>(this Reactive <T> rx) where T : UIControl => new UIBindingObserver <T, bool>(rx.Parent, (control, b) => control.Selected = b);