Accepted Future booking View Model and Its respective pages Implemented.
This commit is contained in:
parent
b9d3fc0c09
commit
31191f3169
@ -0,0 +1,237 @@
|
|||||||
|
using GMCabsDriverAssistant.Enums;
|
||||||
|
using GMCabsDriverAssistant.Services;
|
||||||
|
using GMCabsDriverAssistantSolution.Models.Rydo;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GMCabsDriverAssistantSolution.ViewModels
|
||||||
|
{
|
||||||
|
[QueryProperty(nameof(BookingId), nameof(BookingId))]
|
||||||
|
class AcceptedFutureBookingDetailViewModel : BaseViewModel
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
private string _bookingId;
|
||||||
|
|
||||||
|
private float distance;
|
||||||
|
|
||||||
|
private string formattedDistance;
|
||||||
|
|
||||||
|
private string startAddress;
|
||||||
|
|
||||||
|
private string startSuburb;
|
||||||
|
|
||||||
|
private string endAddress;
|
||||||
|
|
||||||
|
private string endSuburb;
|
||||||
|
|
||||||
|
private string rewardPoints;
|
||||||
|
|
||||||
|
private double bookingFee;
|
||||||
|
|
||||||
|
private bool isCorporateBooking;
|
||||||
|
|
||||||
|
private string fareTypeValue;
|
||||||
|
|
||||||
|
private int? fixedAmount;
|
||||||
|
|
||||||
|
private bool isFutureBooking;
|
||||||
|
|
||||||
|
private int pickUpTime;
|
||||||
|
|
||||||
|
private string formattedPickUpTime;
|
||||||
|
private string formattedPickUpTimeDateOnly;
|
||||||
|
private string formattedPickUpTimeTimeOnly;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
public string BookingId
|
||||||
|
{
|
||||||
|
get => _bookingId;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_bookingId = value;
|
||||||
|
LoadAcceptedFutureBooking(Guid.Parse(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float Distance
|
||||||
|
{
|
||||||
|
get => distance;
|
||||||
|
set => SetProperty(ref distance, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FormattedDistance
|
||||||
|
{
|
||||||
|
get => (distance >= 1000) ? $"{distance / 1000:0.##}k" : $"{(int)distance}m";
|
||||||
|
set => SetProperty(ref formattedDistance, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string StartAddress
|
||||||
|
{
|
||||||
|
get => startAddress;
|
||||||
|
set => SetProperty(ref startAddress, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string StartSuburb
|
||||||
|
{
|
||||||
|
get => startSuburb;
|
||||||
|
set => SetProperty(ref startSuburb, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EndAddress
|
||||||
|
{
|
||||||
|
get => endAddress;
|
||||||
|
set => SetProperty(ref endAddress, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EndSuburb
|
||||||
|
{
|
||||||
|
get => endSuburb;
|
||||||
|
set => SetProperty(ref endSuburb, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string RewardPoints
|
||||||
|
{
|
||||||
|
get => rewardPoints;
|
||||||
|
set => SetProperty(ref rewardPoints, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double BookingFee
|
||||||
|
{
|
||||||
|
get => bookingFee;
|
||||||
|
set => SetProperty(ref bookingFee, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsCorporateBooking
|
||||||
|
{
|
||||||
|
get => isCorporateBooking;
|
||||||
|
set => SetProperty(ref isCorporateBooking, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FareTypeValue
|
||||||
|
{
|
||||||
|
get => fareTypeValue;
|
||||||
|
set => SetProperty(ref fareTypeValue, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int? FixedAmount
|
||||||
|
{
|
||||||
|
get => fixedAmount;
|
||||||
|
set => SetProperty(ref fixedAmount, value);
|
||||||
|
}
|
||||||
|
public bool IsFutureBooking
|
||||||
|
{
|
||||||
|
get => isFutureBooking;
|
||||||
|
set => SetProperty(ref isFutureBooking, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int PickUpTime
|
||||||
|
{
|
||||||
|
get => pickUpTime;
|
||||||
|
set => SetProperty(ref pickUpTime, value);
|
||||||
|
}
|
||||||
|
public string FormattedPickUpTime
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||||
|
dateTime = dateTime.AddSeconds(pickUpTime).ToLocalTime();
|
||||||
|
return dateTime.ToString("dd/MM/yyyy hh:mm tt");
|
||||||
|
}
|
||||||
|
set => SetProperty(ref formattedPickUpTime, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
public AcceptedFutureBookingDetailViewModel()
|
||||||
|
{
|
||||||
|
Title = "Accepted Future Booking Detail";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
public async void LoadAcceptedFutureBooking(Guid bookingId)
|
||||||
|
{
|
||||||
|
string rydoAccessToken = Preferences.Get(EftposLoginResponse.RYDO_ACCESS_TOKEN, "");
|
||||||
|
GMCabsDriverService gmCabsDriverService = new GMCabsDriverService();
|
||||||
|
var booking = await gmCabsDriverService.GetBookingDetails(rydoAccessToken, bookingId);
|
||||||
|
if (booking.BookingId == Guid.Empty)
|
||||||
|
{
|
||||||
|
await Shell.Current.GoToAsync("..");
|
||||||
|
}
|
||||||
|
|
||||||
|
Distance = booking.Distance;
|
||||||
|
FormattedDistance = booking.Distance.ToString();
|
||||||
|
StartAddress = booking.StartAddress;
|
||||||
|
StartSuburb = booking.StartSuburb;
|
||||||
|
EndAddress = booking.EndAddress;
|
||||||
|
EndSuburb = booking.EndSuburb;
|
||||||
|
IsCorporateBooking = booking.IsCorporate;
|
||||||
|
FixedAmount = booking.FixedAmount;
|
||||||
|
IsFutureBooking = booking.FutureBooking;
|
||||||
|
PickUpTime = booking.PickupTime;
|
||||||
|
FormattedPickUpTime = booking.PickupTime.ToString();
|
||||||
|
BookingFee = 0;
|
||||||
|
|
||||||
|
if (FixedAmount != null)
|
||||||
|
{
|
||||||
|
decimal amount = (decimal)(FixedAmount / 100.0);
|
||||||
|
FareTypeValue = "$" + amount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FareTypeValue = "METER";
|
||||||
|
}
|
||||||
|
|
||||||
|
RewardPoints = booking.RydoStars > 0 ? string.Format($"+{booking.RydoStars}") : booking.RydoStars.ToString();
|
||||||
|
|
||||||
|
var preferredDriver = booking.PriorityDriver;
|
||||||
|
if (preferredDriver)
|
||||||
|
{
|
||||||
|
if (booking.FareType == FareType.Fixed)
|
||||||
|
{
|
||||||
|
if (booking.FixedAmount > booking.MinFareAmount)
|
||||||
|
{
|
||||||
|
BookingFee = booking.ProviderChargeFixedFarePreferred.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (booking.FareType == FareType.Meter)
|
||||||
|
{
|
||||||
|
BookingFee = booking.ProviderChargeMeterFarePreferred.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (booking.FareType == FareType.Fixed)
|
||||||
|
{
|
||||||
|
if (booking.FixedAmount > booking.MinFareAmount)
|
||||||
|
{
|
||||||
|
BookingFee = booking.ProviderChargeFixedFare.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (booking.FareType == FareType.Meter)
|
||||||
|
{
|
||||||
|
BookingFee = booking.ProviderChargeMeterFare.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task OnDeclineBookingClickedAsync()
|
||||||
|
{
|
||||||
|
string rydoAccessToken = Preferences.Get(EftposLoginResponse.RYDO_ACCESS_TOKEN, "");
|
||||||
|
GMCabsDriverService gmCabsDriverService = new GMCabsDriverService();
|
||||||
|
var result = await gmCabsDriverService.DeclineFutureBooking(rydoAccessToken, _bookingId);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
await Shell.Current.GoToAsync("../AcceptedFutureBookingsPage");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using GMCabsDriverAssistant.Models;
|
using GMCabsDriverAssistant.Models;
|
||||||
using GMCabsDriverAssistant.Services;
|
using GMCabsDriverAssistant.Services;
|
||||||
using GMCabsDriverAssistantSolution.Models.Rydo;
|
using GMCabsDriverAssistantSolution.Models.Rydo;
|
||||||
|
using GMCabsDriverAssistantSolution.Views;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@ -119,7 +120,7 @@ namespace GMCabsDriverAssistantSolution.ViewModels
|
|||||||
{
|
{
|
||||||
if (booking == null) return;
|
if (booking == null) return;
|
||||||
|
|
||||||
// await Shell.Current.GoToAsync($"{nameof(AcceptedFutureBookingDetailPage)}?{nameof(AcceptedFutureBookingDetailViewModel.BookingId)}={booking.BookingId:N}");
|
await Shell.Current.GoToAsync($"{nameof(AcceptedFutureBookingDetailPage)}?{nameof(AcceptedFutureBookingDetailViewModel.BookingId)}={booking.BookingId:N}");
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,183 @@
|
|||||||
|
<?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.AcceptedFutureBookingDetailPage"
|
||||||
|
xmlns:vm="clr-namespace:GMCabsDriverAssistantSolution.ViewModels"
|
||||||
|
xmlns:models="clr-namespace:GMCabsDriverAssistant.Models"
|
||||||
|
x:DataType="vm:AcceptedFutureBookingDetailViewModel"
|
||||||
|
Title="{Binding Title}">
|
||||||
|
<ContentPage.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<Style x:Key="InnerFrameLabel" TargetType="Label">
|
||||||
|
<Setter Property="HorizontalTextAlignment" Value="Center"/>
|
||||||
|
<Setter Property="FontAttributes" Value="Bold"/>
|
||||||
|
<Setter Property="TextColor" Value="Black"/>
|
||||||
|
<Setter Property="FontSize" Value="25"/>
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="OuterFrameLabel" TargetType="Label">
|
||||||
|
<Setter Property="HorizontalTextAlignment" Value="Center"/>
|
||||||
|
<Setter Property="FontAttributes" Value="Bold"/>
|
||||||
|
<Setter Property="TextColor" Value="Black"/>
|
||||||
|
<Setter Property="FontSize" Value="25"/>
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="BellowFrameStyle" TargetType="Frame">
|
||||||
|
<Setter Property="BackgroundColor" Value="#C4C4C4"/>
|
||||||
|
<Setter Property="WidthRequest" Value="70"/>
|
||||||
|
</Style>
|
||||||
|
<Color x:Key="Accent">#96d1ff</Color>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</ContentPage.Resources>
|
||||||
|
<ContentPage.Content>
|
||||||
|
<StackLayout Orientation="Vertical"
|
||||||
|
Padding="20,5,20,5"
|
||||||
|
BackgroundColor="#DCDCDC">
|
||||||
|
<!--
|
||||||
|
<Label
|
||||||
|
TextColor="Black"
|
||||||
|
HorizontalTextAlignment="Center"
|
||||||
|
FontSize="25">
|
||||||
|
<Label.Triggers>
|
||||||
|
<DataTrigger TargetType="Label" Binding="{Binding IsFutureBooking}" Value="True">
|
||||||
|
<Setter Property="Text" Value=""/>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger TargetType="Label" Binding="{Binding IsFutureBooking}" Value="False">
|
||||||
|
<Setter Property="Text" Value="{Binding FormattedDistance}" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Label.Triggers>
|
||||||
|
</Label>
|
||||||
|
-->
|
||||||
|
<StackLayout Orientation="Horizontal">
|
||||||
|
<Image Source="green_pin.png"
|
||||||
|
HeightRequest="40"/>
|
||||||
|
<Label TextColor="Black"
|
||||||
|
HorizontalTextAlignment="Start"
|
||||||
|
FontSize="20"
|
||||||
|
Margin="10,10,0,0"
|
||||||
|
Text="{Binding StartSuburb}">
|
||||||
|
<!--
|
||||||
|
<Label.Text>
|
||||||
|
<MultiBinding StringFormat="{}{0} {1}">
|
||||||
|
<Binding Path="StartAddress" />
|
||||||
|
<Binding Path="StartSuburb" />
|
||||||
|
</MultiBinding>
|
||||||
|
</Label.Text>
|
||||||
|
-->
|
||||||
|
</Label>
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout Orientation="Horizontal">
|
||||||
|
<Image Source="red_pin.png"
|
||||||
|
HeightRequest="40"/>
|
||||||
|
<Label TextColor="Black"
|
||||||
|
HorizontalTextAlignment="Start"
|
||||||
|
FontSize="20"
|
||||||
|
Margin="10,10,0,0"
|
||||||
|
Text="{Binding EndSuburb}">
|
||||||
|
<!--
|
||||||
|
<Label.Text>
|
||||||
|
<MultiBinding StringFormat="{}{0} {1}">
|
||||||
|
<Binding Path="EndAddress" />
|
||||||
|
<Binding Path="EndSuburb" />
|
||||||
|
</MultiBinding>
|
||||||
|
</Label.Text>
|
||||||
|
-->
|
||||||
|
</Label>
|
||||||
|
</StackLayout>
|
||||||
|
<Frame CornerRadius="25"
|
||||||
|
Padding="0"
|
||||||
|
Margin="0,15,0,0"
|
||||||
|
BackgroundColor="#BCA70F0F">
|
||||||
|
<StackLayout>
|
||||||
|
<Frame BackgroundColor="#C4C4C4"
|
||||||
|
HeightRequest="28"
|
||||||
|
Padding="0,5,0,5"
|
||||||
|
CornerRadius="25">
|
||||||
|
<StackLayout Orientation="Horizontal"
|
||||||
|
HorizontalOptions="CenterAndExpand">
|
||||||
|
<Image Source="clock.png"
|
||||||
|
Margin="0,0,10,0"/>
|
||||||
|
<Label
|
||||||
|
TextColor="Black"
|
||||||
|
FontAttributes="Bold"
|
||||||
|
VerticalTextAlignment="Center"
|
||||||
|
HorizontalTextAlignment="Center"
|
||||||
|
FontSize="20">
|
||||||
|
<Label.Triggers>
|
||||||
|
<DataTrigger TargetType="Label" Binding="{Binding IsFutureBooking}" Value="True">
|
||||||
|
<Setter Property="Text" Value="{Binding FormattedPickUpTime}"/>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger TargetType="Label" Binding="{Binding IsFutureBooking}" Value="False">
|
||||||
|
<Setter Property="Text" Value="READY NOW" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Label.Triggers>
|
||||||
|
</Label>
|
||||||
|
</StackLayout>
|
||||||
|
</Frame>
|
||||||
|
<!--<Frame x:Name="corporateVIPFrame" BackgroundColor="Transparent"
|
||||||
|
HasShadow="False"
|
||||||
|
Padding="5">-->
|
||||||
|
<Label x:Name="corporateVipLabel"
|
||||||
|
Text="Corporate VIP Booking"
|
||||||
|
TextColor="White"
|
||||||
|
FontAttributes="Bold"
|
||||||
|
VerticalTextAlignment="Start"
|
||||||
|
HorizontalTextAlignment="Center"
|
||||||
|
FontSize="20"
|
||||||
|
Padding="5"/>
|
||||||
|
<!--</Frame>-->
|
||||||
|
</StackLayout>
|
||||||
|
</Frame>
|
||||||
|
<StackLayout Orientation="Horizontal"
|
||||||
|
Margin="0,5,0,0">
|
||||||
|
<StackLayout HorizontalOptions="StartAndExpand">
|
||||||
|
<Label Text="PAYMENT"
|
||||||
|
HorizontalTextAlignment="Center"
|
||||||
|
TextColor="Black"
|
||||||
|
FontSize="15"/>
|
||||||
|
<Frame Padding="4,12"
|
||||||
|
WidthRequest="100"
|
||||||
|
CornerRadius="24"
|
||||||
|
Style="{StaticResource BellowFrameStyle}">
|
||||||
|
<Label Text="{Binding FareTypeValue}"
|
||||||
|
FontSize="20"
|
||||||
|
Style="{StaticResource InnerFrameLabel}"/>
|
||||||
|
</Frame>
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout HorizontalOptions="CenterAndExpand">
|
||||||
|
<Label Text="POINTS"
|
||||||
|
HorizontalTextAlignment="Center"
|
||||||
|
TextColor="Black"
|
||||||
|
FontSize="15"/>
|
||||||
|
<Frame Style="{StaticResource BellowFrameStyle}"
|
||||||
|
Padding="4,12"
|
||||||
|
CornerRadius="24">
|
||||||
|
<Label Text="{Binding RewardPoints, StringFormat='+{0}'}" FontSize="20"
|
||||||
|
Style="{StaticResource InnerFrameLabel}"/>
|
||||||
|
</Frame>
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout HorizontalOptions="EndAndExpand">
|
||||||
|
<Label Text="FEE"
|
||||||
|
HorizontalTextAlignment="Center"
|
||||||
|
TextColor="Black"
|
||||||
|
FontSize="15"/>
|
||||||
|
<Frame Style="{StaticResource BellowFrameStyle}"
|
||||||
|
Padding="4,12"
|
||||||
|
CornerRadius="24">
|
||||||
|
<Label Text="{Binding BookingFee, StringFormat='{0}%'}" FontSize="20"
|
||||||
|
TextColor="#B44444"
|
||||||
|
Style="{StaticResource InnerFrameLabel}"/>
|
||||||
|
</Frame>
|
||||||
|
</StackLayout>
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout VerticalOptions="EndAndExpand"
|
||||||
|
Margin="0,5,0,0">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Margin="20,0,20,15"
|
||||||
|
Text="Decline Booking"
|
||||||
|
FontSize="20"
|
||||||
|
TextTransform="Uppercase"
|
||||||
|
Clicked="OnDeclineBookingClicked"/>
|
||||||
|
</StackLayout>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage.Content>
|
||||||
|
</ContentPage>
|
@ -0,0 +1,30 @@
|
|||||||
|
using GMCabsDriverAssistantSolution.ViewModels;
|
||||||
|
|
||||||
|
namespace GMCabsDriverAssistantSolution.Views;
|
||||||
|
|
||||||
|
public partial class AcceptedFutureBookingDetailPage : ContentPage
|
||||||
|
{
|
||||||
|
private AcceptedFutureBookingDetailViewModel _viewModel;
|
||||||
|
|
||||||
|
public AcceptedFutureBookingDetailPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
BindingContext = _viewModel = new AcceptedFutureBookingDetailViewModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnAppearing()
|
||||||
|
{
|
||||||
|
base.OnAppearing();
|
||||||
|
corporateVipLabel.IsVisible = _viewModel.IsCorporateBooking;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnDeclineBookingClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
bool answer = await DisplayAlert("", "Are you sure you want to release this booking, cancellation fees may apply", "YES", "NO");
|
||||||
|
if (answer)
|
||||||
|
{
|
||||||
|
await _viewModel.OnDeclineBookingClickedAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user