protected override void OnAppearing() { this.WhenActivated(d => { this.WhenAnyValue(v => v.ViewModel.LoadRepositoriesCommand) .Where(x => x != null) .Select(x => Unit.Default) .InvokeCommand(ViewModel.LoadRepositoriesCommand); this.Bind(ViewModel, vm => vm.Search, v => v.SearchBox.Text).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.Repositories, v => v.Repositories.ItemsSource).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.Loading, v => v.GridLoader.IsVisible).DisposeWith(d); this.WhenAnyValue(v => v.ViewModel.Adding) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(visible => { GridAdder.TranslateTo(0, visible ? 0 : 60, 500); }); this.WhenAnyValue(v => v.Repositories.SelectedItem) .ObserveOn(RxApp.MainThreadScheduler) .Where(x => x != null) .Subscribe(selected => { ViewModel.SetCurrent((GitHubRepository)selected) .Subscribe(x => Navigation.PushAsync(new PullRequestView())); }) .DisposeWith(d); Observable.FromEventPattern <EventHandler <ItemVisibilityEventArgs>, ItemVisibilityEventArgs>( x => Repositories.ItemAppearing += x, x => Repositories.ItemAppearing -= x) .Where(x => x != null) .Select(x => x.EventArgs.ItemIndex) .Select(NeedLoad) .Where(x => x) .Select(x => Unit.Default) .InvokeCommand(ViewModel.AddRepositoriesCommand).DisposeWith(d); ViewModel.ExceptionInteraction.RegisterHandler(async interaction => { await DisplayAlert("Error", interaction.Input.Message, "Ok"); interaction.SetOutput(Unit.Default); }); }); base.OnAppearing(); }
protected override void OnAppearing() { this.WhenActivated(d => { this.WhenAnyValue(v => v.ViewModel.LoadCommand) .Where(x => x != null) .Select(x => Unit.Default) .InvokeCommand(ViewModel.LoadCommand); this.OneWayBind(ViewModel, vm => vm.OpenCount, v => v.Open.Text).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.CloseCount, v => v.Closed.Text).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.PullRequests, v => v.PullRequests.ItemsSource).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.Loading, v => v.GridLoader.IsVisible).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.Repository.RepositoryName, v => v.Title, e => $"{e[0].ToString().ToUpper()}{e.Substring(1)}").DisposeWith(d); this.WhenAnyValue(v => v.ViewModel.Adding) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(visible => { GridAdder.TranslateTo(0, visible ? 0 : 60, 500); }); Observable.FromEventPattern <EventHandler <ItemVisibilityEventArgs>, ItemVisibilityEventArgs>( x => PullRequests.ItemAppearing += x, x => PullRequests.ItemAppearing -= x) .Where(x => x != null) .Select(x => x.EventArgs.ItemIndex) .Select(NeedLoad) .Where(x => x) .Select(x => Unit.Default) .InvokeCommand(ViewModel.AddCommand).DisposeWith(d); ViewModel.ExceptionInteraction.RegisterHandler(async interaction => { await DisplayAlert("Error", interaction.Input.Message, "Ok"); interaction.SetOutput(Unit.Default); }); }); base.OnAppearing(); }
protected override void OnAppearing() { this.WhenActivated(d => { this.WhenAnyValue(v => v.ViewModel.LoadCache) .Where(x => x != null) .Select(x => Unit.Default) .InvokeCommand(ViewModel.LoadCache); this.Bind(ViewModel, vm => vm.Search, v => v.SearchBox.Text).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.Repositories, v => v.Repositories.ItemsSource).DisposeWith(d); this.Bind(ViewModel, vm => vm.Selected, v => v.Repositories.SelectedItem); this.OneWayBind(ViewModel, vm => vm.ItemTreshold, v => v.Repositories.RemainingItemsThreshold).DisposeWith(d); this.BindCommand(ViewModel, vm => vm.LoadNext, v => v.Repositories, nameof(Repositories.RemainingItemsThresholdReached)).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.Loading, v => v.GridLoader.IsVisible).DisposeWith(d); this.WhenAnyValue(v => v.ViewModel.Adding) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(visible => { GridAdder.TranslateTo(0, visible ? 0 : 60, 500); }); this.WhenAnyValue(v => v.ViewModel.Selected) .Where(x => x != null) .ObserveOn(RxApp.MainThreadScheduler) .Do(x => ViewModel.Selected = null) .Do(async selected => await Navigation.PushAsync(new PullRequestView())) .Subscribe().DisposeWith(d); ViewModel.ExceptionInteraction.RegisterHandler(async interaction => { await DisplayAlert("Error", interaction.Input.Message, "Ok"); interaction.SetOutput(Unit.Default); }); }); base.OnAppearing(); }
protected override void OnAppearing() { this.WhenActivated(d => { this.WhenAnyValue(v => v.ViewModel.LoadCurrentRepository) .Where(x => x != null) .Select(x => Unit.Default) .InvokeCommand(ViewModel.LoadCurrentRepository); this.OneWayBind(ViewModel, vm => vm.OpenCount, v => v.Open.Text).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.CloseCount, v => v.Closed.Text).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.PullRequests, v => v.PullRequests.ItemsSource).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.ItemTreshold, v => v.PullRequests.RemainingItemsThreshold).DisposeWith(d); this.BindCommand(ViewModel, vm => vm.AddCommand, v => v.PullRequests, nameof(PullRequests.RemainingItemsThresholdReached)).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.Loading, v => v.GridLoader.IsVisible).DisposeWith(d); this.OneWayBind(ViewModel, vm => vm.Repository.Name, v => v.Title, e => $"{e[0].ToString().ToUpper()}{e.Substring(1)}").DisposeWith(d); this.WhenAnyValue(v => v.ViewModel.Adding) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(visible => { GridAdder.TranslateTo(0, visible ? 0 : 60, 500); }); ViewModel.ExceptionInteraction.RegisterHandler(async interaction => { await DisplayAlert("Error", interaction.Input.Message, "Ok"); interaction.SetOutput(Unit.Default); }); }); base.OnAppearing(); }