Example #1
0
        public async Task NavigateAsync(int menuId)
        {
            ASENavigationPage newPage = null;

            if (!pages.ContainsKey(menuId))
            {
                //only cache specific pages
                switch (menuId)
                {
                case (int)AppPage.StorageAccounts:
                    pages.Add(menuId, new ASENavigationPage(new StorageAccountsPage()));
                    break;

                case (int)AppPage.Subscriptions:
                    pages.Add(menuId, new ASENavigationPage(new SubscriptionsPage()));
                    break;

                case (int)AppPage.Containers:
                    pages.Add(menuId, new ASENavigationPage(new ContainersPage()));
                    break;

                case (int)AppPage.Queues:
                    pages.Add(menuId, new ASENavigationPage(new QueuesPage()));
                    break;

                case (int)AppPage.Tables:
                    newPage = new ASENavigationPage(new TablesPage());
                    break;

                case (int)AppPage.FileShares:
                    newPage = new ASENavigationPage(new FileSharesPage());
                    break;

                case (int)AppPage.Settings:
                    newPage = new ASENavigationPage(new SettingsPage());
                    break;
                }
            }

            if (newPage == null)
            {
                newPage = pages[menuId];
            }

            if (newPage == null)
            {
                return;
            }

            //if we are on the same tab and pressed it again.
            if (Detail == newPage)
            {
                await newPage.Navigation.PopToRootAsync();
            }

            Detail = newPage;
        }
Example #2
0
        public App()
        {
            current = this;

            InitializeComponent();
            ViewModelBase.Init();
            switch (Device.RuntimePlatform)
            {
            case Device.Android:
                MainPage = new RootPageAndroid();
                break;

            case Device.iOS:
                MainPage = new ASENavigationPage(new RootPageiOS());
                break;

            default:
                throw new NotImplementedException();
            }
        }
Example #3
0
        protected override void OnResume()
        {
            // Handle when your app resumes
            Settings.Current.IsConnected = CrossConnectivity.Current.IsConnected;
            CrossConnectivity.Current.ConnectivityChanged += ConnectivityChanged;

            MessagingService.Current.Subscribe <MessagingServiceAlert>(MessageKeys.Message, async(m, info) =>
            {
                var task = Application.Current?.MainPage?.DisplayAlert(info.Title, info.Message, info.Cancel);
                if (task == null)
                {
                    return;
                }
                await task;
                info?.OnCompleted?.Invoke();
            });

            MessagingService.Current.Subscribe <MessagingServiceQuestion>(MessageKeys.Question, async(m, q) =>
            {
                var task = Application.Current?.MainPage?.DisplayAlert(q.Title, q.Question, q.Positive, q.Negative);
                if (task == null)
                {
                    return;
                }
                var result = await task;
                q?.OnCompleted?.Invoke(result);
            });

            MessagingService.Current.Subscribe(MessageKeys.NavigateLogin, async m =>
            {
                if (Device.RuntimePlatform == Device.Android)
                {
                    ((RootPageAndroid)MainPage).IsPresented = false;
                }
                Page page = null;

                if (Settings.Current.FirstRun && Device.RuntimePlatform == Device.Android)
                {
                    page = new ASENavigationPage(new LoginPage());
                }
                else
                {
                    page = new ASENavigationPage(new LoginPage());
                }

                var nav = Application.Current?.MainPage?.Navigation;
                if (nav == null)
                {
                    return;
                }

                await NavigationService.PushModalAsync(nav, page);
            });

            try
            {
                if (firstRun)
                {
                    DependencyService.Get <ISignOnClient>().LogoutAsync();
                }
                if (firstRun || Device.RuntimePlatform != Device.iOS)
                {
                    return;
                }
                var mainNav = MainPage as NavigationPage;
                if (mainNav == null)
                {
                    return;
                }
                var rootPage = mainNav.CurrentPage as RootPageiOS;
                if (rootPage == null)
                {
                    return;
                }
                var rootNav = rootPage.CurrentPage as NavigationPage;
                if (rootNav == null)
                {
                    return;
                }
            }
            catch
            {
            }
            finally
            {
                firstRun = false;
                Settings.Current.FirstRun = false;

#if __IOS__
                Popup.Init();
#endif
            }
        }