Ejemplo n.º 1
0
 /// <summary>
 /// Called when a this instance becomes the active content in a frame.
 /// </summary>
 /// <param name="e">An object that contains the navigation data.</param>
 public void OnNavigatedTo(NavigationEventArgs e)
 {
     if (NavigatedTo != null)
     {
         NavigatedTo.Invoke(this, e);
     }
 }
        public MultiSelectListViewPageViewModel(INavigationService navigationService) : base(navigationService)
        {
            SelectAll = ReactiveCommand.Create(() =>
            {
                foreach (var item in Items)
                {
                    item.IsSelected = true;
                }
            });

            SelectNone = ReactiveCommand.Create(() =>
            {
                foreach (var item in Items)
                {
                    item.IsSelected = false;
                }
            });

            NavigatedTo
            .Select(args => (IEnumerable <SelectionViewModel>)args["items"])
            .Subscribe(items => Items.AddRange(items));

            NavigatedFrom
            .Subscribe(args => args.Add("selected_items", Items.Where(item => item.IsSelected).ToList()));
        }
Ejemplo n.º 3
0
        public void OnNavigatedTo(Navigation Navigation)
        {
            if (IsDisposing)
            {
                return;
            }

            Info(string.Format("Navigated to: {0}", Navigation));
            NavigatedTo?.Invoke(this, new CodeProjectNavigationEventArgs(Navigation));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Raises the <see cref="NavigatedTo"/> event.
        /// </summary>
        /// <param name="e">The <see cref="NavigatedEventArgs"/> instance containing the event data.</param>
        protected void RaiseNavigatedTo(NavigatedEventArgs e)
        {
            if (!CanHandleNavigation())
            {
                return;
            }

            Log.Debug("Navigated to '{0}'", NavigationTargetType);

            DetermineNavigationContext();

            NavigatedTo.SafeInvoke(this, e);
        }
        public ProjectFilterPageViewModel(
            INavigationService navigationService,
            IProjectDataStore projectDataStore) : base(navigationService)
        {
            Title = "Filter";

            Apply = ReactiveCommand.CreateFromTask(async() =>
            {
                _filter.StartDate           = _selectedStartDate;
                _filter.StartDateComparison = _selectedStartDateComparisonType;

                _filter.Trades.Clear();
                _filter.Trades.AddRange(_selectedTrades);

                await NavigationService.GoBackAsync(new NavigationParameters
                {
                    { "filter", _filter }
                },
                                                    useModalNavigation: true).ConfigureAwait(false);
            });

            Cancel = ReactiveCommand.CreateFromTask(() => NavigationService.GoBackAsync(useModalNavigation: true));

            NavigatedTo
            .Where(args => args.ContainsKey("filter"))
            .Take(1)
            .Select(args => (ProjectFilter)args["filter"])
            .Subscribe(filter => _filter = filter);

            NavigatedTo
            .Where(args => args.ContainsKey("selected_items"))
            .Select(args => (IEnumerable <SelectionViewModel>)args["selected_items"])
            .Subscribe(selections => _selectedTrades = selections.Select(x => x.Item).Cast <Trade>());

            // begin loading the trade data
            var trades = projectDataStore.GetTradesAsync();

            SelectTrades = ReactiveCommand.CreateFromTask(async() =>
            {
                var args = new NavigationParameters();
                args.Add(
                    "items",
                    (await trades).Select(specialty => new SelectionViewModel <Trade>(specialty)
                {
                    DisplayValue = specialty.Name,
                    IsSelected   = _selectedTrades?.Contains(specialty) == true
                }));

                await NavigationService.NavigateAsync(nameof(MultiSelectListViewPage), args).ConfigureAwait(false);
            });
        }
Ejemplo n.º 6
0
        public TestNavigationViewModel()
        {
            NavigatedTo
            .ToProperty(this, nameof(NavigatedToParameter), out _navigatedToParameter)
            .DisposeWith(Garbage);

            NavigatedFrom
            .ToProperty(this, nameof(NavigatedFromParameter), out _navigatedFromParameter)
            .DisposeWith(Garbage);

            NavigatingTo
            .ToProperty(this, nameof(NavigatingToParameter), out _navigatingToParameter)
            .DisposeWith(Garbage);
        }
Ejemplo n.º 7
0
        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;
            });
        }
Ejemplo n.º 8
0
        private async Task NavigateIntenal(object viewModel)
        {
            NavigationStarted?.Invoke(viewModel);

            var request = new NavigationRequest(viewModel);

            NavigationRequested?.Invoke(this, request);

            if (request.NavigationTasks != null)
            {
                await Task.WhenAll(request.NavigationTasks);
            }

            NavigatedTo?.Invoke(viewModel);
        }
Ejemplo n.º 9
0
        public async Task NavigateTo(PageType pageType, object parameter = null)
        {
            string routeId;

            switch (pageType)
            {
            case PageType.Location:
                routeId = "//summary/location";
                break;

            case PageType.Options:
                routeId = "//options";
                break;

            default:
                throw new NotImplementedException(nameof(pageType));
            }
            NavigatedTo?.Invoke(this, new NavigatedToEventArgs(pageType, parameter));
            await Shell.Current.GoToAsync(routeId);
        }
        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;
            });
        }
Ejemplo n.º 11
0
 internal void SendNavigatedTo(NavigatedToEventArgs args)
 {
     NavigatedTo?.Invoke(this, args);
     OnNavigatedTo(args);
 }
        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);
            });
        }
Ejemplo n.º 13
0
 void OnNavigatedTo(NavigatedArgs e)
 {
     NavigatedTo?.Invoke(this, e);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Handles the <see cref="E:NavigatedTo"/> event.
 /// </summary>
 /// <param name="e">The <see cref="FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs"/> instance containing the event data.</param>
 public void OnNavigatedTo(NavigationEventArgs e)
 {
     NavigatedTo?.Invoke(this, e);
 }