Browse Source

Passenger Collected page implemented

master
Kaustav Chaudhuri 1 year ago
parent
commit
3c537263fc
3 changed files with 528 additions and 0 deletions
  1. +382
    -0
      GMCabsDriverAssistantSolution/ViewModels/StartRideViewModel.cs
  2. +130
    -0
      GMCabsDriverAssistantSolution/Views/PassgerCollectedPage.xaml
  3. +16
    -0
      GMCabsDriverAssistantSolution/Views/PassgerCollectedPage.xaml.cs

+ 382
- 0
GMCabsDriverAssistantSolution/ViewModels/StartRideViewModel.cs View File

@ -0,0 +1,382 @@
using GMCabsDriverAssistant.Models;
using GMCabsDriverAssistant.Models.Rydo;
using GMCabsDriverAssistant.Services;
using GMCabsDriverAssistantSolution.Models.Rydo;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace GMCabsDriverAssistantSolution.ViewModels
{
[QueryProperty(nameof(RideRequestJson), nameof(RideRequestJson))]
public class StartRideViewModel : BaseViewModel
{
#region Fields
private string rideRequestJson;
private string passengerName;
private bool isCorporate;
private string fullDestinationAddress;
private StartRideResponse startRideResponse;
private int frameWidth;
private bool stopOver = false;
private bool noStopOver = false;
private int index = 0;
private double destinationCircleColorOpecity = 0.2;
private string destinationStopLabelColorCode = "#BECEDA";
private bool isStopOver = false;
private bool isNoStopOver = false;
StartRideRequestDto startRideRequestDto;
Page _page;
public string meterRunningStatus;
private string locationSuburbName;
private string startSuburb;
private string pickUpDateTime;
private string timerSeconds;
public int seconds = 0;
private bool visibleTrip;
private bool isEndTripButtonVisible = true;
private string startTimeOrEndLocation;
#endregion
#region Properties
public List<StopoverLocations> StopoverLocations { get; }
public ObservableCollection<StopoverLocations> StopoverLocationsList { get; }
public Command OnPassengerCollectedClick { get; }
public string RideRequestJson
{
get => rideRequestJson;
set
{
rideRequestJson = value;
ProcessRiding(value);
}
}
public string PassengerName
{
get => passengerName;
set => SetProperty(ref passengerName, value);
}
public bool IsCorporate
{
get => isCorporate;
set => SetProperty(ref isCorporate, value);
}
public string FullDestinationAddress
{
get => fullDestinationAddress;
set => SetProperty(ref fullDestinationAddress, value);
}
public bool StopOver
{
get => stopOver;
set => SetProperty(ref stopOver, value);
}
public bool NoStopOver
{
get => noStopOver;
set => SetProperty(ref noStopOver, value);
}
public bool IsStopOver
{
get => isStopOver;
set => SetProperty(ref isStopOver, value);
}
public bool IsNoStopOver
{
get => isNoStopOver;
set => SetProperty(ref isNoStopOver, value);
}
public int FrameWidth
{
get => frameWidth;
set => SetProperty(ref frameWidth, value);
}
public double DestinationCircleColorOpecity
{
get => destinationCircleColorOpecity;
set => SetProperty(ref destinationCircleColorOpecity, value);
}
public string DestinationStopLabelColorCode
{
get => destinationStopLabelColorCode;
set => SetProperty(ref destinationStopLabelColorCode, value);
}
public string StartSuburb
{
get => startSuburb;
set
{
SetProperty(ref startSuburb, value);
}
}
public string PickUpDateTime
{
get => pickUpDateTime;
set => SetProperty(ref pickUpDateTime, value);
}
public string TimerSeconds
{
get => timerSeconds;
set => SetProperty(ref timerSeconds, value);
}
public bool VisibleTrip
{
get => visibleTrip;
set => SetProperty(ref visibleTrip, value);
}
public bool IsEndTripButtonVisible
{
get => isEndTripButtonVisible;
set => SetProperty(ref isEndTripButtonVisible, value);
}
public string StartTimeOrEndLocation
{
get => startTimeOrEndLocation;
set => SetProperty(ref startTimeOrEndLocation, value);
}
public Command OnPassengerDroppedOffClick { get; }
public Command onEndTripClick { get; }
#endregion
#region Constructor
public StartRideViewModel(Page page)
{
Title = "Passenger Collected";
StopoverLocations = new List<StopoverLocations>();
StopoverLocationsList = new ObservableCollection<StopoverLocations>();
OnPassengerCollectedClick = new Command(PassengerCollected);
startRideRequestDto = new StartRideRequestDto();
OnPassengerDroppedOffClick = new Command(PassengerDroppedOff);
_page = page;
meterRunningStatus = Preferences.Get("MeterRunningStatus", "");
StartTimeOrEndLocation = "Start Time";
}
#endregion
#region Methods
private async void ProcessRiding(string rideRequestJson)
{
string rydoAccessToken = Preferences.Get(EftposLoginResponse.RYDO_ACCESS_TOKEN, "");
GMCabsDriverService gmCabsDriverService = new GMCabsDriverService();
startRideRequestDto = JsonSerializer.Deserialize<StartRideRequestDto>(rideRequestJson);
StartRideRequest startRideRequest = startRideRequestDto.startRideRequest;
if (startRideRequest.DriverId == "")
{
await Shell.Current.GoToAsync("..");
}
startRideResponse = new StartRideResponse();
startRideResponse = await gmCabsDriverService.StartRiding(startRideRequest, rydoAccessToken, startRideRequestDto.BookingId.ToString());
if (startRideResponse.StatusCode == (int)HttpStatusCode.OK)
{
PassengerName = startRideResponse.PassengerName;
IsCorporate = startRideResponse.IsCorporate;
startRideResponse.DriverId = startRideRequest.DriverId;
startRideResponse.BookingId = startRideRequestDto.BookingId;
if (IsCorporate)
{
FrameWidth = 310;
}
else
{
FrameWidth = 370;
}
startRideResponse.FrameWidth = FrameWidth;
FullDestinationAddress = startRideResponse.EndAddress + " " + startRideResponse.EndSuburb;
var locations = new List<StopoverLocations>();
//These below-mentioned commented out codes are witten for checking the lists of Stop Over Locations as a mock data
//because of unable to fetch real stop over location data from the dev rydo booking page
//locations.Add(new StopoverLocations
//{
// Latitude = -32.63,
// Longitude = 151.55,
// Address = "1 Milson St",
// Suburb = "Charlestown",
// StopNumber = 1
//});
//locations.Add(new StopoverLocations
//{
// Latitude = -36.17,
// Longitude = 144.66,
// Address = "1/1 Milson St",
// Suburb = "Charlestown",
// StopNumber = 2
//});
//locations.Add(new StopoverLocations
//{
// Latitude = -36.17,
// Longitude = 144.66,
// Address = "1/1 Milson St",
// Suburb = "Charlestown",
// StopNumber = 3
//});
//locations.Add(new StopoverLocations
//{
// Latitude = -36.17,
// Longitude = 144.66,
// Address = "1/1 Milson St",
// Suburb = "Charlestown",
// StopNumber = 2
//});
//locations.Add(new StopoverLocations
//{
// Latitude = -36.17,
// Longitude = 144.66,
// Address = "1/1 Milson St",
// Suburb = "Charlestown",
// StopNumber = 2
//});
//locations.Add(new StopoverLocations
//{
// Latitude = -36.17,
// Longitude = 144.66,
// Address = "1/1 Milson St",
// Suburb = "Charlestown",
// StopNumber = 2
//});
locations.Add(new StopoverLocations
{
Latitude = startRideResponse.EndLatitude,
Longitude = startRideResponse.EndLongitude,
Address = startRideResponse.EndAddress,
Suburb = startRideResponse.EndSuburb,
StopNumber = startRideResponse.StopoverLocations.Count + 1
});
startRideResponse.StopoverLocations.AddRange(locations);
if (startRideResponse.StopoverLocations.Count > 0)
{
StopOver = true;
NoStopOver = false;
IsStopOver = true;
IsNoStopOver = false;
StopoverLocations.Clear();
foreach (var locationlists in startRideResponse.StopoverLocations)
{
StopoverLocations.Add(locationlists);
}
setPrimaryStopOverLocation(StopoverLocations);
}
else
{
StopOver = false;
NoStopOver = true;
IsStopOver = false;
IsNoStopOver = true;
}
if (startRideResponse.FixedAmount != null)
{
decimal amount = Convert.ToDecimal(startRideResponse.FixedAmount) / 100.0m;
amount = amount * 1.00m;
startRideResponse.FixedAmount = amount;
}
}
}
private void setPrimaryStopOverLocation(List<StopoverLocations> stopoverLocations)
{
StopoverLocationsList.Clear();
int stopOverLocationCount = 1;
foreach (var location in stopoverLocations)
{
if (stopOverLocationCount == stopoverLocations.Count)
{
location.IsLineVisible = false;
}
location.LabelColor = "#BBB9B9";
location.CircleColorOpecity = 0.2;
StopoverLocationsList.Add(location);
if (stopoverLocations.Count == 1)
{
location.LabelColor = "Black";
location.CircleColorOpecity = 0.5;
IsStopOver = false;
IsNoStopOver = true;
}
stopOverLocationCount++;
}
}
private void setStopOverLocation(List<StopoverLocations> stopoverLocations)
{
StopoverLocationsList.Clear();
int stopoverLocationIndex = 0;
foreach (var location in stopoverLocations)
{
if (stopoverLocationIndex == stopoverLocations.Count - 1)
{
location.IsLineVisible = false;
}
if (stopoverLocationIndex == index)
{
location.LabelColor = "Black";
location.CircleColorOpecity = 0.5;
}
else
{
location.LabelColor = "#BBB9B9";
location.CircleColorOpecity = 0.2;
}
StopoverLocationsList.Add(location);
stopoverLocationIndex++;
}
}
private async void PassengerCollected()
{
int stop_number = StopoverLocationsList[index].StopNumber;
string booking_id = startRideRequestDto.BookingId.ToString();
string rydoAccessToken = Preferences.Get(EftposLoginResponse.RYDO_ACCESS_TOKEN, "");
GMCabsDriverService gmCabsDriverService = new GMCabsDriverService();
await gmCabsDriverService.NotifyStop(stop_number, rydoAccessToken, booking_id);
int StopoverLocationsListCount = StopoverLocationsList.Count;
setStopOverLocation(StopoverLocations);
if (index == StopoverLocationsListCount - 1)
{
DestinationStopLabelColorCode = "Black";
DestinationCircleColorOpecity = 0.5;
IsStopOver = false;
IsNoStopOver = true;
}
index = index + 1;
}
public async void PassengerDroppedOff()
{
//if (meterRunningStatus == "Stopped")
//{
//UpdateBookingStatus();
//if (startRideResponse.PaymentMethodId == null && startRideResponse.FixedAmount == null)
//{
// await _page.Navigation.PushAsync(new PassengerDroppedWithNoPaymentMethodIdNoFixedFareTablet(startRideResponse));
//}
//else if (startRideResponse.PaymentMethodId == null && startRideResponse.FixedAmount != null)
//{
// await _page.Navigation.PushAsync(new PassengerDroppedWithNoPaymentMethodIdAndFixedFareTablet(startRideResponse));
//}
//else if (startRideResponse.PaymentMethodId != null && startRideResponse.FixedAmount != null)
//{
// await _page.Navigation.PushAsync(new PassengerDroppedWithPaymentMethodIdAndFixedFareTablet(startRideResponse));
//}
//else if (startRideResponse.PaymentMethodId != null && startRideResponse.FixedAmount == null)
//{
// await _page.Navigation.PushAsync(new PassengerDroppedWithPaymentMethodIdNoFixedFareTablet(startRideResponse));
//}
//}
//else
//{
// _page.Navigation.ShowPopup(new MeterTripStatusDialogPage(this._page, startRideResponse));
//}
}
#endregion
}
}

+ 130
- 0
GMCabsDriverAssistantSolution/Views/PassgerCollectedPage.xaml View File

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="GMCabsDriverAssistantSolution.Views.PassgerCollectedPage"
xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewmodels="clr-namespace:GMCabsDriverAssistantSolution.ViewModels"
xmlns:models="clr-namespace:GMCabsDriverAssistant.Models"
xmlns:UserControl="clr-namespace:GMCabsDriverAssistant.UserControl" x:DataType="viewmodels:StartRideViewModel"
NavigationPage.HasBackButton="False"
Title="{Binding Title}">
<Shell.BackButtonBehavior>
<BackButtonBehavior IsEnabled="false" IconOverride="ic_menu_blank.png" TextOverride="" />
</Shell.BackButtonBehavior>
<ContentPage.Content>
<StackLayout Orientation="Horizontal"
BackgroundColor="#DCDCDC">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackLayout Grid.Row="0"
Grid.Column="0"
BackgroundColor="#DCDCDC">
<StackLayout>
<RelativeLayout VerticalOptions="CenterAndExpand" Margin="30,30,10,10">
<Frame BackgroundColor="#8B0000" WidthRequest="360" Margin="20,0,0,0" CornerRadius="10" IsVisible="{Binding IsCorporate}">
<StackLayout HorizontalOptions="EndAndExpand">
<Label FontSize="20" VerticalTextAlignment="End" TextColor="White" Text="VIP" />
</StackLayout>
</Frame>
<Frame BackgroundColor="#E9E4D4" WidthRequest="{Binding FrameWidth}" IsVisible="True" CornerRadius="10">
<StackLayout Orientation="Horizontal">
<Image Source="passenger.png"
HeightRequest="30"/>
<Label FontSize="20" Text="{Binding PassengerName}" TextColor="Black" FontAttributes="Bold" />
</StackLayout>
</Frame>
</RelativeLayout>
<Grid Margin="30,0,0,0" IsVisible="{Binding StopOver}">
<CollectionView ItemsSource="{Binding StopoverLocationsList}">
<CollectionView.ItemsLayout>
<LinearItemsLayout
Orientation="Vertical"
ItemSpacing="0"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<RelativeLayout>
<StackLayout x:DataType="models:StopoverLocations" Grid.Row="0" Grid.Column="0" Orientation="Vertical" HorizontalOptions="StartAndExpand">
<Ellipse Fill="{StaticResource Primary}" Opacity="{Binding CircleColorOpecity}"
WidthRequest="30"
HeightRequest="30"
HorizontalOptions="StartAndExpand" />
</StackLayout>
<StackLayout x:DataType="models:StopoverLocations" Orientation="Horizontal" VerticalOptions="Start" Margin="50,0,70,0">
<Label FontSize="22"
Text="{Binding FullStopOverAddress}"
TextColor="{Binding LabelColor}"/>
</StackLayout>
<StackLayout x:DataType="models:StopoverLocations" VerticalOptions="CenterAndExpand" Margin="-25,30,0,0">
<Line X1="40"
Y1="0"
X2="40"
Y2="48"
Stroke="white"
StrokeDashArray="1,1"
StrokeThickness="7"
StrokeDashOffset="6"
IsVisible="{Binding IsLineVisible}"/>
</StackLayout>
</RelativeLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Grid VerticalOptions="CenterAndExpand" IsVisible="False">
<StackLayout Grid.Row="0" Grid.Column="0" Orientation="Vertical" HorizontalOptions="StartAndExpand" Margin="0,10,0,0">
<Ellipse Fill="{StaticResource Primary}" Opacity="{Binding DestinationCircleColorOpecity}"
WidthRequest="30"
HeightRequest="30"
HorizontalOptions="StartAndExpand" />
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand" Margin="50,10,70,0">
<Label FontSize="20"
Text="{Binding FullDestinationAddress}"
TextColor="{Binding DestinationStopLabelColorCode}"/>
</StackLayout>
</Grid>
</Grid>
<Grid Margin="30,0,0,0" IsVisible="{Binding NoStopOver}">
<StackLayout Grid.Row="0" Grid.Column="0" Orientation="Vertical" HorizontalOptions="StartAndExpand">
<Ellipse Fill="{StaticResource Primary}" Opacity="0.5"
WidthRequest="30"
HeightRequest="30"
HorizontalOptions="StartAndExpand" />
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand" Margin="50,0,70,0">
<Label FontSize="20"
Text="{Binding FullDestinationAddress}"
TextColor="Black"/>
</StackLayout>
</Grid>
</StackLayout>
<StackLayout VerticalOptions="EndAndExpand" Orientation="Vertical" Margin="50,0,60,30" IsVisible="{Binding IsStopOver}">
<Button
Text="Passenger Collected"
FontSize="20"
TextTransform="Uppercase"
Command="{Binding OnPassengerCollectedClick}"
/>
</StackLayout>
<StackLayout VerticalOptions="EndAndExpand" Orientation="Vertical" Margin="50,0,60,30" IsVisible="{Binding IsNoStopOver}">
<Button
Text="Passenger Dropped Off"
FontSize="20"
TextTransform="Uppercase"
Command="{Binding OnPassengerDroppedOffClick}"
/>
</StackLayout>
</StackLayout>
<UserControl:TripInformationPage Grid.Row="0"
Grid.Column="1" />
</Grid>
</StackLayout>
</ContentPage.Content>
</ContentPage>

+ 16
- 0
GMCabsDriverAssistantSolution/Views/PassgerCollectedPage.xaml.cs View File

@ -0,0 +1,16 @@
using GMCabsDriverAssistantSolution.ViewModels;
namespace GMCabsDriverAssistantSolution.Views;
public partial class PassgerCollectedPage : ContentPage
{
#region Fields
private readonly StartRideViewModel _viewModel;
#endregion
public PassgerCollectedPage()
{
InitializeComponent();
BindingContext = _viewModel = new StartRideViewModel(this);
}
protected override bool OnBackButtonPressed() => true;
}

Loading…
Cancel
Save