public ActionSheetCellViewModel(TTarget data, Expression <Func <TTarget, TEnum> > propertySetter,
                                 IActionSheetController sheetController,
                                 Func <ActionSheetResponse, TEnum> converter)
     : base(sheetController, converter)
 {
     _propertyValueSaver = new PropertyValueManager <TTarget, TEnum>(data, propertySetter);
     SetValue(_propertyValueSaver.GetValue());
 }
        public ActionSheetCellViewModel(TTarget data,
                                        Expression <Func <TTarget, TEnum> > propertySetter,
                                        IActionSheetController sheetController) : this(data, propertySetter, sheetController, (arg) =>
        {
            if (arg.Result == ActionSheetButtonResponse.Option)
            {
                return((TEnum)arg.Option.Value);
            }

            return(default(TEnum));
        })
        {
        }
Example #3
0
        public WeightConversionTableViewModel(IActionSheetController sheetController, INavigationService navigationService, ISchedulerService scheduler, IViewModelFactory viewModelFactory)
            : base(navigationService, scheduler)
        {
            if (viewModelFactory == null)
            {
                throw new ArgumentNullException(nameof(viewModelFactory));
            }

            Title             = "Weight Conversion";
            ShowNavigationBar = true;
            Intent            = TableIntent.Form;

            SeparatorStyle = TableCellSeparatorStyle.SingleLine;
            _topSection    = AddSection("Converter");

            var poundsCell = new NumericEntryCellViewModel()
            {
                Label = "Pounds", IsInteger = false
            };
            var kilosCell = new NumericEntryCellViewModel()
            {
                Label = "Kilos", IsInteger = false
            };


            poundsCell.Values.ObserveOn(Scheduler.UiScheduler)
            .Where(e => e.HasValue)
            .Subscribe((e) =>
            {
                // We have a new pounds value, we need to process this and push the related kilos value to the kilos cell.
                kilosCell.Value = WeightConverter.ToKilosFromPounds(e.Value);
            });

            _topSection.AddCell(poundsCell);


            kilosCell.Values.ObserveOn(Scheduler.UiScheduler)
            .Where(e => e.HasValue)
            .Subscribe((e) =>
            {
                poundsCell.Value = ImperialWeight.FromKilos(e.Value).TotalPounds;
            });

            _topSection.AddCell(kilosCell);
        }
        public IntegrationViewModel(IActionSheetController actionController, INavigationService navigationService, ISchedulerService scheduler) : base(navigationService, scheduler)
        {
            _actionController = actionController;
            Title             = "Toolbar Tester";

            _saveCommand = new Command((obj) =>
            {
                var options = new ActionSheetViewModel()
                {
                    CancelMessage      = "Cancel",
                    DestructionMessage = "Darth!",
                    Title   = "Evil?",
                    Options = new []
                    {
                        new ActionSheetOption()
                        {
                            Title = "A"
                        },
                        new ActionSheetOption()
                        {
                            Title = "B"
                        },
                        new ActionSheetOption()
                        {
                            Title = "C"
                        }
                    }
                };
                _actionController.ShowActionSheet(options);
            });

            Toolbar.Add(new TextToolbarItemViewModel("Save", _saveCommand));
            var section = AddSection("Balls");

            section.AddCell(new TextCellViewModel()
            {
                Text = "Tester"
            });
            section.AddCell(new NumericEntryCellViewModel(23.5M)
            {
                Label = "Tester"
            });
        }
        public SingleSectionTableViewModel(IActionSheetController sheetController, INavigationService navigationService, ISchedulerService scheduler, IViewModelFactory viewModelFactory)
            : base(navigationService, scheduler)
        {
            if (viewModelFactory == null)
            {
                throw new ArgumentNullException(nameof(viewModelFactory));
            }
            Title                     = "Date Picker";
            ShowNavigationBar         = true;
            ShowSearchBar             = true;
            SearchBar.PlaceholderText = "Find something";
            Intent                    = TableIntent.Form;

            _saveCommand = new Command((obj) =>
            {
                var viewModel = viewModelFactory.CreateModel <IntegrationViewModel>();
                navigationService.PushModalAsync(viewModel);
            });;

            SeparatorStyle = TableCellSeparatorStyle.SingleLine;
            _topSection    = AddSection("Settings");

            var dataThing = new SomeDataThing()
            {
                MyDateTimeValue = DateTime.UtcNow, MySwitchValue = true, MyTextValue = "Balls would be", MyEnumValue = MyTestEnum.Bags
            };

            _topSection.AddCell(new NullableSwitchCellViewModel <SomeDataThing>(dataThing, d => d.MyNullableSwitchValue)
            {
                Label = "Nullable switch"
            });
            _topSection.AddCell(new NumericEntryCellViewModel <SomeDataThing>(dataThing, d => d.MyDecimalValue)
            {
                Label = "Numeric"
            });
            _topSection.AddCell(new NumericEntryCellViewModel <SomeDataThing>(dataThing, d => d.MyNullableDecimalValue)
            {
                Label = "Nullable numeric"
            });
            _topSection.AddBusyCell("Wooooah!");
            _topSection.AddDateTimeCell(dataThing, d => d.MyDateTimeValue, "Start", "Enter start date");
            _topSection.AddDateTimeCell(dataThing, d => d.MyDateTimeValue, "Finish", "Enter end date");
            Toolbar.Add(new TextToolbarItemViewModel()
            {
                Text = "Save", Command = _saveCommand
            });

            _secondSection = AddSection("Stuff");
            _secondSection.AddCell(new BusyCellViewModel()
            {
                Text = "Bloody busy!"
            });

            var commandSection = AddSection("Commands");

            commandSection.AddCell(new TextCellViewModel("Click me")
            {
                Command = new Command(() =>
                {
                    _secondSection.Cells.Clear();
                })
            });

            Icon = "schedule.png";
        }