sharee.bike-App/LastenradBayern/ShareeBike/View/SelectBike/SelectBikePage.xaml
2024-04-16 11:29:40 +02:00

218 lines
6.4 KiB
XML

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
x:Class="ShareeBike.View.SelectBike.SelectBikePage"
xmlns:conv="clr-namespace:ShareeBike.View;assembly=SharedBusinessLogic"
xmlns:resources="clr-namespace:ShareeBike.MultilingualResources;assembly=SharedBusinessLogic"
xmlns:rental_process="clr-namespace:ShareeBike.ViewModel.Bikes;assembly=SharedBusinessLogic"
xmlns:bikeRentalProcess="clr-namespace:SharedGui.View.Bike.RentalProcess"
xmlns:local_bike="clr-namespace:ShareeBike.View.Bike"
xmlns:sharedGui="clr-namespace:SharedGui.View"
BackgroundColor="{DynamicResource background-color}"
Shell.NavBarIsVisible="{Binding IsIdle}">
<Shell.TitleView>
<Grid ColumnDefinitions="Auto, 1*">
<Label Style="{StaticResource Label-Navbar}"
Text="{x:Static resources:AppResources.MarkingSelectBike}"/>
</Grid>
</Shell.TitleView>
<ContentPage.Resources>
<ResourceDictionary>
<local_bike:BikeViewCellTemplateSelector x:Key="bikeTemplateSelector"/>
<conv:StringNotNullOrEmptyToVisibleConverter x:Key="Label_Converter"/>
<xct:MultiConverter x:Key="RentalProcessToVisibleConverter">
<xct:EnumToBoolConverter>
<xct:EnumToBoolConverter.TrueValues>
<rental_process:CurrentRentalProcess>CloseLock</rental_process:CurrentRentalProcess>
<rental_process:CurrentRentalProcess>EndRental</rental_process:CurrentRentalProcess>
</xct:EnumToBoolConverter.TrueValues>
</xct:EnumToBoolConverter>
<xct:InvertedBoolConverter />
</xct:MultiConverter>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<!--Grid for Bike(s) view and Running process in same row-->
<Grid>
<!-- Grid for Content -->
<Grid
IsVisible="{Binding RentalProcess.State, Converter={StaticResource RentalProcessToVisibleConverter}}"
Grid.Row="0"
RowSpacing="0"
RowDefinitions="1*,Auto">
<StackLayout
Grid.Row="0"
Spacing="0"
Orientation="Vertical">
<StackLayout
BackgroundColor="White"
Padding="20,0,20,0">
<Grid
RowDefinitions="Auto,Auto"
ColumnDefinitions="*,Auto">
<!--Search bike-->
<Label
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="0"
Text="{x:Static resources:AppResources.MarkingSelectBikeLabel}"
Margin="0,5,0,-5">
</Label>
<Entry
Grid.Column="0"
Grid.Row="1"
x:Name="SelectBikeEntry"
Placeholder="{x:Static resources:AppResources.PlaceholderSelectBike}"
MaxLength="10"
CursorPosition="0"
Text="{Binding BikeIdUserInput, Mode=TwoWay}"/>
<Button
Grid.Column="1"
Grid.Row="1"
WidthRequest="100"
Text="{x:Static resources:AppResources.MarkingSelectBikeButton}"
Command="{Binding OnSelectBikeRequest}">
<Button.Triggers>
<DataTrigger TargetType="Button" Binding="{Binding IsSelectBikeEnabled}" Value="False">
<Setter Property="BorderColor" Value="DimGray" />
<Setter Property="BackgroundColor" Value="DimGray" />
<Setter Property="TextColor" Value="LightGray" />
</DataTrigger>
</Button.Triggers>
</Button>
</Grid>
<!--Line-->
<BoxView
HeightRequest="1"
WidthRequest="400"
HorizontalOptions="Center"
Color="{DynamicResource primary-back-title-color}"/>
</StackLayout>
<!--Bike data-->
<Grid
RowDefinitions="1*"
RowSpacing="0">
<!--Bike-->
<ListView
x:Name="SelectBikeListView"
BackgroundColor="{DynamicResource background-color}"
SelectionMode="None"
SelectedItem="{Binding SelectedBike}"
IsEnabled="{Binding IsIdle}"
HasUnevenRows="True"
SeparatorVisibility="None"
ItemTemplate="{StaticResource bikeTemplateSelector}"
IsPullToRefreshEnabled="True"
RefreshCommand="{Binding RefreshCommand}"
IsRefreshing="{Binding IsRefreshing}"/>
</Grid>
</StackLayout>
<!--Info at End of Page-->
<StackLayout
Grid.Row="1"
Orientation="Vertical"
Spacing="0"
Padding="20,0,20,0">
<!--Info text-->
<Label
Text="{Binding StatusInfoText}"
IsVisible="{Binding Path=IsProcessWithRunningProcessView, Converter={StaticResource InvertedBoolConverter}}"
FontSize="Small"
TextColor="DimGray"
Padding="5"
HorizontalOptions="CenterAndExpand">
<Label.Triggers>
<DataTrigger
TargetType="Label"
Binding="{Binding Path=StatusInfoText.Length}" Value="0">
<Setter Property="HeightRequest" Value="0" />
</DataTrigger>
<DataTrigger
TargetType="Label"
Binding="{Binding Path=StatusInfoText}" Value="Offline.">
<Setter Property="HeightRequest" Value="0" />
</DataTrigger>
</Label.Triggers>
</Label>
<!--Login-->
<StackLayout Spacing="0">
<StackLayout.Triggers>
<DataTrigger TargetType="StackLayout"
Binding="{Binding IsLoginRequiredHintVisible}"
Value="false">
<Setter Property="HeightRequest" Value="0" />
</DataTrigger>
</StackLayout.Triggers>
<!--Line-->
<BoxView
HeightRequest="1"
WidthRequest="400"
HorizontalOptions="Center"
IsVisible="{Binding IsLoginRequiredHintVisible}"
Color="DimGray" />
<!--Login required-->
<Label
IsVisible="{Binding IsLoginRequiredHintVisible}"
TextType="Html"
TextColor="DimGray"
Text="{Binding LoginRequiredHintText}">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding LoginRequiredHintClickedCommand}"/>
</Label.GestureRecognizers>
</Label>
</StackLayout>
</StackLayout>
</Grid>
<!--While process is running-->
<sharedGui:RunningProcessView
Grid.Row="0"
IsVisible="{Binding IsProcessWithRunningProcessView}"/>
<!--RequestBike View-->
<bikeRentalProcess:RentalProcessStartReservationOrRental
Grid.Row="0"/>
<!--OpenLock View-->
<bikeRentalProcess:RentalProcessBookedClosedOpenLock
Grid.Row="0"/>
<!--CloseLock View-->
<bikeRentalProcess:RentalProcessBookedOpenCloseLock
Grid.Row="0"/>
<!--EndRental View-->
<bikeRentalProcess:RentalProcessBookedClosedEndRental
Grid.Row="0"/>
</Grid>
</ContentPage.Content>
</ContentPage>