Exemplo n.º 1
0
 public ActionSheetBuilder(IActionPresenter presenter)
 {
     _presenter = presenter;
     _cancel    = Prelude.None;
     _destroy   = Prelude.None;
     _actions   = new List <ActionSheetItem>();
 }
 public AuthorizeHealthCommand(IAuthorizer authorizer, IClock clock, IActionPresenter alertPresenter, IAnalytics analytics, ILogger logger, ISettingsStore settings)
 {
     _authorizer     = authorizer;
     _clock          = clock;
     _alertPresenter = alertPresenter;
     _analytics      = analytics;
     _logger         = logger;
     _settings       = settings;
 }
Exemplo n.º 3
0
        static MainPageViewModel GetSut(
            IClock clock                     = null,
            IShare share                     = null,
            IAuthorizer authorizer           = null,
            INavigationService navService    = null,
            IActionPresenter actionPresenter = null,
            ISettingsStore settings          = null,
            IFileManager fileManager         = null,
            IHealthStore healthStore         = null)
        {
            clock ??= SystemClock.Instance;
            var logger = new LoggerConfiguration().CreateLogger();

            var mockAuthorizer      = new Mock <IAuthorizer>();
            var mockSettings        = new Mock <ISettingsStore>();
            var mockAnalytics       = new Mock <IAnalytics>();
            var mockActionPresenter = new Mock <IActionPresenter>();
            var mockNavService      = new Mock <INavigationService>();
            var mockFileManager     = new Mock <IFileManager>();

            mockFileManager
            .Setup(x => x.GetNewFileName())
            .Returns(new FileInfo("arbitrary-filename-for-testing.xlsx"));

            var authCommand = new AuthorizeHealthCommand(
                authorizer ?? mockAuthorizer.Object,
                clock,
                actionPresenter ?? mockActionPresenter.Object,
                mockAnalytics.Object,
                logger,
                settings ?? mockSettings.Object);

            var exporter = new ExportSpreadsheetCommand(
                fileManager ?? mockFileManager.Object,
                actionPresenter ?? mockActionPresenter.Object,
                settings ?? mockSettings.Object,
                clock,
                mockAnalytics.Object,
                healthStore ?? new Mock <IHealthStore>().Object,
                share ?? new Mock <IShare>().Object,
                new Configuration(),
                logger);

            return(new MainPageViewModel(
                       authCommand,
                       exporter,
                       settings ?? mockSettings.Object,
                       navService ?? mockNavService.Object,
                       mockAnalytics.Object));
        }
Exemplo n.º 4
0
 public static ActionSheetBuilder ActionSheet(this IActionPresenter target)
 {
     return(new ActionSheetBuilder(target));
 }
        public ExportSettingsViewModel(ISettingsStore settings, IAnalytics analytics, INavigationService nav, IFileManager fileManager, IActionPresenter actionPresenter) : base(analytics)
        {
            _settings  = settings;
            _analytics = analytics;

            BrowseForCustomSheetsLocation = new Command(async() =>
            {
                var fileData = await CrossFilePicker.Current.PickFile();
                if (fileData == null)
                {
                    return; // user canceled file picking
                }
                var fileName = fileManager.SaveFile(fileData.FileName, fileData.DataArray);
                settings.SetCustomSheetsLocation(fileName);
                OnPropertyChanged(nameof(CustomSheetsLocation));
                OnPropertyChanged(nameof(HasCustomSheetsLocation));
                OnPropertyChanged(nameof(NoCustomSheetsLocation));
            });

            ChangeCustomSheetsLocation = new Command(() =>
            {
                actionPresenter.ActionSheet()
                .With(AppRes.ExportSettings_CustomSheets_Change_Browse, BrowseForCustomSheetsLocation)
                .With(AppRes.ExportSettings_CustomSheets_Change_Clear, () =>
                {
                    settings.ClearCustomSheetsLocation();
                    OnPropertyChanged(nameof(CustomSheetsLocation));
                    OnPropertyChanged(nameof(HasCustomSheetsLocation));
                    OnPropertyChanged(nameof(NoCustomSheetsLocation));
                })
                .WithCancel(AppRes.ExportSettings_CustomSheets_Change_Cancel)
                .Show(AppRes.ExportSettings_CustomSheets_Change_Title);
            });

            Dismiss       = new Command(() => nav.DismissModal());
            DistanceUnits = new List <PickerOption <LengthUnit> >
            {
                new PickerOption <LengthUnit> {
                    DisplayValue = AppRes.Settings_LengthUnit_Meters, Value = LengthUnit.Meter
                },
                new PickerOption <LengthUnit> {
                    DisplayValue = AppRes.Settings_LengthUnit_Miles, Value = LengthUnit.Mile
                },
            };
            MassUnits = new List <PickerOption <MassUnit> >
            {
                new PickerOption <MassUnit> {
                    DisplayValue = AppRes.Settings_MassUnit_Kilograms, Value = MassUnit.Kilogram
                },
                new PickerOption <MassUnit> {
                    DisplayValue = AppRes.Settings_MassUnit_Pounds, Value = MassUnit.Pound
                },
            };
            EnergyUnits = new List <PickerOption <EnergyUnit> >
            {
                new PickerOption <EnergyUnit> {
                    DisplayValue = AppRes.Settings_EnergyUnit_Kilocalories, Value = EnergyUnit.Kilocalorie
                },
                new PickerOption <EnergyUnit> {
                    DisplayValue = AppRes.Settings_EnergyUnit_Calories, Value = EnergyUnit.Calorie
                },
            };
            DurationUnits = new List <PickerOption <DurationUnit> >
            {
                new PickerOption <DurationUnit> {
                    DisplayValue = AppRes.Settings_DurationUnit_Minutes, Value = DurationUnit.Minute
                },
                new PickerOption <DurationUnit> {
                    DisplayValue = AppRes.Settings_DurationUnit_Hours, Value = DurationUnit.Hour
                },
            };
        }