Exemple #1
0
 private void CreateEngine()
 {
     _scheduler   = new LogicalScheduler(_physicalScheduler);
     _queryEngine = new CheckpointingQueryEngine(new Uri(QeId), _resolver, _scheduler, _context, _keyValueStore, SerializationPolicy.Default, s_map, null);
     _queryEngine.Options.TemplatizeExpressions = _templatize;
     EngineContext = _queryEngine.ReactiveService;
 }
Exemple #2
0
        protected ChangedCalled EnsureChangedCalled(IReactive reactive)
        {
            var changedCalled = new ChangedCalled();

            reactive.Changed += () => changedCalled.Increment();

            return(changedCalled);
        }
Exemple #3
0
 public View(
     IWinFormsComponentsInitializer winFormsComponentsInitializer,
     IReactive reactiveImpl
     )
 {
     this.winFormsComponentsInitializer = winFormsComponentsInitializer;
     this.reactiveImpl = reactiveImpl;
 }
Exemple #4
0
 public static IDisposable BindAction <T>(this IReactive <UIView> reactive, OutputAction <T> action)
 {
     return(Observable.Using(
                () => action.Enabled.Subscribe(e => { reactive.Base.UserInteractionEnabled = e; }),
                _ => reactive.Base.Rx().Tap()
                )
            .Subscribe(action.Inputs));
 }
Exemple #5
0
 public static Action <UIColor> AnimatedBackgroundColor(this IReactive <UIView> reactive) =>
 color =>
 {
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.SharpCurve,
         () => reactive.Base.BackgroundColor = color
         );
 };
Exemple #6
0
 public static Action <float> AnimatedAlpha(this IReactive <UIView> reactive)
 => alpha =>
 {
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.SharpCurve,
         () => reactive.Base.Alpha = alpha
         );
 };
 public static IObserver <IEnumerable <TModel> > ReloadItems <THeader, TModel>(
     this IReactive <UITableView> reactive, BaseTableViewSource <THeader, TModel> dataSource)
 {
     return(Observer.Create <IEnumerable <TModel> >(list =>
     {
         dataSource.SetItems(list);
         reactive.Base.ReloadData();
     }));
 }
 public static Action <Color> DrawableColor(this IReactive <View> reactive)
 => color =>
 {
     if (reactive.Base.Background is GradientDrawable drawable)
     {
         drawable.SetColor(color.ToArgb());
         drawable.InvalidateSelf();
     }
 };
Exemple #9
0
 public static Action <nfloat> ConstantAnimated(this IReactive <NSLayoutConstraint> reactive)
 => constant =>
 {
     reactive.Base.Constant = constant;
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.SharpCurve,
         () => ((UIView)reactive.Base.FirstItem).Superview.LayoutIfNeeded());
 };
        public static IObserver <IEnumerable <TSection> > AnimateSections <TSection, THeader, TModel, TKey>(
            this IReactive <UITableView> reactive,
            BaseTableViewSource <TSection, THeader, TModel> dataSource)
            where TKey : IEquatable <TKey>
            where TSection : IAnimatableSectionModel <THeader, TModel, TKey>, new()
            where TModel : IDiffable <TKey>, IEquatable <TModel>
            where THeader : IDiffable <TKey>
        {
            return(Observer.Create <IEnumerable <TSection> >(finalSections =>
            {
                var initialSections = dataSource.Sections;
                if (initialSections == null || initialSections.Count == 0)
                {
                    dataSource.SetSections(finalSections);
                    reactive.Base.ReloadData();
                    return;
                }

                // if view is not in view hierarchy, performing batch updates will crash the app
                if (reactive.Base.Window == null)
                {
                    dataSource.SetSections(finalSections);
                    reactive.Base.ReloadData();
                    return;
                }

                var stopwatchProvider = Mvx.Resolve <IStopwatchProvider>();
                var stopwatch = stopwatchProvider.Create(MeasuredOperation.Diffing);
                stopwatch.Start();

                var diff = new Diffing <TSection, THeader, TModel, TKey>(initialSections, finalSections);
                var changeset = diff.ComputeDifferences();

                stopwatch.Stop();

                // The changesets have to be applied one after another. Not in one transaction.
                // iOS is picky about the changes which can happen in a single transaction.
                // Don't put BeginUpdates() ... EndUpdates() around the foreach, it has to stay this way,
                // otherwise the app might crash from time to time.

                foreach (var difference in changeset)
                {
                    reactive.Base.BeginUpdates();
                    dataSource.SetSections(difference.FinalSections);
                    reactive.Base.performChangesetUpdates(difference);
                    reactive.Base.EndUpdates();

                    foreach (var section in difference.UpdatedSections)
                    {
                        if (reactive.Base.GetHeaderView(section) is BaseTableHeaderFooterView <THeader> headerView)
                        {
                            headerView.Item = difference.FinalSections[section].Header;
                        }
                    }
                }
            }));
        }
Exemple #11
0
        public static IObservable <Unit> LongPress(this IReactive <UIView> reactive)
        => Observable.Create <Unit>(observer =>
        {
            var gestureRecognizer = new UILongPressGestureRecognizer(() => observer.OnNext(Unit.Default));
            gestureRecognizer.ShouldRecognizeSimultaneously = (recognizer, otherRecognizer) => true;
            reactive.Base.AddGestureRecognizer(gestureRecognizer);

            return(Disposable.Create(() => reactive.Base.RemoveGestureRecognizer(gestureRecognizer)));
        });
 public static IObserver <IImmutableList <TModel> > ReloadItems <TSection, THeader, TModel>(
     this IReactive <UITableView> reactive, BaseTableViewSource <TSection, THeader, TModel> dataSource)
     where TSection : SectionModel <THeader, TModel>, new()
 {
     return(Observer.Create <IImmutableList <TModel> >(list =>
     {
         dataSource.SetItems(list);
         reactive.Base.ReloadData();
     }));
 }
 public static IReactiveQbservable <long> Timer(this IReactive context, TimeSpan dueTime)
 {
     return(context.Provider.CreateQbservable <long>(
                Expression.Call(
                    (MethodInfo)MethodInfo.GetCurrentMethod(),
                    Expression.Constant(context, typeof(IReactive)),
                    Expression.Constant(dueTime, typeof(TimeSpan))
                    )
                ));
 }
 public static IObserver <IEnumerable <TSection> > ReloadSections <TSection, THeader, TModel>(
     this IReactive <UITableView> reactive, BaseTableViewSource <TSection, THeader, TModel> dataSource)
     where TSection : ISectionModel <THeader, TModel>, new()
 {
     return(Observer.Create <IEnumerable <TSection> >(list =>
     {
         dataSource.SetSections(list);
         reactive.Base.ReloadData();
     }));
 }
Exemple #15
0
 public Application(
     IModel model,
     UI.Presenters.IPresentation presentation,
     IReactive reactive
     )
 {
     this.Model        = model;
     this.Presentation = presentation;
     this.reactive     = reactive;
 }
 public static Action <bool> CheckedObserver(this IReactive <UISwitch> reactive)
 {
     return(isChecked =>
     {
         if (reactive.Base.On != isChecked)
         {
             reactive.Base.SetState(isChecked, false);
         }
     });
 }
Exemple #17
0
        public static Action <int> MarginTop(this IReactive <ViewGroup.LayoutParams> reactive)
        => margin =>
        {
            var marginParams = reactive.Base as ViewGroup.MarginLayoutParams;
            if (marginParams == null)
            {
                return;
            }

            marginParams.TopMargin = margin;
        };
        public static void BindToAction <TInput, TOutput>(this IReactive <UIButton> reactive, RxAction <TInput, TOutput> action, Func <UIButton, TInput> transform)
        {
            reactive.Tap()
            .Select(_ => transform(reactive.Base))
            .Subscribe(action.Inputs)
            .DisposedBy(action.DisposeBag);

            action.Enabled
            .Subscribe(e => { reactive.Base.Enabled = e; })
            .DisposedBy(action.DisposeBag);
        }
 public static IObserver <IImmutableList <TSection> > ReloadSections <TSection, THeader, TModel>(
     this IReactive <UITableView> reactive, BaseTableViewSource <TSection, THeader, TModel> dataSource)
     where TSection : ISectionModel <THeader, TModel>, new()
 {
     return(Observer.Create <IImmutableList <TSection> >(list =>
     {
         dataSource.SetSections(list);
         reactive.Base.ReloadData();
         dataSource.OnItemsChanged?.Invoke(dataSource, new EventArgs());
     }));
 }
Exemple #20
0
 public static IDisposable BindAction <TInput, TOutput>(
     this IReactive <UIView> reactive,
     RxAction <TInput, TOutput> action,
     Func <TInput> transformationFunction)
 {
     return(Observable.Using(
                () => action.Enabled.Subscribe(e => { reactive.Base.UserInteractionEnabled = e; }),
                _ => reactive.Base.Rx().Tap().Select(unit => transformationFunction())
                )
            .Subscribe(action.Inputs));
 }
 public static Action <string> AnimatedTitle(this IReactive <UIButton> reactive)
 => title =>
 {
     UIView.Transition(
         reactive.Base,
         Animation.Timings.EnterTiming,
         UIViewAnimationOptions.TransitionCrossDissolve,
         () => reactive.Base.SetTitle(title, UIControlState.Normal),
         null
         );
 };
Exemple #22
0
 public static Action <bool> IsAnimating(this IReactive <UIActivityIndicatorView> reactive)
 => isVisible =>
 {
     if (isVisible)
     {
         reactive.Base.StartAnimating();
     }
     else
     {
         reactive.Base.StopAnimating();
     }
 };
        public static IDisposable BindAction <TInput, TElement>(this IReactive <UISwitch> reactive,
                                                                RxAction <TInput, TElement> action, Func <UISwitch, TInput> inputTransform)
        {
            IObservable <Unit> eventObservable = reactive.Base.Rx().Changed();

            return(Observable.Using(
                       () => action.Enabled.Subscribe(e => { reactive.Base.Enabled = e; }),
                       _ => eventObservable
                       )
                   .Select(_ => inputTransform(reactive.Base))
                   .Subscribe(action.Inputs));
        }
Exemple #24
0
 public static Action <bool> IsVisibleWithFade(this IReactive <UIView> reactive)
 => isVisible =>
 {
     var alpha = isVisible ? 1 : 0;
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.EaseIn,
         () =>
     {
         reactive.Base.Alpha = alpha;
     });
 };
        public static IObservable <int> CursorPosition(this IReactive <UITextView> reactive)
        => Observable.Create <int>(observer =>
        {
            var selectedTextRangeDisposable = reactive.Base.AddObserver(
                selectedTextRangeChangedKey,
                NSKeyValueObservingOptions.OldNew,
                _ => observer.OnNext((int)reactive.Base.SelectedRange.Location)
                );

            return(selectedTextRangeDisposable);
        })
        .StartWith((int)reactive.Base.SelectedRange.Location);
Exemple #26
0
        public static Action <bool> AnimatedIsVisible(this IReactive <UIView> reactive)
        => isVisible =>
        {
            reactive.Base.Transform = CGAffineTransform.MakeTranslation(0, 20);

            AnimationExtensions.Animate(
                Animation.Timings.EnterTiming,
                Animation.Curves.SharpCurve,
                () =>
            {
                reactive.Base.Hidden    = !isVisible;
                reactive.Base.Transform = CGAffineTransform.MakeTranslation(0, 0);
            }
                );
        };
Exemple #27
0
        public static IObservable <Unit> Tap(this IReactive <UIView> reactive)
        => Observable.Create <Unit>(observer =>
        {
            var gestureRecognizer = new UITapGestureRecognizer(() => observer.OnNext(Unit.Default));
            gestureRecognizer.ShouldRecognizeSimultaneously = (recognizer, otherRecognizer) => true;
            reactive.Base.AddGestureRecognizer(gestureRecognizer);

            return(Disposable.Create(() =>
            {
                UIApplication.SharedApplication.InvokeOnMainThread(() =>
                {
                    reactive.Base.RemoveGestureRecognizer(gestureRecognizer);
                });
            }));
        });
        public static IObservable <Unit> Tap(this IReactive <UIView> reactive)
        => Observable.Create <Unit>(observer =>
        {
            var gestureRecognizer = new UITapGestureRecognizer(() => observer.OnNext(Unit.Default));
            gestureRecognizer.ShouldRecognizeSimultaneously = (recognizer, otherRecognizer) => true;
            reactive.Base.AddGestureRecognizer(gestureRecognizer);

            return(Disposable.Create(() =>
            {
                DispatchQueue.MainQueue.DispatchAsync(() =>
                {
                    reactive.Base.RemoveGestureRecognizer(gestureRecognizer);
                });
            }));
        });
Exemple #29
0
        public static Action <string> TextObserver(this IReactive <TextView> reactive, bool ignoreUnchanged = false)
        {
            return(text =>
            {
                if (!ignoreUnchanged)
                {
                    reactive.Base.Text = text;
                    return;
                }

                if (reactive.Base.Text != text)
                {
                    reactive.Base.Text = text;
                }
            });
        }
        public static Action <bool> CheckedObserver(this IReactive <Switch> reactive, bool ignoreUnchanged = false)
        {
            return(isChecked =>
            {
                if (!ignoreUnchanged)
                {
                    reactive.Base.Checked = isChecked;
                    return;
                }

                if (reactive.Base.Checked != isChecked)
                {
                    reactive.Base.Checked = isChecked;
                }
            });
        }