mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 13:57:28 +02:00
Version 3.0.366
This commit is contained in:
parent
0eb7362cb8
commit
24cdfbb0ca
84 changed files with 900 additions and 393 deletions
|
@ -10,10 +10,13 @@ using Plugin.BLE.Abstractions.Contracts;
|
|||
using Serilog;
|
||||
using TINK.Model;
|
||||
using TINK.Model.Bikes;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Connector.Filter;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.Services.CopriApi;
|
||||
using TINK.Model.State;
|
||||
using TINK.Model.Stations.StationNS;
|
||||
using TINK.Model.User;
|
||||
using TINK.MultilingualResources;
|
||||
|
@ -25,6 +28,7 @@ using TINK.Services.Permissions;
|
|||
using TINK.Settings;
|
||||
using TINK.View;
|
||||
using TINK.ViewModel.Bikes;
|
||||
using TINK.ViewModel.Map;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
using Command = Xamarin.Forms.Command;
|
||||
|
@ -84,13 +88,13 @@ namespace TINK.ViewModel.FindBike
|
|||
/// <summary>
|
||||
/// True if ListView of Bikes is refreshing after user pulled;
|
||||
/// </summary>
|
||||
private bool _isRefreshing = false;
|
||||
private bool isRefreshing = false;
|
||||
public bool IsRefreshing
|
||||
{
|
||||
get { return _isRefreshing; }
|
||||
get { return isRefreshing; }
|
||||
set
|
||||
{
|
||||
_isRefreshing = value;
|
||||
isRefreshing = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsRefreshing)));
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +103,7 @@ namespace TINK.ViewModel.FindBike
|
|||
/// Holds what should be executed on pull to refresh
|
||||
/// </summary>
|
||||
public Command RefreshCommand { get; }
|
||||
public Command ShowFilterBikeTypeInfoCommand { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs bike collection view model in case information about occupied bikes is available.
|
||||
|
@ -146,6 +151,15 @@ namespace TINK.ViewModel.FindBike
|
|||
await SelectBike();
|
||||
|
||||
});
|
||||
|
||||
ShowFilterBikeTypeInfoCommand = new Xamarin.Forms.Command(async () => {
|
||||
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.MessageBikeTypeInfoTitle,
|
||||
AppResources.MessageBikeTypeInfoText,
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -158,6 +172,8 @@ namespace TINK.ViewModel.FindBike
|
|||
|
||||
Log.ForContext<FindBikePageViewModel>().Information("User request to show page FindBike- page re-appearing");
|
||||
|
||||
ActiveFilteredBikeType = string.Empty;
|
||||
|
||||
IsConnected = IsConnectedDelegate();
|
||||
|
||||
// Stop polling before getting bikes info.
|
||||
|
@ -185,6 +201,19 @@ namespace TINK.ViewModel.FindBike
|
|||
|
||||
ActionText = string.Empty;
|
||||
IsIdle = true;
|
||||
|
||||
var result = await ConnectorFactory(IsConnected).Query.GetBikesAsync();
|
||||
var bikes = result.Response;
|
||||
|
||||
var exception = result.Exception;
|
||||
if (exception != null)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting bikes in polling context failed with exception {Exception}.", exception);
|
||||
}
|
||||
|
||||
// Get Active Filtered BikeType
|
||||
GetActiveFilteredBikeType(bikes);
|
||||
|
||||
}
|
||||
|
||||
/// <summary> Command object to bind select bike button to view model. </summary>
|
||||
|
@ -209,7 +238,7 @@ namespace TINK.ViewModel.FindBike
|
|||
if (exception is WebConnectFailureException)
|
||||
{
|
||||
// Copri server is not reachable.
|
||||
Log.ForContext<FindBikePageViewModel>().Information("Getting bikes failed failed (Copri server not reachable).");
|
||||
Log.ForContext<FindBikePageViewModel>().Information("Getting bikes failed (Copri server not reachable).");
|
||||
|
||||
await ViewService.DisplayAdvancedAlert(
|
||||
AppResources.ErrorReturnBikeNoWebTitle,
|
||||
|
@ -402,6 +431,9 @@ namespace TINK.ViewModel.FindBike
|
|||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
|
||||
BikeIdUserInput = string.Empty;
|
||||
|
||||
}
|
||||
|
||||
/// <summary> Create task which updates my bike view model.</summary>
|
||||
|
@ -417,13 +449,12 @@ namespace TINK.ViewModel.FindBike
|
|||
null);
|
||||
|
||||
var result = ConnectorFactory(IsConnected).Query.GetBikesAsync().Result;
|
||||
|
||||
var bikes = result.Response;
|
||||
|
||||
var exception = result.Exception;
|
||||
if (exception != null)
|
||||
{
|
||||
Log.ForContext<FindBikePageViewModel>().Error("Getting bikes occupied in polling context failed with exception {Exception}.", exception);
|
||||
Log.ForContext<FindBikePageViewModel>().Error("Getting bikes in polling context failed with exception {Exception}.", exception);
|
||||
}
|
||||
|
||||
var selectedBike = bikes.FirstOrDefault(x => x.Id.Equals(BikeIdUserInput.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||
|
@ -441,5 +472,44 @@ namespace TINK.ViewModel.FindBike
|
|||
},
|
||||
null);
|
||||
}
|
||||
|
||||
private string activeFilteredBikeType = string.Empty;
|
||||
/// <summary>
|
||||
/// Selected Bike Type in MapFilter
|
||||
/// </summary>
|
||||
public string ActiveFilteredBikeType
|
||||
{
|
||||
get { return activeFilteredBikeType; }
|
||||
set
|
||||
{
|
||||
if (value == activeFilteredBikeType)
|
||||
{
|
||||
return;
|
||||
}
|
||||
activeFilteredBikeType = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(ActiveFilteredBikeType)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Selected Bike Type in MapFilter
|
||||
/// </summary>
|
||||
public void GetActiveFilteredBikeType(BikeCollection bikesAll)
|
||||
{
|
||||
Log.ForContext<FindBikePageViewModel>().Debug($"Bike type of active filter is extracted.");
|
||||
if (bikesAll != null)
|
||||
{
|
||||
var firstOrDefaultBikeType = bikesAll.FirstOrDefault().TypeOfBike;
|
||||
if(firstOrDefaultBikeType == TypeOfBike.Cargo)
|
||||
{
|
||||
ActiveFilteredBikeType = AppResources.MarkingCargoBike;
|
||||
}
|
||||
else if(firstOrDefaultBikeType == TypeOfBike.City)
|
||||
{
|
||||
ActiveFilteredBikeType = AppResources.MarkingCityBike;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue