private void ConnectViewModel(IBusyPageViewModel viewModel)
        {
            _currentViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
            _pageManager.ConfigurePage(_currentViewModel);

            if (Content != null)
            {
                if (Content is Layout <View> layout)
                {
                    layout.Children.Add(_pageManager.ActivityIndicator);
                }

                _pageManager.SetBusyHost(Content);
            }
        }
Exemplo n.º 2
0
        private void ConnectViewModel(TableViewModel viewModel)
        {
            _currentViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
            _pageManager.ConfigurePage(_currentViewModel);
            _tableView.HasUnevenRows   = _currentViewModel.HasUnevenRows;
            _tableView.Intent          = viewModel.Intent;
            _tableView.BackgroundColor = viewModel.BackgroundColour;

            SetupSearchbar(_currentViewModel.SearchBar);
            SetupSections(_currentViewModel.Sections);

            _pageManager.Disposibles.Add(Observable.FromEventPattern <NotifyCollectionChangedEventHandler, NotifyCollectionChangedEventArgs>
                                         (
                                             h => _currentViewModel.Sections.CollectionChanged += h,
                                             h => _currentViewModel.Sections.CollectionChanged -= h
                                         ).Subscribe((args) =>
            {
                if (args.EventArgs.Action == NotifyCollectionChangedAction.Add && args.EventArgs.NewItems != null)
                {
                    var addedSections = args.EventArgs.NewItems.Cast <TableSectionViewModel>();
                    addedSections.ForEach(svm => _tableView.Root.Add(CreateSectionView(svm)));
                }
            }));
        }