mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 22:07:28 +02:00
Version 3.0.381
This commit is contained in:
parent
f963c0a219
commit
3a363acf3a
1525 changed files with 60589 additions and 125098 deletions
|
@ -0,0 +1,225 @@
|
|||
<?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"
|
||||
xmlns:rental_process="clr-namespace:ShareeBike.ViewModel.Bikes;assembly=SharedBusinessLogic"
|
||||
x:Class="ShareeBike.View.BikesAtStation.BikesAtStationPage"
|
||||
xmlns:local_bike="clr-namespace:ShareeBike.View.Bike"
|
||||
xmlns:sharedGui="clr-namespace:SharedGui.View"
|
||||
xmlns:bikeRentalProcess="clr-namespace:SharedGui.View.Bike.RentalProcess"
|
||||
BackgroundColor="{DynamicResource background-color}"
|
||||
Shell.NavBarIsVisible="{Binding IsIdle}">
|
||||
|
||||
<Shell.TitleView>
|
||||
<Grid ColumnDefinitions="Auto, 1*">
|
||||
<Label Style="{StaticResource Label-Navbar}"
|
||||
Text="{Binding Title}"/>
|
||||
</Grid>
|
||||
</Shell.TitleView>
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<local_bike:BikeViewCellTemplateSelector x:Key="bikeTemplateSelector"/>
|
||||
<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>
|
||||
|
||||
<!--BikesAtStationPage 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">
|
||||
|
||||
<!--Station-->
|
||||
<StackLayout
|
||||
BackgroundColor="{DynamicResource primary-back-title-color}"
|
||||
IsVisible="{Binding IsIdle}"
|
||||
Padding="20,0,20,0">
|
||||
|
||||
<!--Line-->
|
||||
<BoxView
|
||||
HeightRequest="1"
|
||||
WidthRequest="400"
|
||||
HorizontalOptions="Center"
|
||||
Color="White"/>
|
||||
|
||||
<Grid
|
||||
ColumnDefinitions="Auto,1*"
|
||||
RowDefinitions="Auto"
|
||||
Padding="0,0,0,5">
|
||||
|
||||
<!--Station id-->
|
||||
<Label
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
FontSize="Small"
|
||||
HorizontalOptions="Start"
|
||||
TextColor="White"
|
||||
Text="{Binding StationDetailText}"/>
|
||||
|
||||
<!--Contact to operator-->
|
||||
<Label
|
||||
Grid.Column="1"
|
||||
Grid.Row="0"
|
||||
TextType="Html"
|
||||
FontSize="Small"
|
||||
HorizontalOptions="End"
|
||||
TextColor="White"
|
||||
Text="{Binding ContactSupportHintText}">
|
||||
<Label.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding ContactSupportClickedCommand}"/>
|
||||
</Label.GestureRecognizers>
|
||||
</Label>
|
||||
|
||||
</Grid>
|
||||
|
||||
</StackLayout>
|
||||
|
||||
<!--If Not Connected To Internet-->
|
||||
<sharedGui:NotConnectedToNetView/>
|
||||
|
||||
<!--Bike data-->
|
||||
<Grid
|
||||
RowDefinitions="Auto,1*"
|
||||
RowSpacing="0">
|
||||
|
||||
<!--Hint for Outdated Data.-->
|
||||
<sharedGui:HintForRefreshingPageView
|
||||
Grid.Row="0"/>
|
||||
|
||||
<!--Bike(s)-->
|
||||
<ListView
|
||||
Grid.Row="1"
|
||||
x:Name="BikesAtStationListView"
|
||||
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}"/>
|
||||
|
||||
<!--No Bikes-->
|
||||
<Label
|
||||
Grid.Row="1"
|
||||
Margin="20"
|
||||
IsVisible="{Binding IsNoBikesAtStationVisible}"
|
||||
Text="{Binding NoBikesAtStationText}"/>
|
||||
|
||||
</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
|
||||
IsVisible="{Binding IsProcessWithRunningProcessView}"
|
||||
Grid.Row="0"/>
|
||||
|
||||
<!--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>
|
|
@ -0,0 +1,191 @@
|
|||
|
||||
using ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace ShareeBike.View.BikesAtStation
|
||||
{
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ShareeBike.Model.Device;
|
||||
using ShareeBike.ViewModel;
|
||||
using ShareeBike.Model;
|
||||
using ShareeBike.Services.BluetoothLock.Tdo;
|
||||
using System.Collections.Generic;
|
||||
using Serilog;
|
||||
using ShareeBike.Services.BluetoothLock;
|
||||
using Plugin.BLE;
|
||||
using ShareeBike.ViewModel.BikesAtStation;
|
||||
using ShareeBike.ViewModel.Bikes;
|
||||
using Xamarin.CommunityToolkit.Extensions;
|
||||
using ShareeBike.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS;
|
||||
using ShareeBike.MultilingualResources;
|
||||
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class BikesAtStationPage : ContentPage, IViewService
|
||||
{
|
||||
|
||||
private BikesAtStationPageViewModel m_oViewModel;
|
||||
|
||||
/// <summary> Initialization status to ensure initialization logic is not called multiple times. </summary>
|
||||
private bool isInitializationStarted = false;
|
||||
public BikesAtStationPage()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when page is shown.
|
||||
/// Starts update process.
|
||||
/// </summary>
|
||||
protected async override void OnAppearing()
|
||||
{
|
||||
// Don't repeat the initialization if it has been completed already.
|
||||
if (isInitializationStarted) return;
|
||||
isInitializationStarted = true;
|
||||
|
||||
if (m_oViewModel != null)
|
||||
{
|
||||
// No need to create view model, set binding context an items source if already done.
|
||||
// If done twice tap events are fired multiple times (when hiding page using home button).
|
||||
await m_oViewModel.OnAppearingOrRefresh();
|
||||
isInitializationStarted = false;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var model = App.ModelRoot;
|
||||
|
||||
m_oViewModel = new BikesAtStationPageViewModel(
|
||||
model.ActiveUser,
|
||||
App.PermissionsService,
|
||||
App.BluetoothService,
|
||||
Device.RuntimePlatform,
|
||||
model.SelectedStation,
|
||||
() => model.GetIsConnected(),
|
||||
(isConnected) => model.GetConnector(isConnected),
|
||||
App.LocationServicesContainer.Active,
|
||||
model.LocksServices.Active,
|
||||
model.Polling,
|
||||
(url) => DependencyService.Get<IExternalBrowserService>().OpenUrl(url),
|
||||
model.PostAction,
|
||||
model.SmartDevice,
|
||||
this)
|
||||
{
|
||||
IsReportLevelVerbose = model.IsReportLevelVerbose
|
||||
};
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext<BikesAtStationPage>().Error("Displaying bikes at station page failed. {Exception}", exception);
|
||||
|
||||
await DisplayAlert(
|
||||
AppResources.ErrorPageNotLoadedTitle,
|
||||
$"{AppResources.ErrorPageNotLoaded}\r\n{exception.Message}",
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
isInitializationStarted = false;
|
||||
return;
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
BindingContext = m_oViewModel;
|
||||
BikesAtStationListView.ItemsSource = m_oViewModel;
|
||||
|
||||
await m_oViewModel.OnAppearingOrRefresh();
|
||||
isInitializationStarted = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when pages is closed/ hidden.
|
||||
/// Stops update process.
|
||||
/// </summary>
|
||||
protected async override void OnDisappearing()
|
||||
{
|
||||
if (m_oViewModel != null)
|
||||
{
|
||||
// View model might be null.
|
||||
await m_oViewModel?.OnDisappearing();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handeles pressing of the Android hardware back button.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected override bool OnBackButtonPressed() => !m_oViewModel.IsIdle;
|
||||
|
||||
/// <summary> Displays alert message.</summary>
|
||||
/// <param name="title">Title of message.</param>
|
||||
/// <param name="message">Message to display.</param>
|
||||
/// <param name="cancel">Type of buttons.</param>
|
||||
public new async Task DisplayAlert(string title, string message, string cancel)
|
||||
=> await App.Current.MainPage.DisplayAlert(title, message, cancel);
|
||||
|
||||
/// <summary> Displays alert message.</summary>
|
||||
/// <param name="title">Title of message.</param>
|
||||
/// <param name="message">Message to display.</param>
|
||||
/// <param name="details">Detailed error description.</param>
|
||||
/// <param name="cancel">Type of buttons.</param>
|
||||
public async Task DisplayAdvancedAlert(
|
||||
string title,
|
||||
string message,
|
||||
string details,
|
||||
string cancel)
|
||||
=> await App.Current.MainPage.DisplayAlert(title, $"{message}\r\nDetails:\r\n{details}", cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Displays alert message.
|
||||
/// </summary>
|
||||
/// <param name="title">Title of message.</param>
|
||||
/// <param name="message">Message to display.</param>
|
||||
/// <param name="accept">Text of accept button.</param>
|
||||
/// <param name="cancel">Text of button.</param>
|
||||
/// <returns>True if user pressed accept.</returns>
|
||||
public new async Task<bool> DisplayAlert(string title, string message, string accept, string cancel)
|
||||
=> await App.Current.MainPage.DisplayAlert(title, message, accept, cancel);
|
||||
|
||||
/// <summary> Displays detailed alert message.</summary>
|
||||
/// <param name="title">Title of message.</param>
|
||||
/// <param name="message">Message to display.</param>
|
||||
/// <param name="details">Detailed error description.</param>
|
||||
/// <param name="accept">Text of accept button.</param>
|
||||
/// <param name="cancel">Text of cancel button.</param>
|
||||
/// <returns>True if user pressed accept.</returns>
|
||||
public async Task<bool> DisplayAdvancedAlert(string title, string message, string details, string accept, string cancel)
|
||||
=> await App.Current.MainPage.DisplayAlert(title, !string.IsNullOrEmpty(details) ? $"{message}\r\nDetails:\r\n{details}" : $"{message}", accept, cancel);
|
||||
|
||||
|
||||
/// <summary> Shows a page.</summary>
|
||||
/// <param name="route">Route of the page to show.</param>
|
||||
public async Task ShowPage(string route) => await Shell.Current.GoToAsync(route);
|
||||
|
||||
/// <summary> Pushes a page onto the modal stack. </summary>
|
||||
/// <param name="typeOfPage">Page to display.</param>
|
||||
public async Task PushModalAsync(ViewTypes typeOfPage)
|
||||
=> await Navigation.PushModalAsync((Page)Activator.CreateInstance(typeOfPage.GetViewType()));
|
||||
|
||||
/// <summary> Pops a page from the modal stack. </summary>
|
||||
public Task PopModalAsync()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public Task PushAsync(ViewTypes p_oTypeOfPage)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#if USCSHARP9
|
||||
public async Task<IViewService.IUserFeedback> DisplayUserFeedbackPopup() => await Navigation.ShowPopupAsync<FeedbackPopup.Result>(new FeedbackPopup());
|
||||
#else
|
||||
/// <summary> Displays user feedback popup.</summary>
|
||||
/// <returns>User feedback.</returns>
|
||||
public async Task<IUserFeedback> DisplayUserFeedbackPopup(IBatteryMutable battery = null) => await Navigation.ShowPopupAsync<FeedbackPopup.Result>(new FeedbackPopup(battery));
|
||||
#endif
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue