Exemple #1
0
        public TripPage(MbtaRoutePrediction selectedRoute, MbtaPrediction singlePrediction, Geolocator.Plugin.Abstractions.Position currentLocation)
        {
            this.selectedRoute = selectedRoute;
            this.singlePrediction = singlePrediction;
            this.currentLocation = currentLocation;

            var mapPosition = new Position (currentLocation.Latitude, currentLocation.Longitude);
            currentSpan = MapSpan.FromCenterAndRadius(mapPosition, Distance.FromMiles(0.3));
            map = new Map (currentSpan) {
                IsShowingUser = true,
                HeightRequest = 100,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            var stack = new StackLayout { Spacing = 0 };
            stack.Children.Add(map);
            Content = stack;

            FetchPredictions ();
        }
        public StopRoutePredictionPage(MbtaRoutePrediction selectedRoute, Position currentLocation)
        {
            Title = selectedRoute.RouteName;
            this.currentLocation = currentLocation;

            var routeLabel = new Label {
                HorizontalOptions = LayoutOptions.Start,
                FontSize = 44,
                YAlign = TextAlignment.Center,
                Text = selectedRoute.RouteName
            };

            var stopLabel = new Label {
                HorizontalOptions = LayoutOptions.Start,
                YAlign = TextAlignment.Start,
                Text = selectedRoute.StopName,
                LineBreakMode = LineBreakMode.WordWrap
            };
            var predictionList = new ListView {
                HasUnevenRows = true,
                VerticalOptions = LayoutOptions.Start
            };
            predictionList.ItemsSource = selectedRoute.Predictions;
            predictionList.ItemTemplate = new DataTemplate (typeof(SingleCellPredictionCell));

            Content = new StackLayout {
                Orientation = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.Start,
                Padding = new Thickness (9, 6, 9, 6),
                Children = { routeLabel, stopLabel, predictionList }
            };

            predictionList.ItemSelected += async (sender, e) => {
                MbtaPrediction singlePrediction = e.SelectedItem as MbtaPrediction;
                var tripPrediction = new TripPage (selectedRoute, singlePrediction, currentLocation);
                await Navigation.PushAsync (tripPrediction, true);
            };
        }