public static Binder <TSource, UISegmentedControl> Titles <TSource, TPropertyType>(this Binder <TSource, UISegmentedControl> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string[]> converter = null) where TSource : class { return(binder.Property(property, b => { var list = new string[b.NumberOfSegments]; for (int i = 0; i < b.NumberOfSegments; i++) { list[i] = b.TitleAt(i); } return list; }, (b, v) => { if (v == null) { b.RemoveAllSegments(); } else if (b.NumberOfSegments != v.Length) { b.RemoveAllSegments(); for (int i = 0; i < v.Length; i++) { b.InsertSegment(v[i], i, false); } } else { for (int i = 0; i < v.Length; i++) { b.SetTitle(v[i], i); } } }, converter)); }
public static Binder <TSource, SeekBar> Progress <TSource, TPropertyType>(this Binder <TSource, SeekBar> binder, Expression <Func <TSource, TPropertyType> > property, ITwoWayConverter <TPropertyType, float> converter = null) where TSource : class { converter = converter ?? Transmute.Transmuter.Default.GetTwoWayConverter <TPropertyType, float>(); var finalconverter = converter.Chain(PercentToAmountConverter); return(binder.Property <TPropertyType, int, SeekBar.ProgressChangedEventArgs>(property, b => b.Progress, nameof(SeekBar.ProgressChanged), finalconverter)); }
public static Binder <TSource, UISegmentedControl> Selected <TSource, TPropertyType>(this Binder <TSource, UISegmentedControl> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, int> converter = null) where TSource : class { converter = converter ?? Converters.Default <TPropertyType, int>(); var finalConverter = converter.Chain(Converters.Default <int, nint>()); return(binder.Property <TPropertyType, nint, EventArgs>(property, b => b.SelectedSegment, nameof(UISegmentedControl.ValueChanged), finalConverter)); }
public static Binder <TSource, UIButton> Title <TSource, TPropertyType>(this Binder <TSource, UIButton> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null) where TSource : class { Action <UIButton, string> setter = (b, v) => b.SetTitle(v, UIControlState.Normal); Func <UIButton, string> getter = (b) => b.Title(UIControlState.Normal); return(binder.Property(property, getter, setter, converter)); }
public static Binder <TSource, WKWebView> HtmlContent <TSource, TPropertyType>(this Binder <TSource, WKWebView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null) where TSource : class { Action <WKWebView, string> setter = (b, v) => b.LoadHtmlString(v, null); Func <WKWebView, string> getter = (b) => { throw new InvalidOperationException("No synchronous way to get HTML from WKWebView"); }; // FIXME add two way async bindings return(binder.Property(property, getter, setter, converter)); }
public static Binder <TSource, UIWebView> HtmlContent <TSource, TPropertyType>(this Binder <TSource, UIWebView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null) where TSource : class { Action <UIWebView, string> setter = (b, v) => b.LoadHtmlString(v, null); Func <UIWebView, string> getter = (b) => b.EvaluateJavascript("document.documentElement.outerHTML"); return(binder.Property(property, getter, setter, converter)); }
public static Binder <TSource, UIButton> Image <TSource, TPropertyType>(this Binder <TSource, UIButton> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, UIImage> converter = null) where TSource : class { Action <UIButton, UIImage> setter = (b, v) => b.SetImage(v, UIControlState.Normal); Func <UIButton, UIImage> getter = (b) => b.CurrentImage; return(binder.Property(property, getter, setter, converter)); }
public static Binder <TSource, UISegmentedControl> Selected <TSource, TPropertyType>(this Binder <TSource, UISegmentedControl> binder, Expression <Func <TSource, TPropertyType> > property, ITwoWayConverter <TPropertyType, int> converter = null) where TSource : class { if (converter == null) { converter = Transmuter.Default.GetTwoWayConverter <TPropertyType, int>(); } var nconverter = converter.Chain(Transmuter.Default.GetTwoWayConverter <int, nint>()); return(binder.Property <TPropertyType, nint, EventArgs>(property, b => b.SelectedSegment, nameof(UISegmentedControl.ValueChanged), nconverter)); }
public static Binder <TSource, UIActivityIndicatorView> IsAnimating <TSource, TPropertyType>(this Binder <TSource, UIActivityIndicatorView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, bool> converter = null) where TSource : class { return(binder.Property(property, b => b.IsAnimating, (b, v) => { if (v) { b.StartAnimating(); } else { b.StopAnimating(); } }, converter)); }
public static Binder <TSource, TView> Visibility <TSource, TView, TPropertyType>(this Binder <TSource, TView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, ViewStates> converter = null) where TSource : class where TView : View { return(binder.Property(property, b => b.Visibility, converter)); }
public static Binder <TSource, ToggleButton> Checked <TSource, TPropertyType>(this Binder <TSource, ToggleButton> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, bool> converter = null) where TSource : class { return(binder.Property <TPropertyType, bool, CompoundButton.CheckedChangeEventArgs>(property, b => b.Checked, nameof(ToggleButton.CheckedChange), converter)); }
public static Binder <TSource, TView> UserInteractionEnabled <TSource, TView, TPropertyType>(this Binder <TSource, TView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, bool> converter = null) where TSource : class where TView : UIView { return(binder.Property(property, b => b.UserInteractionEnabled, converter)); }
public static Binder <TSource, ImageView> Image <TSource, TPropertyType>(this Binder <TSource, ImageView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, Bitmap> converter = null) where TSource : class { return(binder.Property(property, b => ((BitmapDrawable)b.Drawable).Bitmap, (b, v) => b.SetImageBitmap(v), converter)); }
public static Binder <TSource, TView> Frame <TSource, TView, TPropertyType>(this Binder <TSource, TView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, CGRect> converter = null) where TSource : class where TView : UIView { return(binder.Property(property, b => b.Frame, converter)); }
public static Binder <TSource, UIImageView> Image <TSource, TPropertyType>(this Binder <TSource, UIImageView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, UIImage> converter = null) where TSource : class { return(binder.Property(property, b => b.Image, converter)); }
public static Binder <TSource, UIStepper> MinimumValue <TSource, TPropertyType>(this Binder <TSource, UIStepper> binder, Expression <Func <TSource, TPropertyType> > property, TwoWayConverter <TPropertyType, double> converter = null) where TSource : class { return(binder.Property <TPropertyType, double, EventArgs>(property, b => b.MinimumValue, nameof(UIStepper.ValueChanged), converter)); }
public static Binder <TSource, EditText> Text <TSource, TPropertyType>(this Binder <TSource, EditText> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null) where TSource : class { return(binder.Property <TPropertyType, string, TextChangedEventArgs>(property, b => b.Text, nameof(EditText.TextChanged), converter)); }
public static Binder <TSource, TView> Background <TSource, TView, TPropertyType>(this Binder <TSource, TView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, Drawable> converter = null) where TSource : class where TView : View { return(binder.Property(property, b => b.Background, converter)); }
public static Binder <TSource, TView> Alpha <TSource, TView, TPropertyType>(this Binder <TSource, TView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, float> converter = null) where TSource : class where TView : View { return(binder.Property(property, b => b.Alpha, converter)); }
public static Binder <TSource, UIProgressView> TrackTintColor <TSource, TPropertyType>(this Binder <TSource, UIProgressView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, UIColor> converter = null) where TSource : class { return(binder.Property(property, b => b.TrackTintColor, converter)); }
public static Binder <TSource, ProgressBar> Progress <TSource, TPropertyType>(this Binder <TSource, ProgressBar> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, int> converter = null) where TSource : class { return(binder.Property(property, b => b.Progress, converter)); }
public static IBinding Text <TSource, TPropertyType>(this Binder <TSource, TextView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null) where TSource : class { return(binder.Property(property, b => b.Text, converter)); }
public static Binder <TSource, UISwitch> On <TSource, TPropertyType>(this Binder <TSource, UISwitch> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, bool> converter = null) where TSource : class { return(binder.Property <TPropertyType, bool, EventArgs>(property, b => b.On, nameof(UISwitch.ValueChanged), converter)); }
public static Binder <TSource, UIActivityIndicatorView> Color <TSource, TPropertyType>(this Binder <TSource, UIActivityIndicatorView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, UIColor> converter = null) where TSource : class { return(binder.Property(property, b => b.Color, converter)); }
public static Binder <TSource, UIDatePicker> Date <TSource, TPropertyType>(this Binder <TSource, UIDatePicker> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, NSDate> converter = null) where TSource : class { return(binder.Property <TPropertyType, NSDate, EventArgs>(property, v => v.Date, nameof(UISlider.ValueChanged), converter)); }
public static Binder <TSource, UIViewController> Title <TSource, TPropertyType>(this Binder <TSource, UIViewController> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null) where TSource : class { return(binder.Property(property, b => b.Title, converter)); }
public static Binder <TSource, Button> Text <TSource, TPropertyType>(this Binder <TSource, Button> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null) where TSource : class { return(binder.Property(property, x => x.Text, converter)); }
public static Binder <TSource, UIViewController> BackTitle <TSource, TPropertyType>(this Binder <TSource, UIViewController> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null) where TSource : class { return(binder.Property(property, b => b.NavigationItem.BackBarButtonItem.Title, (b, v) => new UIBarButtonItem(v, UIBarButtonItemStyle.Plain, null), converter)); }
public static Binder <TSource, UITextView> Text <TSource, TPropertyType>(this Binder <TSource, UITextView> binder, Expression <Func <TSource, TPropertyType> > property, ITwoWayConverter <TPropertyType, string> converter = null) where TSource : class { return(binder.Property <TPropertyType, string, EventArgs> (property, b => b.Text, nameof(UITextView.Changed), converter)); }
public static Binder <TSource, TView> Hidden <TSource, TView, TPropertyType>(this Binder <TSource, TView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, bool> converter = null) where TSource : class where TView : UIView { return(binder.Property(property, b => b.Hidden, converter)); }