public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            TableView.TableHeaderView = _repositorySearchBar;
            TableView.Source          = new RepositoryTableViewSource(TableView, ViewModel.Items);

            this.WhenActivated(d =>
            {
                d(_repositorySearchBar.GetChangedObservable()
                  .Subscribe(x => ViewModel.SearchText = x));

                d(_repositorySearchBar.GetSearchObservable()
                  .InvokeReactiveCommand(ViewModel.SearchCommand));

                d(ViewModel.SearchCommand.IsExecuting
                  .Subscribe(Searching));

                d(ViewModel.RepositoryItemSelected
                  .Select(x => new RepositoryViewController(x.Owner, x.Name, x.Repository))
                  .Subscribe(x => NavigationController.PushViewController(x, true)));

                d(ViewModel.SearchCommand.Subscribe(_ => SearchComplete()));
            });
        }
Esempio n. 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var tableViewSource = new FeedbackTableViewSource(TableView, ViewModel.Items);

            TableView.Source = tableViewSource;

            Appearing
            .Take(1)
            .Subscribe(_ => LoadData());

            this.WhenActivated(d =>
            {
                d(this.WhenAnyValue(x => x.ViewModel.Title)
                  .Subscribe(title => Title = title));

                d(_repositorySearchBar.GetChangedObservable()
                  .Subscribe(x => ViewModel.SearchKeyword = x));

                d(ViewModel.WhenAnyValue(x => x.IsEmpty)
                  .Where(x => x.HasValue)
                  .Select(x => x.Value)
                  .Subscribe(SetHasItems));

                d(ViewModel.Items.Changed.Select(_ => Unit.Default)
                  .StartWith(Unit.Default)
                  .Select(_ => ViewModel.Items.Select(x => x.GoToCommand.Select(__ => x)))
                  .Select(x => Observable.Merge(x))
                  .Switch()
                  .Select(x => new IssueView(x.RepositoryOwner, x.RepositoryName, x.IssueId))
                  .Subscribe(x => NavigationController.PushViewController(x, true)));
            });
        }
Esempio n. 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var tableViewSource = new UserTableViewSource(TableView, ViewModel.Items);

            TableView.Source = tableViewSource;

            Appearing
            .Take(1)
            .Select(_ => ViewModel.LoadCommand.Execute())
            .Switch()
            .Take(1)
            .Catch(Observable.Return(false))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(SetItemsPresent);

            this.WhenActivated(d =>
            {
                d(_repositorySearchBar.GetChangedObservable()
                  .Subscribe(x => ViewModel.SearchText = x));

                d(ViewModel.ItemSelected
                  .Select(x => new UserViewController(x.User))
                  .Subscribe(x => NavigationController.PushViewController(x, true)));

                d(ViewModel.WhenAnyValue(x => x.HasMore)
                  .Subscribe(x => TableView.TableFooterView = x ? _loading : null));

                d(tableViewSource.RequestMore
                  .InvokeReactiveCommand(ViewModel.LoadMoreCommand));

                d(ViewModel.LoadCommand
                  .Select(_ => ViewModel.Items.Changed)
                  .Switch()
                  .Select(_ => Unit.Default)
                  .Throttle(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler)
                  .Where(_ => TableView.LastItemVisible())
                  .InvokeReactiveCommand(ViewModel.LoadMoreCommand));

                d(ViewModel.LoadCommand.Merge(ViewModel.LoadMoreCommand)
                  .Select(_ => Unit.Default)
                  .Throttle(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler)
                  .Where(_ => TableView.LastItemVisible())
                  .InvokeReactiveCommand(ViewModel.LoadMoreCommand));
            });
        }