Ejemplo n.º 1
0
        public AboutPage(AboutPageVM vm)
        {
            VM             = vm ?? new AboutPageVM();
            BindingContext = VM;
            Title          = "About";
            var testo = new Label
            {
                Text = "" +
                       "Questa app è stata realizzata grazie al lavoro degli studenti che hanno partecipato al corso di Xamarin tenuto dal Dott. Luca Pisano nell'a.a. 2016-2017"
                       + Environment.NewLine + Environment.NewLine +
                       "Si ringrazia il team del Luiss Loft per la collaborazione offerta e la Luiss Guido Carli per l'opportunità"
            };
            var scrollVerticale = new ScrollView {
                Orientation = ScrollOrientation.Vertical,
                Content     = testo,
            };

            var stackImmagini = new StackLayout {
                Orientation = StackOrientation.Vertical
            };

            var listaImg = new ListView();

            listaImg.ItemTemplate = new DataTemplate(typeof(PersonCellView));
            listaImg.SetBinding(ListView.ItemsSourceProperty, new Binding(nameof(AboutPageVM.Utenti)));
            listaImg.SetBinding(ListView.IsRefreshingProperty, new Binding(nameof(ViewModelBase.IsLoadingData)));

            var griglia = new Grid {
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition {
                        Height = new GridLength(0.5, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(0.5, GridUnitType.Star)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection {
                    new ColumnDefinition {
                        Width = GridLength.Star
                    }
                }
            };

            griglia.AddChild(scrollVerticale, 0, 0);
            griglia.AddChild(listaImg, 1, 0);

            Content = griglia;
        }
Ejemplo n.º 2
0
        public MasterPage(MasterPageVM vm)
        {
            VM             = vm ?? new MasterPageVM();
            BindingContext = VM;
            Title          = "Menu";
            Icon           = "menu";

            var buttLogin = new Button
            {
                Command = new Command(async() =>
                {
                    if (VM.IsLogged == false)
                    {
                        var pageVM = new LoginPageVM();
                        pageVM.DownloadData().ContinueWith((arg) => { pageVM.UpdateVM(); });
                        pageVM.Completed += async(object sender, User e) =>
                        {
                            //detail = profilePage
                            GoToEventsPage();
                        };
                        VM.Navigation = new NavigationPage(new LoginPageView(pageVM));
                    }
                    else
                    {
                        //doing logout
                        App.VM.user = null;
                        await App.VM.Settings.Save();
                    }
                })
            };

            //buttLogin.SetBinding(View.IsVisibleProperty, new Binding(nameof(MasterPageVM.IsLogged), BindingMode.Default, new NegateBooleanConverter()));
            buttLogin.SetBinding(Button.TextProperty, new Binding(nameof(MasterPageVM.IsLoggedString)));

            var userImg = new Image {
                HeightRequest = 64, WidthRequest = 64
            };

            userImg.Bind(nameof(MasterPageVM.UserImg));

            var userName = new Label {
                HorizontalTextAlignment = TextAlignment.Center,
                HorizontalOptions       = LayoutOptions.Center
            };

            userName.Bind(nameof(MasterPageVM.UserName), true);

            var buttonCalendario = new Button {
                Text = "Prenotazione"
            };

            buttonCalendario.Clicked += delegate {
                var pageVM = new CalendarioPageVM();
                pageVM.DownloadData().ContinueWith(delegate {
                    pageVM.UpdateVM();
                });
                VM.Navigation = new NavigationPage(new CalendarioPage(pageVM));
            };

            var buttonAbout = new Button
            {
                Text = "About"
            };

            buttonAbout.Clicked += (sender, e) => {
                var pageVM = new AboutPageVM();
                pageVM.DownloadData().ContinueWith(delegate
                {
                    pageVM.UpdateVM();
                });
                VM.Navigation = new NavigationPage(new AboutPage(pageVM));
            };

            Content = new StackLayout {
                Children =
                {
                    new BoxView {
                        HeightRequest = 20, Color = Color.Transparent, BackgroundColor = Color.Transparent
                    },
                    userImg,
                    userName,
                    buttLogin,
                    new Button  {
                        Text = "Eventi", Command = new Command(() =>{
                            GoToEventsPage();
                        })
                    },
                    buttonCalendario,
                    buttonAbout,
                }
            };
        }