Esempio n. 1
0
        private ReactiveTableViewSource <TeamItemViewModel> CreateSource(IReadOnlyReactiveList <TeamItemViewModel> items)
        {
            var source = new ReactiveTableViewSource <TeamItemViewModel>(TableView, items, TeamCellView.Key, (float)UITableView.AutomaticDimension);

            source.ElementSelected.OfType <TeamItemViewModel>().Subscribe(x => x.GoToCommand.ExecuteIfCan());
            return(source);
        }
Esempio n. 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _viewSegment.ValueChanged += (sender, args) => ViewModel.SelectedFilter = (BranchesAndTagsViewModel.ShowIndex)_viewSegment.SelectedSegment;
            ViewModel.WhenAnyValue(x => x.SelectedFilter).Subscribe(x => _viewSegment.SelectedSegment = (int)x);
            NavigationItem.TitleView = _viewSegment;

            TableView.RegisterClassForCellReuse(typeof(BranchCellView), BranchCellView.Key);
            TableView.RegisterClassForCellReuse(typeof(TagCellView), TagCellView.Key);

            ViewModel.WhenAnyValue(x => x.SelectedFilter)
            .Subscribe(x =>
            {
                if (TableView.Source != null)
                {
                    TableView.Source.Dispose();
                    TableView.Source = null;
                }

                if (x == BranchesAndTagsViewModel.ShowIndex.Branches)
                {
                    var source = new ReactiveTableViewSource <BranchItemViewModel>(TableView, ViewModel.Branches, BranchCellView.Key, 44f);
                    source.ElementSelected.OfType <BranchItemViewModel>().Subscribe(y => y.GoToCommand.ExecuteIfCan());
                    TableView.Source = source;
                }
                else
                {
                    var source = new ReactiveTableViewSource <TagItemViewModel>(TableView, ViewModel.Tags, TagCellView.Key, 44f);
                    source.ElementSelected.OfType <TagItemViewModel>().Subscribe(y => y.GoToCommand.ExecuteIfCan());
                    TableView.Source = source;
                }
            });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavigationItem.TitleView = _viewSegment;

            TableView.RegisterClassForCellReuse(typeof(BranchCellView), BranchCellView.Key);
            TableView.RegisterClassForCellReuse(typeof(TagCellView), TagCellView.Key);

            OnActivation(d => {
                d(_viewSegment.GetChangedObservable().Subscribe(x => ViewModel.SelectedFilter = (BranchesAndTagsViewModel.ShowIndex)x));
                d(this.WhenAnyValue(x => x.ViewModel.SelectedFilter).Subscribe(x => {
                    _viewSegment.SelectedSegment = (int)x;

                    TableView.Source?.Dispose();
                    TableView.Source = null;

                    if (x == BranchesAndTagsViewModel.ShowIndex.Branches)
                    {
                        var source = new ReactiveTableViewSource <BranchItemViewModel>(TableView, ViewModel.Branches, BranchCellView.Key, 44f);
                        source.ElementSelected.OfType <BranchItemViewModel>().Subscribe(y => y.GoToCommand.ExecuteIfCan());
                        TableView.Source = source;
                    }
                    else
                    {
                        var source = new ReactiveTableViewSource <TagItemViewModel>(TableView, ViewModel.Tags, TagCellView.Key, 44f);
                        source.ElementSelected.OfType <TagItemViewModel>().Subscribe(y => y.GoToCommand.ExecuteIfCan());
                        TableView.Source = source;
                    }
                }));
            });
        }
    /// <summary>
    /// <para>Extension method that binds an observable of a list of table
    /// sections as the source of a <see cref="UITableView"/>.</para>
    /// <para>If your <see cref="IReadOnlyList{T}"/> is also an instance of
    /// <see cref="INotifyCollectionChanged"/>, then this method
    /// will silently update the bindings whenever it changes as well.
    /// Otherwise, it will just log a message.</para>
    /// </summary>
    /// <returns>The <see cref="IDisposable"/> used to dispose this binding.</returns>
    /// <param name="sectionsObservable">Sections observable.</param>
    /// <param name="tableView">Table view.</param>
    /// <param name="initSource">Optionally initializes some property of
    /// the <see cref="ReactiveTableViewSource{TSource}"/>.</param>
    /// <typeparam name="TSource">The source type.</typeparam>
    /// <typeparam name="TCell">Type of the <see cref="UITableViewCell"/>.</typeparam>
    public static IDisposable BindTo <TSource, TCell>(
        this IObservable <IReadOnlyList <TableSectionInformation <TSource, TCell> > > sectionsObservable,
        UITableView tableView,
        Func <ReactiveTableViewSource <TSource>, IDisposable>?initSource = null)
        where TCell : UITableViewCell
    {
        if (sectionsObservable is null)
        {
            throw new ArgumentNullException(nameof(sectionsObservable));
        }

        if (tableView is null)
        {
            throw new ArgumentNullException(nameof(tableView));
        }

        var source = new ReactiveTableViewSource <TSource>(tableView);

        if (initSource is not null)
        {
            initSource(source);
        }

        var bind = sectionsObservable.BindTo(source, x => x.Data);

        tableView.Source = source;

        return(new CompositeDisposable(bind, source));
    }
Esempio n. 5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            TableView.RegisterClassForCellReuse(typeof(TeamCellView), TeamCellView.Key);
            var source = new ReactiveTableViewSource <TeamItemViewModel>(TableView, ViewModel.Teams, TeamCellView.Key, 44f);

            source.ElementSelected.OfType <TeamItemViewModel>().Subscribe(x => x.GoToCommand.ExecuteIfCan());
            TableView.Source = source;
        }
Esempio n. 6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            TableView.RegisterClassForCellReuse(typeof(TeamCellView), TeamCellView.Key);
            var source = new ReactiveTableViewSource <TeamItemViewModel>(TableView, ViewModel.Items, TeamCellView.Key, (float)UITableView.AutomaticDimension);

            TableView.Source = source;

            this.WhenActivated(d => d(source.ElementSelected.OfType <TeamItemViewModel>().Subscribe(x => x.GoToCommand.ExecuteIfCan())));
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            TableView.RegisterClassForCellReuse(typeof(BranchCellView), BranchCellView.Key);
            var source = new ReactiveTableViewSource <BranchItemViewModel>(TableView, ViewModel.Items, BranchCellView.Key, 44f);

            OnActivation(d => d(source.ElementSelected.OfType <BranchItemViewModel>().Subscribe(x => x.GoToCommand.ExecuteIfCan())));
            TableView.Source = source;
        }
Esempio n. 8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            TableView.RegisterClassForCellReuse(typeof(BranchCellView), BranchCellView.Key);
            var source = new ReactiveTableViewSource <BranchModel>(TableView, ViewModel.Branches, BranchCellView.Key, 44f);

            source.ElementSelected.Subscribe(ViewModel.GoToBranchCommand.ExecuteIfCan);
            TableView.Source = source;

            ViewModel.LoadCommand.ExecuteIfCan();
        }
Esempio n. 9
0
        public override void ViewDidLoad()
        {
            Title = "Teams";
            base.ViewDidLoad();
            this.AddSearchBar(x => ViewModel.SearchKeyword = x);
            TableView.RegisterClassForCellReuse(typeof(TeamCellView), TeamCellView.Key);
            var source = new ReactiveTableViewSource <TeamShortModel>(TableView, ViewModel.Teams, TeamCellView.Key, 44f);

            source.ElementSelected.Subscribe(ViewModel.GoToTeamCommand.ExecuteIfCan);
            TableView.Source = source;

            ViewModel.LoadCommand.ExecuteIfCan();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

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

            TableView.RegisterClassForCellReuse(typeof(BranchCellView), BranchCellView.Key);
            var source = new ReactiveTableViewSource <BranchItemViewModel>(TableView, ViewModel.Items, BranchCellView.Key, 44f);

            source.ElementSelected.OfType <BranchItemViewModel>().Subscribe(x => x.GoToCommand.ExecuteIfCan());
            TableView.Source = source;
        }
Esempio n. 11
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.AddSearchBar(x => ViewModel.SearchKeyword = x);

            _viewSegment = new UISegmentedControl(new object[] { "Branches", "Tags" });
            _viewSegment.ValueChanged += (sender, args) => ViewModel.SelectedFilter = (BranchesAndTagsViewModel.ShowIndex)_viewSegment.SelectedSegment;
            ViewModel.WhenAnyValue(x => x.SelectedFilter).Subscribe(x => _viewSegment.SelectedSegment = (int)x);
            NavigationItem.TitleView = _viewSegment;

            TableView.RegisterClassForCellReuse(typeof(BranchCellView), BranchCellView.Key);
            TableView.RegisterClassForCellReuse(typeof(TagCellView), TagCellView.Key);

            ViewModel.WhenAnyValue(x => x.SelectedFilter)
            .Subscribe(x =>
            {
                if (TableView.Source != null)
                {
                    TableView.Source.Dispose();
                    TableView.Source = null;
                }

                if (x == BranchesAndTagsViewModel.ShowIndex.Branches)
                {
                    var source = new ReactiveTableViewSource <BranchModel>(TableView, ViewModel.Branches, BranchCellView.Key, 44f);
                    source.ElementSelected.Subscribe(ViewModel.GoToSourceCommand.ExecuteIfCan);
                    TableView.Source = source;
                }
                else
                {
                    var source = new ReactiveTableViewSource <TagModel>(TableView, ViewModel.Tags, TagCellView.Key, 44f);
                    source.ElementSelected.Subscribe(ViewModel.GoToSourceCommand.ExecuteIfCan);
                    TableView.Source = source;
                }
            });

            ViewModel.LoadCommand.ExecuteIfCan();
        }