mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-28 07:16:27 +02:00
Version 3.0.371
This commit is contained in:
parent
bdb2dec1c1
commit
6d22dbf40b
145 changed files with 2289 additions and 764 deletions
|
@ -3,6 +3,7 @@ using System;
|
|||
using System.ComponentModel;
|
||||
using System.Text.RegularExpressions;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS;
|
||||
#if !USEFLYOUT
|
||||
#endif
|
||||
using TINK.Model.Connector;
|
||||
|
@ -136,20 +137,32 @@ namespace TINK.ViewModel.Bikes.Bike
|
|||
selectedBike.PropertyChanged +=
|
||||
(sender, eventargs) => OnSelectedBikePropertyChanged(eventargs.PropertyName);
|
||||
|
||||
var battery = selectedBike.Drive?.Battery;
|
||||
if (battery != null)
|
||||
{
|
||||
battery.PropertyChanged += (_, args) =>
|
||||
{
|
||||
if (args.PropertyName == nameof(BatteryMutable.CurrentChargeBars))
|
||||
{
|
||||
RaisePropertyChanged(this, new PropertyChangedEventArgs(nameof(CurrentChargeBars)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
BikesViewModel = bikesViewModel
|
||||
?? throw new ArgumentException($"Can not construct {GetType().Name}-object. {nameof(bikesViewModel)} must not be null.");
|
||||
|
||||
OpenUrlInBrowser = openUrlInBrowser ?? (url => { Log.ForContext<BikeViewModelBase>().Error($"No browse service avialble to upen {url}."); });
|
||||
OpenUrlInBrowser = openUrlInBrowser ?? (url => { Log.ForContext<BikeViewModelBase>().Error($"No browse service available to open {url}."); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles BikeInfoMutable events.
|
||||
/// Helper member to raise events. Maps model event change notification to view model events.
|
||||
/// </summary>
|
||||
/// <param name="p_strNameOfProp"></param>
|
||||
private void OnSelectedBikePropertyChanged(string p_strNameOfProp)
|
||||
/// <param name="nameOfProp"></param>
|
||||
private void OnSelectedBikePropertyChanged(string nameOfProp)
|
||||
{
|
||||
if (p_strNameOfProp == nameof(State))
|
||||
if (nameOfProp == nameof(State))
|
||||
{
|
||||
OnSelectedBikeStateChanged(); // Notify derived class about change of state.
|
||||
}
|
||||
|
@ -211,7 +224,7 @@ namespace TINK.ViewModel.Bikes.Bike
|
|||
Bike.Drive.Type == Model.Bikes.BikeInfoNS.DriveNS.DriveType.Pedelec
|
||||
&& (!Bike.Drive.Battery.IsHidden.HasValue /* no value means show battery level */ || Bike.Drive.Battery.IsHidden.Value == false);
|
||||
|
||||
/// Gets the image path for bike type Citybike, CargoLong, Trike or Pedelec.
|
||||
/// Gets the image path for bike type City bike, CargoLong, Trike or Pedelec.
|
||||
public string DisplayedBikeImageSourceString => $"bike_{Bike.TypeOfBike}_{Bike.Drive.Type}_{Bike.WheelType}.png";
|
||||
|
||||
/// <summary>
|
||||
|
@ -302,7 +315,7 @@ namespace TINK.ViewModel.Bikes.Bike
|
|||
/// <summary>
|
||||
/// Gets reserved into display text.
|
||||
/// </summary>
|
||||
/// <todo>Log unexpeced states.</todo>
|
||||
/// <todo>Log unexpected states.</todo>
|
||||
/// <param name="p_oInUseState"></param>
|
||||
/// <returns>Display text</returns>
|
||||
private string GetReservedInfo(
|
||||
|
@ -316,7 +329,7 @@ namespace TINK.ViewModel.Bikes.Bike
|
|||
/// <summary>
|
||||
/// Gets booked into display text.
|
||||
/// </summary>
|
||||
/// <todo>Log unexpeced states.</todo>
|
||||
/// <todo>Log unexpected states.</todo>
|
||||
/// <param name="p_oInUseState"></param>
|
||||
/// <returns>Display text</returns>
|
||||
private string GetBookedInfo(
|
||||
|
@ -366,7 +379,7 @@ namespace TINK.ViewModel.Bikes.Bike
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary> Holds description about the tarif. </summary>
|
||||
/// <summary> Holds description about the tariff. </summary>
|
||||
public TariffDescriptionViewModel TariffDescription => new TariffDescriptionViewModel(Bike.TariffDescription);
|
||||
|
||||
/// <summary> Gets the value of property <see cref="StateColor"/> when PropertyChanged was fired. </summary>
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
{
|
||||
public Xamarin.Forms.Command ShowTrackingInfoCommand { get; private set; }
|
||||
public Xamarin.Forms.Command ShowRideTypeInfoCommand { get; private set; }
|
||||
public Xamarin.Forms.Command ShowBikeIsBoundToCityInfoCommand { get; private set; }
|
||||
|
||||
/// <summary> Notifies GUI about changes. </summary>
|
||||
public override event PropertyChangedEventHandler PropertyChanged;
|
||||
|
@ -123,6 +124,16 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
|
||||
});
|
||||
|
||||
ShowBikeIsBoundToCityInfoCommand = new Xamarin.Forms.Command(async () => {
|
||||
|
||||
// later, if value comes from backend: message = TariffDescription.CityAreaType
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.MessageBikeIsBoundToCityInfoTitle,
|
||||
String.Format(AppResources.MessageBikeIsBoundToCityInfoText,selectedBike.TypeOfBike),
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
});
|
||||
|
||||
RequestHandler = user.IsLoggedIn
|
||||
? RequestHandlerFactory.Create(
|
||||
selectedBike,
|
||||
|
@ -178,6 +189,9 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
RaisePropertyChangedEvent(lastHandler);
|
||||
}
|
||||
|
||||
public bool IsBikeBoundToCity
|
||||
=> Bike.AaRideType == TINK.Model.Bikes.BikeInfoNS.BikeNS.AaRideType.NoAaRide ? true : false;
|
||||
|
||||
/// <summary> Gets visibility of the copri command button. </summary>
|
||||
public bool IsButtonVisible
|
||||
=> RequestHandler.IsButtonVisible;
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model;
|
||||
using TINK.MultilingualResources;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.Repository.Request;
|
||||
using TINK.Services.Logging;
|
||||
using TINK.View;
|
||||
using static TINK.Model.Bikes.BikeInfoNS.BluetoothLock.Command.CloseCommand;
|
||||
using TINK.Services.BluetoothLock;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
||||
|
@ -33,20 +28,6 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
/// </summary>
|
||||
private IViewService ViewService { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Service to control locks.
|
||||
/// </summary>
|
||||
private ILocksService LockService { get; }
|
||||
|
||||
/// <summary> Provides a connector object.</summary>
|
||||
protected Func<bool, IConnector> ConnectorFactory { get; }
|
||||
|
||||
/// <summary> Delegate to retrieve connected state. </summary>
|
||||
private Func<bool> IsConnectedDelegate { get; }
|
||||
|
||||
/// <summary>Gets the is connected state. </summary>
|
||||
bool IsConnected;
|
||||
|
||||
/// <summary>Object to start or stop update of view model objects from Copri.</summary>
|
||||
private Func<IPollingUpdateTaskManager> ViewUpdateManager { get; }
|
||||
|
||||
|
@ -83,7 +64,6 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
switch (step)
|
||||
{
|
||||
case Step.StartStopingPolling:
|
||||
BikesViewModel.ActionText = AppResources.ActivityTextOneMomentPlease;
|
||||
break;
|
||||
|
||||
case Step.StartingQueryingLocation:
|
||||
|
@ -188,12 +168,12 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
|
||||
// 1. Step
|
||||
// Parameter for RentalProcess View
|
||||
BikesViewModel.RentalProcess = new RentalProcess(SelectedBike.Id)
|
||||
BikesViewModel.StartRentalProcess(new RentalProcessViewModel(SelectedBike.Id)
|
||||
{
|
||||
State = CurrentRentalProcess.CloseLock,
|
||||
StepIndex = 1,
|
||||
Result = CurrentStepStatus.None
|
||||
};
|
||||
});
|
||||
|
||||
// Close Lock
|
||||
BikesViewModel.RentalProcess.StepInfoText = AppResources.MarkingRentalProcessCloseLockStepCloseLock;
|
||||
|
@ -215,9 +195,8 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
await ViewUpdateManager().StartAsync();
|
||||
|
||||
BikesViewModel.ActionText = string.Empty;
|
||||
BikesViewModel.IsIdle = true;
|
||||
|
||||
BikesViewModel.RentalProcess.State = CurrentRentalProcess.None;
|
||||
BikesViewModel.IsIdle = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -231,90 +210,31 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
BikesViewModel.RentalProcess.Result = CurrentStepStatus.None;
|
||||
BikesViewModel.RentalProcess.ImportantStepInfoText = String.Empty;
|
||||
|
||||
//// Ask if lock is closed
|
||||
//var isLockClosed = await ViewService.DisplayAlert(
|
||||
// AppResources.QuestionRentalProcessCloseLockCheckLockTitle,
|
||||
// AppResources.QuestionRentalProcessCloseLockCheckLockText,
|
||||
// AppResources.QuestionRentalProcessCloseLockCheckLockAnswerYes,
|
||||
// AppResources.QuestionRentalProcessCloseLockCheckLockAnswerNo);
|
||||
// Question if park bike or end rental
|
||||
IsEndRentalRequested = await ViewService.DisplayAlert(
|
||||
AppResources.QuestionRentalProcessCloseLockEndOrContinueTitle,
|
||||
AppResources.QuestionRentalProcessCloseLockEndOrContinueText,
|
||||
AppResources.QuestionRentalProcessCloseLockEndRentalAnswer,
|
||||
AppResources.QuestionRentalProcessCloseLockContinueRentalAnswer);
|
||||
|
||||
//// If lock is not closed
|
||||
//if(isLockClosed == false)
|
||||
//{
|
||||
// var retryOrContactresult = await ViewService.DisplayAlert(
|
||||
// AppResources.MessageRentalProcessCloseLockNotClosedTitle,
|
||||
// AppResources.MessageRentalProcessCloseLockNotClosedText,
|
||||
// AppResources.MessageAnswerRetry,
|
||||
// AppResources.MessageAnswerContactSupport);
|
||||
BikesViewModel.RentalProcess.Result = CurrentStepStatus.Succeeded;
|
||||
|
||||
// BikesViewModel.RentalProcess.Result = CurrentStepStatus.Failed;
|
||||
|
||||
// if (retryOrContactresult == true)
|
||||
// {
|
||||
// //restart CloseLock()
|
||||
// }
|
||||
// else if(retryOrContactresult == false)
|
||||
// {
|
||||
// await OpenContactPageAsync();
|
||||
// }
|
||||
//}
|
||||
// If lock is closed
|
||||
//else if(isLockClosed == true)
|
||||
//{
|
||||
IsEndRentalRequested = await ViewService.DisplayAlert(
|
||||
AppResources.QuestionRentalProcessCloseLockEndOrContinueTitle,
|
||||
AppResources.QuestionRentalProcessCloseLockEndOrContinueText,
|
||||
AppResources.QuestionRentalProcessCloseLockEndRentalAnswer,
|
||||
AppResources.QuestionRentalProcessCloseLockContinueRentalAnswer);
|
||||
|
||||
BikesViewModel.RentalProcess.Result = CurrentStepStatus.Succeeded;
|
||||
|
||||
// Continue with End rental in RequestHandler
|
||||
if (IsEndRentalRequested == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Park bike
|
||||
else if(IsEndRentalRequested == false)
|
||||
{
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.MessageRentalProcessCloseLockFinishedTitle,
|
||||
AppResources.MessageRentalProcessCloseLockFinishedText,
|
||||
AppResources.MessageAnswerOk);
|
||||
}
|
||||
|
||||
//}
|
||||
// Message for parking bike
|
||||
if(IsEndRentalRequested == false)
|
||||
{
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.MessageRentalProcessCloseLockFinishedTitle,
|
||||
AppResources.MessageRentalProcessCloseLockFinishedText,
|
||||
AppResources.MessageAnswerOk);
|
||||
}
|
||||
|
||||
BikesViewModel.RentalProcess.State = CurrentRentalProcess.None;
|
||||
BikesViewModel.IsIdle = true;
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary> Opens support. </summary>
|
||||
//#if USEFLYOUT
|
||||
// public void OpenContactPageAsync()
|
||||
//#else
|
||||
// public async Task OpenContactPageAsync()
|
||||
//#endif
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// // Open Contact Page with Contact information for operator of SelectedBike
|
||||
//#if USEFLYOUT
|
||||
// ViewService.ShowPage(ViewTypes.ContactPage, AppResources.MarkingFeedbackAndContact);
|
||||
//#else
|
||||
// await ViewService.ShowPage("//ContactPage");
|
||||
//#endif
|
||||
// }
|
||||
// catch (Exception p_oException)
|
||||
// {
|
||||
// Log.Error("Ein unerwarteter Fehler ist auf der Seite Kontakt aufgetreten. Kontext: Klick auf Konakt aufnehmen bei Schloss schließen (Schloss nicht zu!). {@Exception}", p_oException);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// True if user requested End rental.
|
||||
/// Default value of user request to end rental = false.
|
||||
/// </summary>
|
||||
private bool isEndRentalRequested = false;
|
||||
|
||||
|
|
|
@ -76,12 +76,12 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
?? throw new ArgumentException($"Can not construct {typeof(EndRentalActionViewModel<T>)}-object. {nameof(bikesViewModel)} must not be null.");
|
||||
|
||||
// Set parameter for RentalProcess View to initial value.
|
||||
BikesViewModel.RentalProcess = new RentalProcess(SelectedBike.Id)
|
||||
BikesViewModel.StartRentalProcess(new RentalProcessViewModel(SelectedBike.Id)
|
||||
{
|
||||
State = CurrentRentalProcess.None,
|
||||
StepIndex = 0,
|
||||
Result = CurrentStepStatus.None
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -155,12 +155,12 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
|
||||
// 1. Step
|
||||
// Parameter for RentalProcess View
|
||||
BikesViewModel.RentalProcess = new RentalProcess(SelectedBike.Id)
|
||||
BikesViewModel.StartRentalProcess(new RentalProcessViewModel(SelectedBike.Id)
|
||||
{
|
||||
State = CurrentRentalProcess.EndRental,
|
||||
StepIndex = 1,
|
||||
Result = CurrentStepStatus.None
|
||||
};
|
||||
});
|
||||
|
||||
// Get Location
|
||||
BikesViewModel.RentalProcess.StepInfoText = AppResources.MarkingRentalProcessEndRentalStepGPS;
|
||||
|
@ -271,7 +271,16 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
BikesViewModel.RentalProcess.ImportantStepInfoText = String.Empty;
|
||||
|
||||
var feedBackUri = SelectedBike?.OperatorUri;
|
||||
var feedback = await ViewService.DisplayUserFeedbackPopup(SelectedBike.Drive?.Battery);
|
||||
var battery = SelectedBike.Drive?.Battery;
|
||||
var feedback = await ViewService.DisplayUserFeedbackPopup(
|
||||
battery,
|
||||
bookingFinished?.Co2Saving);
|
||||
|
||||
if (battery != null
|
||||
&& feedback.CurrentChargeBars != null)
|
||||
{
|
||||
SelectedBike.Drive.Battery.CurrentChargeBars = feedback.CurrentChargeBars;
|
||||
}
|
||||
#endif
|
||||
BikesViewModel.RentalProcess.Result = CurrentStepStatus.Succeeded;
|
||||
|
||||
|
|
|
@ -62,7 +62,16 @@ namespace TINK.ViewModel.Bikes.Bike.CopriLock.RequestHandler
|
|||
await ViewUpdateManager().StopAsync();
|
||||
|
||||
// Do get Feedback
|
||||
var feedback = await ViewService.DisplayUserFeedbackPopup(SelectedBike.Drive?.Battery, SelectedBike?.BookingFinishedModel?.Co2Saving);
|
||||
var battery = SelectedBike.Drive?.Battery;
|
||||
var feedback = await ViewService.DisplayUserFeedbackPopup(
|
||||
battery,
|
||||
SelectedBike?.BookingFinishedModel?.Co2Saving);
|
||||
|
||||
if (battery != null
|
||||
&& feedback.CurrentChargeBars != null)
|
||||
{
|
||||
SelectedBike.Drive.Battery.CurrentChargeBars = feedback.CurrentChargeBars;
|
||||
}
|
||||
|
||||
BikesViewModel.ActionText = AppResources.ActivityTextSubmittingFeedback;
|
||||
IsConnected = IsConnectedDelegate();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue