StackLayout CreateForecastStatusStackLayout()
        {
            var daysLabel = new ExtraLargeLabel {
                HorizontalOptions = LayoutOptions.Center
            };

            daysLabel.SetBinding <ForecastViewModel> (Label.TextProperty, vm => vm.DaysClean);
            daysLabel.TextColor = GetDaysCleanTextColor(_forecast.DaysClean);

            var daysTextLabel = new LargeLabel {
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            daysTextLabel.SetBinding <ForecastViewModel> (Label.TextProperty, vm => vm.DaysText);

            var horizontalStackLayout = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Start,
                Padding           = new Thickness(40, 0, 0, 0)
            };


            horizontalStackLayout.Children.Add(new LargeLabel {
                Text            = "Clean for ",
                VerticalOptions = LayoutOptions.CenterAndExpand
            });
            horizontalStackLayout.Children.Add(daysLabel);
            horizontalStackLayout.Children.Add(daysTextLabel);

            return(horizontalStackLayout);
        }
示例#2
0
        private async Task Init(GeoLocation geoLocation)
        {
            var location = new Position(geoLocation.Latitude, geoLocation.Longitude);

            var map = new CustomMap(MapSpan.FromCenterAndRadius(location, Distance.FromMiles(5)))
            {
                IsShowingUser = true
            };

            //Show current location for Win Phone
            if (Device.OS == TargetPlatform.WinPhone)
            {
                map.CustomPins.Add(new CustomPin {
                    Position = location,
                    Label    = "Current Location"
                });
            }


            //Add the car wash pins
            Task.Run(async() => {
                var carWashPins = await _viewModel.GetMapPinsAsync();

                Device.BeginInvokeOnMainThread(() => {
                    foreach (var carWashPin in carWashPins)
                    {
                        map.CustomPins.Add(carWashPin);
                    }
                });
            });

            var selectedPinLabel = new LargeLabel {
                HorizontalOptions = LayoutOptions.Center, TextColor = Color.Black
            };

            selectedPinLabel.BindingContext = map;
            selectedPinLabel.SetBinding <CustomMap> (Label.TextProperty, vm => vm.SelectedPin.Label);

            var selectedPinAddress = new Label {
                HorizontalOptions = LayoutOptions.Center, TextColor = Color.Black
            };

            selectedPinAddress.BindingContext = map;
            selectedPinAddress.SetBinding <CustomMap> (Label.TextProperty, vm => vm.SelectedPin.Address);

            var stack = new StackLayout {
                Spacing = 0, BackgroundColor = Color.FromHex("#ecf0f1")
            };

            map.VerticalOptions = LayoutOptions.FillAndExpand;

            stack.Children.Add(map);
            stack.Children.Add(selectedPinLabel);
            stack.Children.Add(selectedPinAddress);

            Content = stack;
        }
		private async Task Init (GeoLocation geoLocation)
		{
			var location = new Position (geoLocation.Latitude, geoLocation.Longitude);

			var map = new CustomMap (MapSpan.FromCenterAndRadius (location, Distance.FromMiles (5))) {
				IsShowingUser = true
			};
      
			//Show current location for Win Phone
			if (Device.OS == TargetPlatform.WinPhone) {
				map.CustomPins.Add (new CustomPin {
					Position = location,
					Label = "Current Location"
				});
			}


			//Add the car wash pins
			Task.Run (async () => {
				var carWashPins = await _viewModel.GetMapPinsAsync ();

				Device.BeginInvokeOnMainThread (() => {
					foreach (var carWashPin in carWashPins) {
						map.CustomPins.Add (carWashPin);
					}

				});
			});

			var selectedPinLabel = new LargeLabel { HorizontalOptions = LayoutOptions.Center, TextColor = Color.Black };

			selectedPinLabel.BindingContext = map;
			selectedPinLabel.SetBinding<CustomMap> (Label.TextProperty, vm => vm.SelectedPin.Label);

			var selectedPinAddress = new Label { HorizontalOptions = LayoutOptions.Center, TextColor = Color.Black };

			selectedPinAddress.BindingContext = map;
			selectedPinAddress.SetBinding<CustomMap> (Label.TextProperty, vm => vm.SelectedPin.Address);

			var stack = new StackLayout { Spacing = 0,  BackgroundColor = Color.FromHex ("#ecf0f1") };

			map.VerticalOptions = LayoutOptions.FillAndExpand;

			stack.Children.Add (map);
			stack.Children.Add (selectedPinLabel);
			stack.Children.Add (selectedPinAddress);

			Content = stack;
		}
示例#4
0
        public LoadingPage(RootPage rootPage)
        {
            _rootPage = rootPage;
            NavigationPage.SetHasNavigationBar(this, false);

            //TODO : Inject ForecastService

            _viewModel     = new LoadingViewModel(Navigation, new ForecastService(new OpenWeatherMapService(new HttpClient())), rootPage);
            BindingContext = _viewModel;

            var statusMessageLabel = new LargeLabel {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                TextColor         = Color.White,
            };

            statusMessageLabel.SetBinding <LoadingViewModel> (Label.TextProperty, vm => vm.StatusMessage);

            var stackLayout = new StackLayout {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Spacing           = 10
            };

            var loadingImage = new Image();

            loadingImage.SetBinding <LoadingViewModel> (Image.SourceProperty, vm => vm.LoadingImage);

            var refreshButton = new Button {
                Text = "Refresh", HorizontalOptions = LayoutOptions.Center
            };

            refreshButton.SetBinding <LoadingViewModel> (Button.CommandProperty, vm => vm.GetForecastCommand);
            refreshButton.SetBinding <LoadingViewModel> (VisualElement.IsVisibleProperty, vm => vm.IsRefreshButtonVisible);

            var activityIndicator = new ActivityIndicator {
                IsRunning = true
            };

            activityIndicator.SetBinding <LoadingViewModel> (VisualElement.IsVisibleProperty, vm => vm.IsActivityIndicatorVisible);

            stackLayout.Children.Add(loadingImage);
            stackLayout.Children.Add(statusMessageLabel);
            stackLayout.Children.Add(activityIndicator);
            stackLayout.Children.Add(refreshButton);

            Content = stackLayout;
        }
示例#5
0
        public LoadingPage(RootPage rootPage)
        {
            _rootPage = rootPage;
            NavigationPage.SetHasNavigationBar (this, false);

            //TODO : Inject ForecastService

            _viewModel = new LoadingViewModel (Navigation, new ForecastService (new OpenWeatherMapService (new HttpClient ())), rootPage);
            BindingContext = _viewModel;

            var statusMessageLabel = new LargeLabel {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center,
                TextColor = Color.White,
            };

            statusMessageLabel.SetBinding<LoadingViewModel> (Label.TextProperty, vm => vm.StatusMessage);

            var stackLayout = new StackLayout {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center,
                Spacing = 10
            };

            var loadingImage = new Image ();

            loadingImage.SetBinding<LoadingViewModel> (Image.SourceProperty, vm => vm.LoadingImage);

            var refreshButton = new Button{ Text = "Refresh", HorizontalOptions = LayoutOptions.Center };

            refreshButton.SetBinding<LoadingViewModel> (Button.CommandProperty, vm => vm.GetForecastCommand);
            refreshButton.SetBinding<LoadingViewModel> (VisualElement.IsVisibleProperty, vm => vm.IsRefreshButtonVisible);

            var activityIndicator = new ActivityIndicator{ IsRunning = true };

            activityIndicator.SetBinding<LoadingViewModel> (VisualElement.IsVisibleProperty, vm => vm.IsActivityIndicatorVisible);

            stackLayout.Children.Add (loadingImage);
            stackLayout.Children.Add (statusMessageLabel);
            stackLayout.Children.Add (activityIndicator);
            stackLayout.Children.Add (refreshButton);

            Content = stackLayout;
        }