public ProjectDetailsPageViewModel( INavigationService navigationService, IAnalyticService analyticService) : base(navigationService) { Title = "Project Details"; analyticService.TrackScreen("project-detail"); NavigatedTo .Take(1) .Select(args => (Project)args["project"]) .Subscribe(project => { Project = project; }); }
public ProfilePageViewModel(INavigationService navigationService) : base(navigationService) { Title = "Profile"; Edit = ReactiveCommand.CreateFromTask(async() => { var parameters = new NavigationParameters { { "user", User } }; await NavigationService.NavigateAsync($"NavigationPage/{nameof(EditableProfilePage)}", parameters, useModalNavigation: true).ConfigureAwait(false); }); NavigatedTo .Take(1) .Select(args => args["user"] as Account) .Subscribe(user => { // TODO: Add handler for when user is null User = user; }); }
public EditableProfilePageViewModel( INavigationService navigationService, IUserDialogs dialogService, IProjectDataStore projectDataStore, IPermissionsService permissionsService) : base(navigationService) { Title = "Edit Profile"; AddValidationRules(); NavigatedTo .Take(1) .Select(args => args["user"] as Account) .Subscribe(user => { // TODO: Handle null user, handle editing... }); ChangePhoto = ReactiveCommand.CreateFromTask(async() => { try { // check if permission has been granted to the photos var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Photos); if (status != PermissionStatus.Granted) { status = await permissionsService.CheckPermissionsAsync(Permission.Photos, dialogService); } // if permission was granted, open the photo picker if (status == PermissionStatus.Granted) { using (var file = await CrossMedia.Current.PickPhotoAsync(_pickOptions)) { if (file != null) { Photo = file.GetStream(); } } } else { // permission was not granted. Let the user know they can't pick a photo // without permissions await dialogService.AlertAsync( new AlertConfig { Title = "Photos Not Supported", Message = ":( Permission not granted to photos.", OkText = "OK" }).ConfigureAwait(false); return; } } catch (MediaPermissionException mediaException) { await dialogService.AlertAsync( new AlertConfig { Title = "Permission Error", Message = $"Permissions not granted: {string.Join(", ", mediaException.Permissions)}", OkText = "OK" }).ConfigureAwait(false); } catch (Exception ex) { // TODO: log the exception... await dialogService.AlertAsync( new AlertConfig { Title = "Error", Message = "An error has occurred.", OkText = "OK" }).ConfigureAwait(false); } }); Save = ReactiveCommand.CreateFromTask(async() => { // TODO:... }); Cancel = ReactiveCommand.CreateFromTask(async() => { await NavigationService.GoBackAsync(useModalNavigation: true).ConfigureAwait(false); }); SelectCommunities = ReactiveCommand.CreateFromTask(async() => { var args = new NavigationParameters(); args.Add( "items", (await projectDataStore.GetTradesAsync()).Select(specialty => new SelectionViewModel <Trade>(specialty) { DisplayValue = specialty.Name })); await NavigationService.NavigateAsync(nameof(MultiSelectListViewPage), args).ConfigureAwait(false); }); }