Ejemplo n.º 1
0
        //public ICommand LoadCommand { get; }

        #endregion


        #region Methods

        private void LoadDatas()
        {
            try
            {
                //Load data for this ViewModel (fake)
                Themes = new ObservableCollection <string>(new List <string>()
                {
                    "Acrylic",
                    "AcrylicBlur",
                    "AcrylicDarkBlur",
                    "Dark",
                    "Light"
                });
                TestValue     = 2;
                SelectedTheme = Enum.GetName(typeof(AppTheme), ThemeHelper.GetCurrentTheme());
            }
            catch (Exception ex)
            {
                DialogsService?.Toast(this["Msg_RedToast_Error_Unknown"]);
                Logger.Write(ex);
            }
            finally
            {
            }
        }
        private async Task LoadApplication()
        {
            string error = null;

            try
            {
                SetIsExecuting(true);
                // Manage here any long time initialization (DB, Localisation, etc...)
                StatusLabel = "Chargement du thème...";
                await ThemeHelper.InitTheme();

                await Task.Delay(1000);

                //Fake/Dev init
                StatusLabel = "Chargement de la BDD...";
                await Task.Delay(1000);

                StatusLabel = "Chargement de la langue...";
                await Task.Delay(1000);

                StatusLabel = "Chargement de XXX...";
                await Task.Delay(1000);

                StatusLabel = "Chargement de YYY...";
                await Task.Delay(1000);

                StatusLabel = "Lancement de l'application...";
                await Task.Delay(1000);

                // Manage startup navigation logic (ConfigPage or LoginProcess or HomePage or whatever...)
                string nextPage;
                //if (SettingsService.IsUserLogged())
                //{
                nextPage = $"{nameof(App)}:///{nameof(MDPage)}/{nameof(NavigationPage)}/{nameof(HomePage)}";
                //}
                //else
                //{
                //    mainPage = $"/{nameof(LoginPage)}";
                //}

                await Device.InvokeOnMainThreadAsync(async() => await NavigationService.NavigateAsync(nextPage));
            }
            catch (Exception ex)
            {
                error = this["Msg_RedToast_Error_Unknown"];
                Logger.Write(ex);
            }
            finally
            {
                if (!string.IsNullOrWhiteSpace(error))
                {
                    DialogsService?.Toast(error);
                    HasFailedOnce = true;
                }
                SetIsExecuting(false);
            }
        }
Ejemplo n.º 3
0
        private async Task LoadDatas()
        {
            try
            {
                //Load data for this ViewModel (fake)
                await Task.Delay(1000);

                Property1 = "Toto";
                await Task.Delay(1000);
            }
            catch (Exception ex)
            {
                DialogsService?.Toast(this["Msg_RedToast_Error_Unknown"]);
                Logger.Write(ex);
            }
            finally
            {
            }
        }
        //public ICommand MenuNavigateCommand { get; }

        #endregion


        #region Methods

        private async Task LogoutUser()
        {
            try
            {
                if (await DialogsService?.ConfirmAsync(this["Msg_Confirm_Disconnect"], this["Msg_Confirm_Title"], this["Msg_Confirm_Ok"], this["Msg_Confirm_Cancel"]))
                {
                    DialogsService.Loading(this["Msg_Loading_Disconnecting"]);
                    await Task.Delay(500);

                    //await DataService.ClearUserDataAsync();
                    SettingsService?.Clear();
                    //_notificationService.Unregister();
                    Logger.Write("LogoutUser", $"Day({DateTime.Now.ToString("yyyy_MM_dd")})");
                    await NavigationService.NavigateAsync($"{nameof(App)}:///{nameof(StartupPage)}");

                    DialogsService.HideLoading();
                }
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
            }
        }
        private async Task LoadDatas()
        {
            try
            {
                //Load data for this ViewModel

                //Get User display
                UserDisplayName = "Prénom Nom";           //SettingsService.UserPrenom + " " + SettingsService.UserNom;
                UserLogin       = "******"; //SettingsService.UserEmail;

                //Create NavigationMenu
                MenuItems = new List <MenuItemModel>
                {
                    new MenuItemModel
                    {
                        Title           = this["HomePage_Title"],
                        ItemImageSource = "ic_home.png",
                        NavigationPath  = $"{nameof(NavigationPage)}/{nameof(HomePage)}"
                    },
                    //Add any new MenuItem in MasterDetail menu
                    //new MenuItemModel
                    //{
                    //    Title = this["NewPage_Title"],
                    //    ItemImageSource = "newpage_icon.png",
                    //    NavigationPath = $"{nameof(NavigationPage)}/{nameof(NewPage)}"
                    //},
                };

#if DEBUG
                MenuItems.Add(new MenuItemModel
                {
                    Title           = this["Debug_BottomTabsPage_Title"],
                    ItemImageSource = "ic_bug_report.png",
                    NavigationPath  = $"{nameof(NavigationPage)}/{nameof(Debug_BottomTabsPage)}?selectedTab={nameof(Debug_ImagesView)}"
                });

                MenuItems.Add(new MenuItemModel
                {
                    Title           = this["WalkThrough_Title"],
                    ItemImageSource = "ic_bug_report.png",
                    NavigationPath  = $"{nameof(WalkThroughPage)}"
                });
#endif

                //await Device.InvokeOnMainThreadAsync(notificationService.RegisterAsync);

                //MessagingCenter.Unsubscribe<object, string>(this, "NotifURL");
                //MessagingCenter.Subscribe<object, string>(this, "NotifURL", async (sender, url) =>
                //{
                //    await NavigationService.NavigateAsync(url);
                //});

                if (SelectedMenuItem == null)
                {
                    SelectedMenuItem = MenuItems.Count > 0 ? MenuItems[0] : null;
                }
            }
            catch (Exception ex)
            {
                DialogsService?.Toast(this["Msg_RedToast_Error_Unknown"]);
                Logger.Write(ex);
            }
            finally
            {
            }
        }