コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: golf1052/LyftApp
        private async Task RefreshRideDetails()
        {
            while (RideState == RideStates.Ride)
            {
                rideDetails = await AppConstants.ShyftClient.RetrieveRideDetails(currentRideId);

                rideStatusBackground.Visibility = Visibility.Visible;
                rideStatusTextBlock.Text        = rideDetails.Status.Humanize(LetterCasing.Title);
                if (rideDetails.Status == LyftConstants.RideStatus.Pending)
                {
                    // Orange
                    rideStatusBackground.Background = new SolidColorBrush(AppConstants.GetColor("#FF8C00"));
                    SetCancelButtonVisibility(rideDetails);
                }
                else if (rideDetails.Status == LyftConstants.RideStatus.Accepted)
                {
                    // Yellow
                    rideStatusBackground.Background = new SolidColorBrush(AppConstants.GetColor("#FFB900"));
                    SetCancelButtonVisibility(rideDetails);
                    SetVehicleInfo(rideDetails);
                }
                else if (rideDetails.Status == LyftConstants.RideStatus.Arrived)
                {
                    // Light Green
                    rideStatusBackground.Background = new SolidColorBrush(AppConstants.GetColor("#00CC6A"));
                    SetCancelButtonVisibility(rideDetails);
                    SetVehicleInfo(rideDetails);
                    UpdateDriverLocation(rideDetails.Location);
                    UpdateRideEtaInfo(rideDetails.Origin);
                }
                else if (rideDetails.Status == LyftConstants.RideStatus.PickedUp)
                {
                    // Pink
                    rideStatusBackground.Background = new SolidColorBrush(AppConstants.LyftPink);
                    SetCancelButtonVisibility(rideDetails);
                    SetVehicleInfo(rideDetails);
                    UpdateDriverLocation(rideDetails.Location);
                    UpdateRideEtaInfo(rideDetails.Destination);
                }
                else if (rideDetails.Status == LyftConstants.RideStatus.DroppedOff)
                {
                    // Blue
                    rideStatusBackground.Background = new SolidColorBrush(AppConstants.LyftMulberry);
                    await SetRideState(RideStates.Complete);
                }
                else if (rideDetails.Status == LyftConstants.RideStatus.Canceled)
                {
                    await SetupPin(RideStates.Pickup, null, rideDetails.Origin);

                    pickupLocation = startLocation.Location.Position;
                    await SetupPin(RideStates.Dropoff, null, rideDetails.Destination);

                    dropoffLocation = endLocation.Location.Position;
                    await SetRideState(RideStates.RideStaging);
                }
                await Task.Delay(TimeSpan.FromMilliseconds(500));
            }
        }
コード例 #2
0
ファイル: MainPage.xaml.cs プロジェクト: golf1052/LyftApp
 private void SetVehicleInfo(RideDetail rideDetails)
 {
     vehicleInfoGrid.Visibility = Visibility.Visible;
     vehicleImage.Source        = new BitmapImage(new Uri(rideDetails.Vehicle.ImageUrl));
     vehicleInfoTextBlock.Text  = $"{rideDetails.Vehicle.Year} {rideDetails.Vehicle.Color} {rideDetails.Vehicle.Make} {rideDetails.Vehicle.Model}\n" +
                                  $"{rideDetails.Vehicle.LicensePlateState} {rideDetails.Vehicle.LicensePlate}";
     if (!string.IsNullOrEmpty(rideDetails.BeaconColor))
     {
         ampColorRectangle.Visibility = Visibility.Visible;
         ampColorRectangle.Fill       = new SolidColorBrush(AppConstants.GetColor(rideDetails.BeaconColor));
     }
     else
     {
         ampColorRectangle.Visibility = Visibility.Collapsed;
     }
     UpdateDriverLocation(rideDetails.Location);
     if (rideDetails.Origin.EtaSeconds.HasValue)
     {
         rideEtaTextBlock.Visibility = Visibility.Visible;
         rideEtaTextBlock.Text       = $"Arrives in {TimeSpan.FromSeconds(rideDetails.Origin.EtaSeconds.Value).Humanize(2)}";
     }
 }