示例#1
0
        public HomePage(Page page = null)
        {
            try
            {
                Instance = this;
                InitializeComponent();

                NavigationHandler.SetMasterPage(this);
                var servicesTabPage = new DashboardPage();
                this.Detail = new NavigationPage(servicesTabPage)
                {
                    BarTextColor = Color.White
                };
                mAppServices = DependencyService.Get <IAppServices>();

                this.PropertyChanged += (sender, e) =>
                {
                    try
                    {
                        if (e.PropertyName == nameof(this.Detail))
                        {
                            mAppServices.SetNetworkBar(false);
                        }
                    }
                    catch (Exception e1)
                    {
                        ExceptionHandler.Catch(e1);
                    }
                };

                if (Shared.IsLoggedIn &&
                    Shared.UserId == -1)
                {
                    var userModel = Shared.APIs.IUsers.GetCurrentUser();
                    Shared.UserId = userModel.ID;
                }

                masterPage.ListView.ItemTapped += ListView_ItemTapped;

                this.IsPresentedChanged += (sender, e) =>
                {
                    try
                    {
                        if (IsPresented)
                        {
                            var itemsSource = masterPage.ListView.ItemsSource;
                            masterPage.ListView.ItemsSource = null;
                            masterPage.ListView.ItemsSource = itemsSource;
                        }
                    }
                    catch (Exception e1)
                    {
                        ExceptionHandler.Catch(e1);
                    }
                };
            }
            catch (Exception e)
            {
                ExceptionHandler.Catch(e);
            }
        }