public FooterHolder(View root, LogTimeEntriesViewModel viewModel) : base(root) { retryLayout = ItemView.FindViewById <RelativeLayout> (Resource.Id.RetryLayout); progressBar = ItemView.FindViewById <ProgressBar> (Resource.Id.ProgressBar); retryButton = ItemView.FindViewById <Button> (Resource.Id.RetryButton); retryButton.Click += async(sender, e) => await viewModel.LoadMore(); }
public void SetViewModel(LogTimeEntriesViewModel viewModel) { ViewModel = viewModel; // TODO: investigate why WhenSourceChanges doesn't work. :( isRunningBinding = this.SetBinding(() => ViewModel.IsTimeEntryRunning, () => IsRunning); durationBinding = this.SetBinding(() => ViewModel.Duration, () => DurationTextView.Text); descBinding = this.SetBinding(() => ViewModel.Description, () => DescriptionTextView.Text) .ConvertSourceToTarget(desc => desc != string.Empty ? desc : activity.ApplicationContext.Resources.GetText(Resource.String.TimerComponentNoDescription)); projectBinding = this.SetBinding(() => ViewModel.ProjectName, () => ProjectTextView.Text) .ConvertSourceToTarget(proj => proj != string.Empty ? proj : activity.ApplicationContext.Resources.GetText(Resource.String.TimerComponentNoProject)); }
public async override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); viewModel = new LogTimeEntriesViewModel(); await viewModel.Init(); binding = Binding.Create(() => HasMore == viewModel.CollectionView.HasMore && ItemCount == viewModel.ItemCount && CollectionView == viewModel.CollectionView && IsRunning == viewModel.IsTimeEntryRunning); startStopBtn.Click += async(sender, e) => await viewModel.StartStopTimeEntry(); }
public FooterHolder(View root, LogTimeEntriesViewModel viewModel) : base(root) { Vm = viewModel; retryLayout = ItemView.FindViewById <RelativeLayout> (Resource.Id.RetryLayout); retryButton = ItemView.FindViewById <Button> (Resource.Id.RetryButton); progressBar = ItemView.FindViewById <ProgressBar> (Resource.Id.ProgressBar); IsRecyclable = false; retryButton.Click += async(sender, e) => await Vm.LoadMore(); hasMoreBinding = this.SetBinding(() => Vm.HasMoreItems).WhenSourceChanges(SetFooterState); hasErrorBinding = this.SetBinding(() => Vm.HasLoadErrors).WhenSourceChanges(SetFooterState); SetFooterState(); }
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(); }
public async override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); // init viewModel ViewModel = LogTimeEntriesViewModel.Init(); collectionBinding = this.SetBinding(() => ViewModel.Collection).WhenSourceChanges(() => { logAdapter = new LogTimeEntriesAdapter(recyclerView, ViewModel); recyclerView.SetAdapter(logAdapter); }); hasMoreBinging = this.SetBinding(() => ViewModel.HasMoreItems).WhenSourceChanges(SetFooterState); hasErrorBinding = this.SetBinding(() => ViewModel.HasLoadErrors).WhenSourceChanges(SetFooterState); hasItemsBinding = this.SetBinding(() => ViewModel.HasItems).WhenSourceChanges(SetCollectionState); fabBinding = this.SetBinding(() => ViewModel.IsTimeEntryRunning, () => StartStopBtn.ButtonAction) .ConvertSourceToTarget(isRunning => isRunning ? FABButtonState.Stop : FABButtonState.Start); newMenuBinding = this.SetBinding(() => ViewModel.IsTimeEntryRunning) .WhenSourceChanges(() => { if (AddNewMenuItem != null) { AddNewMenuItem.SetVisible(!ViewModel.IsTimeEntryRunning); } }); // Pass ViewModel to TimerComponent. timerComponent.SetViewModel(ViewModel); StartStopBtn.Click += StartStopClick; SetupRecyclerView(ViewModel); // 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(); // Subscribe to sync messages var bus = ServiceContainer.Resolve <MessageBus> (); drawerSyncFinished = bus.Subscribe <SyncFinishedMessage> (SyncFinished); }
private void SetupRecyclerView(LogTimeEntriesViewModel viewModel) { // Touch listeners. itemTouchListener = new ItemTouchListener(recyclerView, this); recyclerView.AddOnItemTouchListener(itemTouchListener); // Scroll listener recyclerView.AddOnScrollListener( new ScrollListener((LinearLayoutManager)recyclerView.GetLayoutManager(), viewModel)); var touchCallback = new SwipeDismissCallback(ItemTouchHelper.Up | ItemTouchHelper.Down, ItemTouchHelper.Left, this); var touchHelper = new ItemTouchHelper(touchCallback); touchHelper.AttachToRecyclerView(recyclerView); // Decorations. dividerDecoration = new DividerItemDecoration(Activity, DividerItemDecoration.VerticalList); shadowDecoration = new ShadowItemDecoration(Activity); recyclerView.AddItemDecoration(dividerDecoration); recyclerView.AddItemDecoration(shadowDecoration); recyclerView.GetItemAnimator().SupportsChangeAnimations = false; }
public ScrollListener(LinearLayoutManager linearLayoutManager, LogTimeEntriesViewModel viewModel) { this.linearLayoutManager = linearLayoutManager; this.viewModel = viewModel; }
public TimeEntriesSource(LogViewController owner, LogTimeEntriesViewModel viewModel) : base(owner.TableView, viewModel.Collection) { this.owner = owner; VM = viewModel; }
public LogTimeEntriesAdapter(RecyclerView owner, LogTimeEntriesViewModel viewModel) : base(owner, viewModel.Collection) { ViewModel = viewModel; lastTimeEntryContinuedTime = Time.UtcNow; }