示例#1
0
        public ProfileMainPage()
        {
            instance = this;
            InitializeComponent();
            mainModel = MainViewModel.Getinstance();
            UserData  = mainModel.Usuario;

            menulist = new ObservableCollection <ProfileMainPageMenuItem>(new[]
            {
                new ProfileMainPageMenuItem {
                    Id = 0, Title = "Current Trip", Color = "Black", VOptions = "Start", TextAlign = "Left"
                },
                new ProfileMainPageMenuItem {
                    Id = 1, Title = "Sales Available", Color = "Black", VOptions = "Start", TextAlign = "Left"
                },
                new ProfileMainPageMenuItem {
                    Id = 2, Title = $"Completed Services: {UserData.ViajesTotales}", Color = "Black", VOptions = "Start", TextAlign = "Left"
                }
            });
            Label prop = (Label)MasterPage.FindByName("userName");

            prop.Text = UserData.Nombre;
            Label propD = (Label)MasterPage.FindByName("memberDate");

            propD.Text = "member since: " + UserData.FechaAlta;

            MasterPage.ListView.ItemsSource   = menulist;
            MasterPage.ListView.ItemSelected += ListView_ItemSelectedAsync;

            CrossConnectivity.Current.ConnectivityChanged += Current_ConnectivityChanged;

            verifyTirpInstance();
        }
示例#2
0
 public static ProfileMainPage Getinstance()
 {
     if (instance == null)
     {
         instance = new ProfileMainPage();
     }
     return(instance);
 }
示例#3
0
        private async void ListView_ItemSelectedAsync(object sender, SelectedItemChangedEventArgs e)
        {
            var item = e.SelectedItem as ProfileMainPageMenuItem;

            if (item == null)
            {
                return;
            }
            var page = (Page)Activator.CreateInstance(item.TargetType);

            if (item.Id == 0)
            {
                var venta = MainViewModel.Getinstance().Venta;
                if (venta != null)
                {
                    page = new MainPage(venta);

                    page.Title = item.Title;

                    Detail = new NavigationPage(page);
                }
                else
                {
                    await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Failed operation", "Theres no trip linked to current user.", "Dismiss");
                }
                IsPresented = false;
            }
            if (item.Id == 1)
            {
                mainModel.Ventas = new VentasViewModel();
                ProfileMainPage.Getinstance().Detail = new NavigationPage(new ProfileMainPageDetail());

                IsPresented = false;
            }
            MasterPage.ListView.SelectedItem = null;
        }