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(); }); }
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 MainViewController() { ViewModel = new ListViewModel(); this.WhenActivated(disposable => { TableView.Delegate = this; TableView.RegisterClassForCellReuse(typeof(BaseCell), BaseCell.Key); IObservable <IVirtualRequest> request = Observable.Return(new VirtualRequest(4, 255)); new SourceList <ListItemViewModel>(ViewModel.ListCollection) .Connect() .Filter(i => i.Group == 0) .Bind(out var topCollection) .Subscribe() .DisposeWith(disposable); new SourceList <ListItemViewModel>(ViewModel.ListCollection) .Connect() .Filter(i => i.Group == 1) .Virtualise(request) .Bind(out var dynamicCollection) .Subscribe() .DisposeWith(disposable); new SourceList <ListItemViewModel>(ViewModel.ListCollection) .Connect() .Filter(i => i.Group == 2) .Bind(out var bottomCollection) .Subscribe() .DisposeWith(disposable); new SourceList <ListItemViewModel>(ViewModel.ListCollection) .Connect() .Filter(i => i.Group == 3) .Bind(out var syncCollection) .Subscribe() .DisposeWith(disposable); var sizeHint = 56f; var top = new TableSectionInformation <ListItemViewModel, SimpleCell>(topCollection, BaseCell.Key, sizeHint, cell => cell.SetupViews()); var dynamic = new TableSectionInformation <ListItemViewModel, SimpleCell>(dynamicCollection, BaseCell.Key, sizeHint, cell => cell.SetupViews()); var bottom = new TableSectionInformation <ListItemViewModel, SimpleCell>(bottomCollection, BaseCell.Key, sizeHint, cell => cell.SetupViews()); var sync = new TableSectionInformation <ListItemViewModel, SimpleCell>(syncCollection, BaseCell.Key, sizeHint, cell => cell.SetupViews()); var sectionCollection = new TableSectionInformation <ListItemViewModel>[] { top, dynamic, bottom, sync }; var tableSource = new MoreTableSource <ListItemViewModel>(TableView) { Data = sectionCollection }; TableView.Source = tableSource; }); }