public SettingsViewModel(IBiometricsService biometricsService, IApplicationStateService applicationStateService, IBandService bandService, IShell shell) { Guard.NotNull(biometricsService, nameof(biometricsService)); Guard.NotNull(applicationStateService, nameof(applicationStateService)); Guard.NotNull(bandService, nameof(bandService)); this._biometricsService = biometricsService; this._applicationStateService = applicationStateService; this._bandService = bandService; this._shell = shell; var hasUser = new ReplaySubject<bool>(1); hasUser.OnNext(this._applicationStateService.GetCurrentUser() != null); var deviceAvailable = this._biometricsService.BiometricAuthDeviceIsAvailableAsync().ToObservable(); var canRememberLogin = hasUser.CombineLatest(deviceAvailable, (hasUsr, deviceAvail) => hasUsr && deviceAvail); this.RememberLogin = UwCoreCommand.Create(canRememberLogin, this.RememberLoginImpl) .ShowLoadingOverlay(CTime2Resources.Get("Loading.RememberedLogin")) .HandleExceptions() .TrackEvent("SetupRememberLogin"); var canToggleTile = this.WhenAnyValue(f => f.State, state => state != BandState.NotConnected); this.ToggleBandTile = UwCoreCommand.Create(canToggleTile, this.ToggleTileImpl) .ShowLoadingOverlay(() => this.State == BandState.Installed ? CTime2Resources.Get("Loading.RemoveTileFromBand") : CTime2Resources.Get("Loading.AddTileToBand")) .HandleExceptions() .TrackEvent("ToggleBandTile"); this.Reload = UwCoreCommand.Create(this.ReloadImpl) .ShowLoadingOverlay(CTime2Resources.Get("Loading.Settings")) .HandleExceptions() .TrackEvent("ReloadSettings"); this.Theme = this._applicationStateService.GetApplicationTheme(); this.SelectedWorkTime = this._applicationStateService.GetWorkDayHours(); this.SelectedBreakTime = this._applicationStateService.GetWorkDayBreak(); this.CompanyId = this._applicationStateService.GetCompanyId(); this.WhenAnyValue(f => f.Theme) .Subscribe(theme => { this._shell.Theme = theme; this._applicationStateService.SetApplicationTheme(theme); }); this.WhenAnyValue(f => f.SelectedWorkTime) .Subscribe(workTime => { this._applicationStateService.SetWorkDayHours(workTime); }); this.WhenAnyValue(f => f.SelectedBreakTime) .Subscribe(breakTime => { this._applicationStateService.SetWorkDayBreak(breakTime); }); this.WhenAnyValue(f => f.CompanyId) .Subscribe(companyId => { this._applicationStateService.SetCompanyId(companyId); }); this.DisplayName = CTime2Resources.Get("Navigation.Settings"); this.WorkTimes = new ReactiveList<TimeSpan>(Enumerable .Repeat((object)null, 4 * 24) .Select((_, i) => TimeSpan.FromHours(0.25 * i))); this.BreakTimes = new ReactiveList<TimeSpan>(Enumerable .Repeat((object)null, 4 * 24) .Select((_, i) => TimeSpan.FromHours(0.25 * i))); }