Exemplo n.º 1
0
        public override async Task InitializeAsync(Func <bool, Task> setBusy)
        {
            await base.InitializeAsync(setBusy);

            var sessionState = await _sessionStateManager.GetSessionState();

            NavigationMenuModelManager.Update(_viewModelRepository.CreateViewModel <NavMenuViewModel>(this, (nm) => nm.InitializeMenu(NavigationItems, sessionState)));
        }
Exemplo n.º 2
0
        public override async Task HandleChanges(object sender, object changes)
        {
            if (changes is ISessionState sessionState)
            {
                var navigationItems = NavigationItems;
                // We'd usually do some proper login checks here!
                if (sessionState.IsLoggedIn)
                {
                    navigationItems.Add(new Navigation(() => ContentViewModelManager.Update(_viewModelRepository.CreateViewModel <RegisterRecipeViewModel>(this)), "Register Recipe"));
                    navigationItems.Add(new Navigation(() => ContentViewModelManager.Update(_viewModelRepository.CreateViewModel <RecipeSummaryViewModel>(this, m => m.InitializeComponents(sessionState.Recipes))), "Your Recipes"));
                    InformationViewModelManager.Update(_viewModelRepository.CreateViewModel <InformationViewModel>(this, (vm) => vm.OrganisationName = sessionState.Organisation.OrganisationName));
                }
                else
                {
                    InformationViewModelManager.Update(_viewModelRepository.CreateViewModel <InformationViewModel>(this, (vm) => vm.OrganisationName = string.Empty));
                }

                Debug.WriteLine("NavigationMenuModel.UpdateMenu state : " + sessionState.AccessKey);
                await Task.Run(() => NavigationMenuModelManager.Update(_viewModelRepository.CreateViewModel <NavMenuViewModel>(this, (nm) => nm.InitializeMenu(navigationItems, sessionState))));

                Debug.WriteLine("No SessionStateManager_SessionUpdated state ends");
            }
        }