Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 /// <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);
Exemplo n.º 3
0
        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();
            }));
        }
Exemplo n.º 4
0
 /// <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);
Exemplo n.º 5
0
 /// <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));
Exemplo n.º 6
0
 /// <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();
Exemplo n.º 7
0
 /// <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);
Exemplo n.º 8
0
 /// 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);
Exemplo n.º 9
0
 /// <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);
Exemplo n.º 10
0
 /// <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);
Exemplo n.º 11
0
 /// <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);
Exemplo n.º 12
0
        /// <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);
Exemplo n.º 13
0
 /// <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);
Exemplo n.º 14
0
 /// <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);
Exemplo n.º 15
0
 /// <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();
Exemplo n.º 16
0
 /// <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);