public GroupPage(RootPage rootPage) { _rootPage = rootPage; NavigationPage.SetHasNavigationBar (this, false); //TODO : Inject Groups _db = new GroupsterDatabase(); _viewModel = new GroupLoadingViewModel (Navigation, _db.GetItems<Group>(), rootPage); BindingContext = _viewModel; var statusMessageLabel = new LargeLabel { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, TextColor = Color.White, }; statusMessageLabel.SetBinding<GroupLoadingViewModel> (Label.TextProperty, vm => vm.StatusMessage); var stackLayout = new StackLayout { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Spacing = 10 }; var loadingImage = new Image (); loadingImage.SetBinding<GroupLoadingViewModel> (Image.SourceProperty, vm => vm.LoadingImage); var refreshButton = new Button{ Text = "Refresh", HorizontalOptions = LayoutOptions.Center }; refreshButton.SetBinding<GroupLoadingViewModel> (Button.CommandProperty, vm => vm.GetGroupCommand); refreshButton.SetBinding<GroupLoadingViewModel> (VisualElement.IsVisibleProperty, vm => vm.IsRefreshButtonVisible); var activityIndicator = new ActivityIndicator{ IsRunning = true }; activityIndicator.SetBinding<GroupLoadingViewModel> (VisualElement.IsVisibleProperty, vm => vm.IsActivityIndicatorVisible); stackLayout.Children.Add (loadingImage); stackLayout.Children.Add (statusMessageLabel); stackLayout.Children.Add (activityIndicator); stackLayout.Children.Add (refreshButton); Content = stackLayout; }
public LoadingViewModel (INavigation navigation, IForecastService forecastService, RootPage rootPage) { this.rootPage = rootPage; _navigation = navigation; _forecastService = forecastService; LoadingImage = "Radar.png"; IsRefreshButtonVisible = false; IsActivityIndicatorVisible = false; Setup (); if (_geolocator.IsGeolocationEnabled) { GetForecastAsync (); } else { StatusMessage = "GPS is disabled, please enable GPS and refresh."; IsRefreshButtonVisible = true; } }
public ForecastPage(RootPage rootPage, Forecast forecast) { this._rootPage = rootPage; _forecast = forecast; BindingContext = new ForecastViewModel (Navigation, _forecast); NavigationPage.SetHasNavigationBar (this, false); var masterGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition{ Height = new GridLength (0.3, GridUnitType.Star) }, new RowDefinition{ Height = new GridLength (0.3, GridUnitType.Star) }, new RowDefinition{ Height = new GridLength (0.4, GridUnitType.Star) } }, ColumnDefinitions = new ColumnDefinitionCollection{ new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) } } }; var forecastListview = new ListView (); var forecastListviewItemTemplate = new DataTemplate (typeof(ImageCell)); forecastListviewItemTemplate.SetBinding (ImageCell.TextProperty, "ItemTemplateTextProperty"); forecastListviewItemTemplate.SetValue(ImageCell.TextColorProperty, Color.FromHex("#3498DB")); forecastListviewItemTemplate.SetBinding (ImageCell.DetailProperty, "ItemTemplateDetailProperty"); forecastListviewItemTemplate.SetValue(ImageCell.DetailColorProperty, Color.White); forecastListviewItemTemplate.SetBinding (ImageCell.ImageSourceProperty, "Icon"); forecastListview.ItemTemplate = forecastListviewItemTemplate; forecastListview.SetBinding<ForecastViewModel> (ListView.ItemsSourceProperty, vm => vm.GroupList); var refreshImage = new ImageButton () { Image = "Refresh", ImageHeightRequest = 70, ImageWidthRequest = 70, BorderColor = Color.Transparent, VerticalOptions = LayoutOptions.Start, BackgroundColor = Color.Transparent }; refreshImage.Clicked += (object sender, EventArgs e) => { /*_rootPage.ShowLoadingDialogAsync ();*/ }; var topGrid = new Grid {RowDefinitions = new RowDefinitionCollection { new RowDefinition{ Height = new GridLength (1, GridUnitType.Star) } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition{ Width = new GridLength (0.8, GridUnitType.Star) }, new ColumnDefinition{ Width = new GridLength (0.2, GridUnitType.Star) }, } }; topGrid.Children.Add (CreateForecastStatusStackLayout (), 0, 0); topGrid.Children.Add (refreshImage, 1, 0); masterGrid.Children.Add (topGrid, 0, 0); masterGrid.Children.Add (CreateMiddleStackLayout (), 0, 1); masterGrid.Children.Add (forecastListview, 0, 2); Content = masterGrid; }
public LoginPage (RootPage rootPage) { this._rootPage = rootPage; _db = new GroupsterDatabase(); _viewModel = new LoginViewModel (Navigation, new User(), rootPage); BindingContext = _viewModel; Padding = 0; // Create layout and bind where appropriate. var loginMessageLabel = new LargeLabel { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, HeightRequest = 50, TextColor = Color.White, Text = "Welcome to Groupster", FontSize = 30 //Device.GetNamedSize(NamedSize.Large, typeof(Label)) }; BackgroundColor = AppColors.BaseColor; var loginImage = new Image (); loginImage.SetBinding<LoginViewModel> (Image.SourceProperty, vm => vm.LoginImage); var usernameEntry = new Entry { Placeholder = "Email", }; usernameEntry.SetBinding(Entry.TextProperty, "UserNameMessage"); var passwordEntry = new Entry { Placeholder = "Password", IsPassword = true }; passwordEntry.SetBinding(Entry.TextProperty, "PasswordMessage"); var switchLabel = new Label { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, Text = "Remember Me?", }; var rememberMeOption = new CheckBox { BackgroundColor = AppColors.BaseColor }; rememberMeOption.SetBinding(CheckBox.CheckedProperty, "RememberMe"); var switchStackLayout = new StackLayout { HorizontalOptions = LayoutOptions.Center, Spacing = 10, Orientation = StackOrientation.Horizontal, Children = { switchLabel, rememberMeOption } }; var loginButton = new Button { Text = "Login", HorizontalOptions = LayoutOptions.Center, BackgroundColor = AppColors.Button }; loginButton.Clicked += LogMeIn; // var registerButton = new Button { // Text = "Close", // HorizontalOptions = LayoutOptions.Center // }; // // var buttonLayout = new StackLayout { // HorizontalOptions = LayoutOptions.Center, // Spacing = 10, // Orientation = StackOrientation.Horizontal, // Children = { // loginButton, // registerButton // } // }; var registerLabel = new Label { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.End, HeightRequest = 40, Text = "New to Groupster?", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; var registerLink = new Label { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.End, HeightRequest = 40, Text = "Register here", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), FontAttributes = FontAttributes.Italic }; // var registerLink = new Button { // Text = "Register here", // HorizontalOptions = LayoutOptions.Center, // VerticalOptions = LayoutOptions.End, // HeightRequest = 20, // FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), // FontAttributes = FontAttributes.Italic, // BackgroundColor = AppColors.BaseColor, // TextColor = Color.Default // }; // // registerLink.Clicked += RegisterMe; var registerLayout = new StackLayout { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand, Spacing = 10, Orientation = StackOrientation.Horizontal, Children = { new Label{}, registerLabel, registerLink } }; var stackLayout = new StackLayout { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Spacing = 10, }; stackLayout.Children.Add (loginMessageLabel); stackLayout.Children.Add (loginImage); stackLayout.Children.Add (usernameEntry); stackLayout.Children.Add (passwordEntry); stackLayout.Children.Add (switchStackLayout); stackLayout.Children.Add (loginButton); stackLayout.Children.Add (registerLayout); Content = stackLayout; }