예제 #1
0
        public async Task SelectMotive(MotiveOptionViewModel motiveOptionView)
        {
            _motiveSelectionViewModel.SelectedMotiveOption          = motiveOptionView;
            _motiveSelectionViewModel.SelectedMotiveOption.Selected = true;
            _motiveSelectionViewModel.ShouldSave = true;

            _motiveSelectionViewModel.CustomMotive = true;
            await _navigation.PopAsync();
        }
예제 #2
0
        protected void SetupMotives()
        {
            bool foundMotive = false;
            bool motiveIsSet = !string.IsNullOrEmpty(MotiveText);

            // Setup possible motives
            foreach (MotiveOption mo in _configuration.Motive.Options)
            {
                string translatedText        = typeof(AppResources).GetProperty($"{mo.Id}MotiveText")?.GetValue(null) as string;
                string text                  = translatedText ?? mo.Text;
                MotiveOptionViewModel motive = new MotiveOptionViewModel()
                {
                    Text = text, Id = mo.Id
                };
                if (motiveIsSet && motive.Id == MotiveText)
                {
                    motive.Selected = true;
                    _motiveSelectionViewModel.SelectedMotiveOption = motive;
                    foundMotive = true;
                }
                PossibleMotives.Add(motive);
            }

            foreach (MotiveOption mo in _configuration.Motive.OtherOptions)
            {
                string translatedText = typeof(AppResources).GetProperty($"{mo.Id}MotiveText")?.GetValue(null) as string;
                string text           = translatedText ?? mo.Text;
                if (motiveIsSet && mo.Id == MotiveText)
                {
                    CustomMotiveOption = new MotiveOptionViewModel()
                    {
                        Text = text, Id = mo.Id
                    };
                    _motiveSelectionViewModel.SelectedMotiveOption = CustomMotiveOption;
                    CustomMotiveOption.Selected            = true;
                    _motiveSelectionViewModel.CustomMotive = true;
                    foundMotive = true;
                    break;
                }
            }

            if (motiveIsSet && !foundMotive)
            {
                CustomMotiveOption = new MotiveOptionViewModel()
                {
                    Text = MotiveText, Id = MotiveText
                };
                _motiveSelectionViewModel.SelectedMotiveOption = CustomMotiveOption;
                CustomMotiveOption.Selected            = true;
                _motiveSelectionViewModel.CustomMotive = true;
                foundMotive = true;
            }
        }
예제 #3
0
        public void SetupMotive(string filter)
        {
            PossibleMotives.Clear();
            foreach (MotiveOption mo in _configuration.Motive.OtherOptions)
            {
                string translatedText = typeof(AppResources).GetProperty($"{mo.Id}MotiveText")?.GetValue(null) as string;
                string text           = translatedText ?? mo.Text;

                if (filter == null || filter == "" || text.ToLower().Contains(filter.ToLower()))
                {
                    MotiveOptionViewModel motive = new MotiveOptionViewModel()
                    {
                        Text = text, Id = mo.Id
                    };
                    if (motive.Id == _motiveSelectionViewModel.SelectedMotiveOption?.Id)
                    {
                        motive.Selected = true;
                        _motiveSelectionViewModel.SelectedMotiveOption = motive;
                    }
                    PossibleMotives.Add(motive);
                }
            }
        }