Beispiel #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            EmptyView = new Lazy <UIView>(() =>
                                          new EmptyListView(Octicon.Pulse.ToEmptyListImage(), "There are no repositories."));

            var titleButton = new TrendingTitleButton
            {
                Frame     = new CGRect(0, 0, 200f, 32f),
                TintColor = Theme.PrimaryNavigationBarTextColor
            };

            NavigationItem.TitleView   = titleButton;
            titleButton.TouchUpInside += (sender, e) => ViewModel.GoToLanguages.ExecuteIfCan();
            this.WhenAnyValue(x => x.ViewModel.SelectedLanguage).IsNotNull()
            .Subscribe(x => titleButton.Text = x.Name);

            var source = new RepositoryTableViewSource(TableView);

            TableView.Source = source;

            this.WhenAnyValue(x => x.ViewModel.Repositories)
            .Select(x => x ?? new List <GroupedCollection <RepositoryItemViewModel> >())
            .Select(x => x.Select(g => new TableSectionInformation <RepositoryItemViewModel, RepositoryCellView>(g.Items, RepositoryCellView.Key, (float)UITableView.AutomaticDimension)
            {
                Header = new TableSectionHeader(() => CreateHeaderView(g.Name), 26f)
            }))
            .Subscribe(x => source.Data = x.ToList());
        }
Beispiel #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var titleButton = new TrendingTitleButton {
                Frame = new RectangleF(0, 0, 200f, 32f)
            };

            titleButton.TouchUpInside += (sender, e) => ViewModel.GoToLanguages.ExecuteIfCan();
            ViewModel.WhenAnyValue(x => x.SelectedLanguage).Subscribe(x => titleButton.Text = x.Name);
            NavigationItem.TitleView = titleButton;

            var source = new RepositoryTableViewSource(TableView);

            TableView.Source = source;

            ViewModel.WhenAnyValue(x => x.Repositories)
            .Where(x => x != null)
            .Subscribe(x =>
            {
                source.Data = x.Select(g =>
                {
                    var t    = new TableSectionInformation <RepositoryItemViewModel, RepositoryCellView>(g.Items, RepositoryCellView.Key, 64f);
                    t.Header = new TableSectionHeader(() => CreateHeaderView(g.Name), 26f);
                    return(t);
                }).ToList();
            });
        }
Beispiel #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var source = new RepositoryTableViewSource(TableView);

            TableView.Source = source;

            this.WhenAnyValue(x => x.ViewModel.Repositories)
            .Select(x => x ?? new List <GroupedCollection <RepositoryItemViewModel> >())
            .Select(x => x.Select(g => new TableSectionInformation <RepositoryItemViewModel, RepositoryCellView>(g.Items, RepositoryCellView.Key, 64f)
            {
                Header = new TableSectionHeader(() => CreateHeaderView(g.Name), 26f)
            }))
            .Subscribe(x => source.Data = x.ToList());
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var tableViewSource = new RepositoryTableViewSource(TableView);

            TableView.Source = tableViewSource;

            Appearing
            .Take(1)
            .Select(_ => Unit.Default)
            .InvokeCommand(ViewModel.LoadCommand);

            this.WhenActivated(d =>
            {
                d(ViewModel.LoadCommand.IsExecuting
                  .Subscribe(Loading));

                d(_trendingTitleButton.GetClickedObservable()
                  .Subscribe(_ => ShowLanguages()));

                d(ViewModel.WhenAnyValue(x => x.SelectedLanguage)
                  .Subscribe(x => _trendingTitleButton.Text = x.Name));

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

                d(ViewModel.WhenAnyValue(x => x.Items).Subscribe(items =>
                {
                    var sections = items.Select(item =>
                    {
                        var tsi = new TableSectionInformation <RepositoryItemViewModel, RepositoryCellView>(
                            new ReactiveList <RepositoryItemViewModel>(item.Item2),
                            RepositoryCellView.Key,
                            (float)UITableView.AutomaticDimension);
                        tsi.Header = new TableSectionHeader(() => CreateHeaderView(item.Item1), 26f);
                        return(tsi);
                    });

                    tableViewSource.Data = sections.ToList();
                }));
            });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

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

            TableView.Source = tableViewSource;

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

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

                d(ViewModel.RepositoryItemSelected
                  .Select(x => new RepositoryViewController(x.Owner, x.Name))
                  .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));
            });
        }
Beispiel #6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            EmptyView = new Lazy <UIView>(() =>
                                          new EmptyListView(Octicon.Pulse.ToEmptyListImage(), "There are no repositories."));

            NavigationItem.TitleView = _trendingTitleButton;
            this.WhenAnyValue(x => x.ViewModel.SelectedLanguage).IsNotNull()
            .Subscribe(x => _trendingTitleButton.Text = x.Name);

            var source = new RepositoryTableViewSource(TableView);

            TableView.Source = source;

            this.WhenAnyValue(x => x.ViewModel.Repositories)
            .Select(x => x ?? new List <GroupedCollection <RepositoryItemViewModel> >())
            .Select(x => x.Select(g => new TableSectionInformation <RepositoryItemViewModel, RepositoryCellView>(g.Items, RepositoryCellView.Key, (float)UITableView.AutomaticDimension)
            {
                Header = new TableSectionHeader(() => CreateHeaderView(g.Name), 26f)
            }))
            .Subscribe(x => source.Data = x.ToList());
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var titleButton = new TrendingTitleButton
            {
                Frame     = new RectangleF(0, 0, 200f, 32f),
                TintColor = _themeService.CurrentTheme.NavigationBarTextColor
            };

            titleButton.TouchUpInside += (sender, e) => ViewModel.GoToLanguages.ExecuteIfCan();
            NavigationItem.TitleView   = titleButton;

            var source = new RepositoryTableViewSource(TableView);

            TableView.Source = source;

            this.WhenViewModel(x => x.Repositories)
            .Subscribe(x =>
            {
                if (x == null)
                {
                    source.Data = new List <TableSectionInformation <RepositoryItemViewModel, RepositoryCellView> >();
                }
                else
                {
                    source.Data = x.Select(g => new TableSectionInformation <RepositoryItemViewModel, RepositoryCellView>(g.Items, RepositoryCellView.Key, 64f)
                    {
                        Header = new TableSectionHeader(() => CreateHeaderView(g.Name), 26f)
                    }).ToList();
                }
            });

            this.WhenViewModel(x => x.SelectedLanguage)
            .Subscribe(x => titleButton.Text = x.Name);
        }