public override void ViewDidLoad() { base.ViewDidLoad(); EdgesForExtendedLayout = UIRectEdge.None; emptyView = new SimpleEmptyView() { Title = "LogEmptyTitle".Tr(), Message = "LogEmptyMessage".Tr(), }; var headerView = new TableViewRefreshView(); var source = new Source(this) { EmptyView = emptyView, HeaderView = headerView }; source.Attach(); RefreshControl = headerView; headerView.AdaptToTableView(TableView); }
public async override void ViewDidLoad() { base.ViewDidLoad(); NavigationItem.LeftBarButtonItem = new UIBarButtonItem( Image.IconNav.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), UIBarButtonItemStyle.Plain, OnNavigationButtonTouched); EdgesForExtendedLayout = UIRectEdge.None; TableView.RegisterClassForCellReuse(typeof(TimeEntryCell), EntryCellId); TableView.RegisterClassForHeaderFooterViewReuse(typeof(SectionHeaderView), SectionHeaderId); TableView.SetEditing(false, true); // Create view model ViewModel = LogTimeEntriesViewModel.Init(); var headerView = new TableViewRefreshView(); RefreshControl = headerView; headerView.AdaptToTableView(TableView); headerView.ValueChanged += (sender, e) => ViewModel.TriggerFullSync(); // Bindings syncBinding = this.SetBinding(() => ViewModel.IsAppSyncing).WhenSourceChanges(() => { if (!ViewModel.IsAppSyncing) { headerView.EndRefreshing(); } }); hasMoreBinding = this.SetBinding(() => ViewModel.HasMoreItems).WhenSourceChanges(SetFooterState); hasErrorBinding = this.SetBinding(() => ViewModel.HasLoadErrors).WhenSourceChanges(SetFooterState); hasItemsBinding = this.SetBinding(() => ViewModel.HasItems).WhenSourceChanges(SetCollectionState); loadMoreBinding = this.SetBinding(() => ViewModel.HasItems).WhenSourceChanges(LoadMoreIfNeeded); collectionBinding = this.SetBinding(() => ViewModel.Collection).WhenSourceChanges(() => { TableView.Source = new TimeEntriesSource(this, ViewModel); }); isRunningBinding = this.SetBinding(() => ViewModel.IsTimeEntryRunning).WhenSourceChanges(SetStartStopButtonState); durationBinding = this.SetBinding(() => ViewModel.Duration).WhenSourceChanges(() => durationButton.SetTitle(ViewModel.Duration, UIControlState.Normal)); // TODO: Review this line. // Get data to fill the list. For the moment, // until a screenloader is added to the screen // is better to load the items after create // the viewModel and show the loader from RecyclerView await ViewModel.LoadMore(); }