public TrackDetailMotiveViewModel(IRepoManager repoManager,
                                   INavigation navigation,
                                   ITabiConfiguration configuration,
                                   TrackMotiveViewModel motiveViewModel,
                                   MotiveSelectionViewModel motiveSelectionViewModel) : base(repoManager, navigation, configuration, motiveSelectionViewModel)
 {
     Motive = motiveViewModel ?? throw new ArgumentNullException(nameof(motiveViewModel));
     SetupMotives();
 }
Esempio n. 2
0
        protected DetailMotiveViewModel(IRepoManager repoManager,
                                        INavigation navigation,
                                        ITabiConfiguration configuration,
                                        MotiveSelectionViewModel motiveSelectionViewModel)
        {
            _navigation = navigation ?? throw new ArgumentNullException(nameof(navigation));
            _motiveSelectionViewModel = motiveSelectionViewModel ?? throw new ArgumentNullException(nameof(motiveSelectionViewModel));
            _configuration            = configuration ?? throw new ArgumentNullException(nameof(configuration));
            _repoManager = repoManager ?? throw new ArgumentNullException(nameof(repoManager));

            SaveCommand   = new Command(Save);
            CancelCommand = new Command(async() =>
            {
                ResetViewModel();
                await PopPageAsync();
            });

            _motiveSelectionViewModel.PropertyChanged += _motiveSelectionViewModel_PropertyChanged;

            PossibleMotives = new ObservableRangeCollection <MotiveOptionViewModel>();
        }
Esempio n. 3
0
        public SearchMotiveViewModel(ITabiConfiguration configuration, INavigation navigation, MotiveSelectionViewModel motiveSelectionViewModel)
        {
            _navigation               = navigation ?? throw new ArgumentNullException(nameof(navigation));
            _configuration            = configuration ?? throw new ArgumentNullException(nameof(configuration));
            _motiveSelectionViewModel = motiveSelectionViewModel ?? throw new ArgumentNullException(nameof(motiveSelectionViewModel));

            PossibleMotives = new ObservableRangeCollection <MotiveOptionViewModel>();

            CustomMotiveCommand = new Command(async(obj) =>
            {
                _motiveSelectionViewModel.SelectedMotiveOption = new MotiveOptionViewModel()
                {
                    Id   = SearchText,
                    Text = SearchText,
                };

                _motiveSelectionViewModel.CustomMotive = true;
                _motiveSelectionViewModel.ShouldSave   = true;

                await _navigation.PopAsync();
            });

            SetupMotive(null);
            // Setup possible motives

            PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == nameof(SearchText))
                {
                    OnPropertyChanged(nameof(CustomMotiveText));
                    SetupMotive(searchText);
                    CustomMotiveVisible = SearchText.Length > 0;
                    OtherMotivesVisible = SearchText.Length > 2;
                }
            };
        }