Version 3.0.360

This commit is contained in:
Anja 2023-02-22 14:03:35 +01:00
parent 5c0b2e70c9
commit faf68061f4
160 changed files with 2114 additions and 1932 deletions

View file

@ -2,9 +2,11 @@ using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Plugin.Connectivity;
using TINK.Model.Connector;
using TINK.Model.Device;
using TINK.Model.User;
using TINK.MultilingualResources;
using TINK.Services.BluetoothLock;
using TINK.Services.Geolocation;
using TINK.View;
@ -20,6 +22,8 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
/// </summary>
public class BikeViewModel : BikeViewModelBase, INotifyPropertyChanged
{
public Xamarin.Forms.Command ShowTrackingInfoCommand { get; private set; }
/// <summary> Notifies GUI about changes. </summary>
public override event PropertyChangedEventHandler PropertyChanged;
@ -39,12 +43,6 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
string lastStateText = null,
Xamarin.Forms.Color? lastStateColor = null)
{
if (IsDataFromCache != IsDataFromCache)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsDataFromCache)));
}
if (lastHandler.ButtonText != ButtonText)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ButtonText)));
@ -105,6 +103,15 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
IBikesViewModel bikesViewModel,
Action<string> openUrlInBrowser) : base(isConnectedDelegate, connectorFactory, bikeRemoveDelegate, viewUpdateManager, smartDevice, viewService, selectedBike, user, stateInfoProvider, bikesViewModel, openUrlInBrowser)
{
ShowTrackingInfoCommand = new Xamarin.Forms.Command(async () => {
await ViewService.DisplayAlert(
"Tracking",
TariffDescription.TrackingInfoText,
AppResources.MessageAnswerOk);
});
RequestHandler = user.IsLoggedIn
? RequestHandlerFactory.Create(
selectedBike,
@ -132,7 +139,6 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsButtonVisible)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsLockitButtonVisible)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsDataFromCache)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(OnButtonClicked)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(OnLockitButtonClicked)));
};
@ -175,15 +181,13 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
/// <summary> Gets the text of the ILockIt command button. </summary>
public string LockitButtonText => RequestHandler.LockitButtonText;
/// <summary> True if Data is from Cache. </summary>
public bool IsDataFromCache
=> Bike.DataSource == Model.Bikes.BikeInfoNS.BC.DataSource.Cache;
/// <summary> Processes request to perform a copri action (reserve bike and cancel reservation).
/// Button only enabled if data is up to date = not from cache. </summary>
public System.Windows.Input.ICommand OnButtonClicked => new Xamarin.Forms.Command(async () => await ClickButton(RequestHandler.HandleRequestOption1()));
/// <summary> Processes request to perform a copri action (reserve bike and cancel reservation). </summary>
public System.Windows.Input.ICommand OnButtonClicked => new Xamarin.Forms.Command(async () => await ClickButton(RequestHandler.HandleRequestOption1()), () => !IsDataFromCache);
/// <summary> Processes request to perform a ILockIt action (unlock bike and lock bike). </summary>
public System.Windows.Input.ICommand OnLockitButtonClicked => new Xamarin.Forms.Command(async () => await ClickButton(RequestHandler.HandleRequestOption2()), () => !IsDataFromCache);
/// <summary> Processes request to perform a ILockIt action (unlock bike and lock bike).
/// Button only enabled if data is up to date = not from cache. </summary>
public System.Windows.Input.ICommand OnLockitButtonClicked => new Xamarin.Forms.Command(async () => await ClickButton(RequestHandler.HandleRequestOption2()));
/// <summary> Processes request to perform a copri action (reserve bike and cancel reservation). </summary>
private async Task ClickButton(Task<IRequestHandler> handleRequest)

View file

@ -342,16 +342,16 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
await ViewService.DisplayAlert(
AppResources.ErrorOpenLockTitle,
AppResources.ErrorOpenLockBoldBlockedMessage,
AppResources.ErrorOpenLockBoldIsBlockedMessage,
AppResources.MessageAnswerOk);
}
else if (exception is CouldntOpenBoldWasBlockedException)
else if (exception is CouldntOpenBoldStatusIsUnknownException)
{
Log.ForContext<BookedClosed>().Debug("Lock can not be opened. Bold was or is blocked. {Exception}", exception);
Log.ForContext<BookedClosed>().Debug("Lock can not be opened. Bold status is unknown. {Exception}", exception);
await ViewService.DisplayAlert(
AppResources.ErrorOpenLockStillOpenTitle,
AppResources.ErrorOpenLockBoldWasBlockedMessage,
AppResources.ErrorOpenLockStillClosedTitle,
AppResources.ErrorOpenLockBoldStatusIsUnknownMessage,
"OK");
}
else if (exception is CouldntOpenInconsistentStateExecption inconsistentState

View file

@ -94,16 +94,16 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
await ViewService.DisplayAlert(
AppResources.ErrorOpenLockTitle,
AppResources.ErrorOpenLockBoldBlockedMessage,
AppResources.ErrorOpenLockBoldIsBlockedMessage,
AppResources.MessageAnswerOk);
}
else if (exception is CouldntOpenBoldWasBlockedException)
else if (exception is CouldntOpenBoldStatusIsUnknownException)
{
Log.ForContext<BookedUnknown>().Debug("Lock can not be opened. Bold was or is blocked. {Exception}", exception);
Log.ForContext<BookedUnknown>().Debug("Lock can not be opened. Bold status is unknown. {Exception}", exception);
await ViewService.DisplayAlert(
AppResources.ErrorOpenLockStillOpenTitle,
AppResources.ErrorOpenLockBoldWasBlockedMessage,
AppResources.ErrorOpenLockStillClosedTitle,
AppResources.ErrorOpenLockBoldStatusIsUnknownMessage,
AppResources.MessageAnswerOk);
}
else if (exception is CouldntOpenInconsistentStateExecption inconsistentState

View file

@ -283,16 +283,16 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
await ViewService.DisplayAlert(
AppResources.ErrorOpenLockTitle,
AppResources.ErrorOpenLockBoldBlockedMessage,
AppResources.ErrorOpenLockBoldIsBlockedMessage,
AppResources.MessageAnswerOk);
}
else if (exception is CouldntOpenBoldWasBlockedException)
else if (exception is CouldntOpenBoldStatusIsUnknownException)
{
Log.ForContext<DisposableDisconnected>().Debug("Lock can not be opened. Bold was or is blocked. {Exception}", exception);
Log.ForContext<DisposableDisconnected>().Debug("Lock can not be opened. Bold status is unknown. {Exception}", exception);
await ViewService.DisplayAlert(
AppResources.ErrorOpenLockStillOpenTitle,
AppResources.ErrorOpenLockBoldWasBlockedMessage,
AppResources.ErrorOpenLockStillClosedTitle,
AppResources.ErrorOpenLockBoldStatusIsUnknownMessage,
AppResources.MessageAnswerOk);
}
else if (exception is CouldntOpenInconsistentStateExecption inconsistentState

View file

@ -248,16 +248,16 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
await ViewService.DisplayAlert(
AppResources.ErrorOpenLockTitle,
AppResources.ErrorOpenLockBoldBlockedMessage,
AppResources.ErrorOpenLockBoldIsBlockedMessage,
AppResources.MessageAnswerOk);
}
else if (exception is CouldntOpenBoldWasBlockedException)
else if (exception is CouldntOpenBoldStatusIsUnknownException)
{
Log.ForContext<ReservedClosed>().Debug("Lock can not be opened. Bold was or is blocked. {Exception}", exception);
Log.ForContext<ReservedClosed>().Debug("Lock can not be opened. Bold status is unknown. {Exception}", exception);
await ViewService.DisplayAlert(
AppResources.ErrorOpenLockStillOpenTitle,
AppResources.ErrorOpenLockBoldWasBlockedMessage,
AppResources.ErrorOpenLockStillClosedTitle,
AppResources.ErrorOpenLockBoldStatusIsUnknownMessage,
AppResources.MessageAnswerOk);
}
else if (exception is CouldntOpenInconsistentStateExecption inconsistentState

View file

@ -411,16 +411,16 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
await ViewService.DisplayAlert(
AppResources.ErrorOpenLockTitle,
AppResources.ErrorOpenLockBoldBlockedMessage,
AppResources.ErrorOpenLockBoldIsBlockedMessage,
AppResources.MessageAnswerOk);
}
else if (exception is CouldntOpenBoldWasBlockedException)
else if (exception is CouldntOpenBoldStatusIsUnknownException)
{
Log.ForContext<ReservedDisconnected>().Debug("Lock can not be opened. Bold was or is blocked. {Exception}", exception);
Log.ForContext<ReservedDisconnected>().Debug("Lock can not be opened. Bold status is unknown. {Exception}", exception);
await ViewService.DisplayAlert(
AppResources.ErrorOpenLockStillOpenTitle,
AppResources.ErrorOpenLockBoldWasBlockedMessage,
AppResources.ErrorOpenLockStillClosedTitle,
AppResources.ErrorOpenLockBoldStatusIsUnknownMessage,
AppResources.MessageAnswerOk);
}
else if (exception is CouldntOpenInconsistentStateExecption inconsistentState

View file

@ -86,20 +86,20 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
}
else if (exception is CouldntOpenBoldIsBlockedException)
{
Log.ForContext<ReservedUnknown>().Debug("Lock can not be opened. Bold is blocked. {Exception}", exception);
Log.ForContext<ReservedUnknown>().Debug("Lock can not be opened. bold is blocked. {Exception}", exception);
await ViewService.DisplayAlert(
AppResources.ErrorOpenLockTitle,
AppResources.ErrorOpenLockBoldBlockedMessage,
AppResources.ErrorOpenLockBoldIsBlockedMessage,
AppResources.MessageAnswerOk);
}
else if (exception is CouldntOpenBoldWasBlockedException)
else if (exception is CouldntOpenBoldStatusIsUnknownException)
{
Log.ForContext<ReservedUnknown>().Debug("Lock can not be opened. Bold was or is blocked. {Exception}", exception);
Log.ForContext<ReservedUnknown>().Debug("Lock can not be opened. lock reports state unkwnown. {Exception}", exception);
await ViewService.DisplayAlert(
AppResources.ErrorOpenLockStillOpenTitle,
AppResources.ErrorOpenLockBoldWasBlockedMessage,
AppResources.ErrorOpenLockStillClosedTitle,
AppResources.ErrorOpenLockBoldStatusIsUnknownMessage,
AppResources.MessageAnswerOk);
}
else if (exception is CouldntOpenInconsistentStateExecption inconsistentState

View file

@ -9,6 +9,8 @@ namespace TINK.ViewModel.Bikes.Bike
/// </summary>
public class TariffDescriptionViewModel
{
private const string TRACKINGKEY = "TRACKING";
public TariffDescriptionViewModel(RentalDescription tariff)
{
Name = tariff?.Name ?? string.Empty;
@ -18,8 +20,13 @@ namespace TINK.ViewModel.Bikes.Bike
: new ObservableCollection<RentalDescription.TariffElement>();
InfoEntries = tariff != null && tariff?.InfoEntries != null
? new ObservableCollection<string>(tariff.InfoEntries.OrderBy(x => x.Key).Select(x => x.Value.Value))
? new ObservableCollection<string>(tariff.InfoEntries
.Where(x => x.Value.Key.ToUpper() != TRACKINGKEY)
.OrderBy(x => x.Key)
.Select(x => x.Value.Value))
: new ObservableCollection<string>();
TrackingInfoText = tariff?.InfoEntries != null ? tariff?.InfoEntries?.FirstOrDefault(x => x.Value.Key.ToUpper() == TRACKINGKEY).Value?.Value ?? string.Empty : string.Empty;
}
/// <summary>
@ -37,11 +44,15 @@ namespace TINK.ViewModel.Bikes.Bike
/// </summary>
public ObservableCollection<string> InfoEntries { get; private set; }
/// <summary>
/// Holds the tracking info text or empty if not applicable.
/// </summary>
public string TrackingInfoText { get; private set; }
public RentalDescription.TariffElement TarifEntry1 => TariffEntries.Count > 0 ? TariffEntries[0] : new RentalDescription.TariffElement();
public RentalDescription.TariffElement TarifEntry2 => TariffEntries.Count > 1 ? TariffEntries[1] : new RentalDescription.TariffElement();
public RentalDescription.TariffElement TarifEntry3 => TariffEntries.Count > 2 ? TariffEntries[2] : new RentalDescription.TariffElement();
public RentalDescription.TariffElement TarifEntry4 => TariffEntries.Count > 3 ? TariffEntries[3] : new RentalDescription.TariffElement();
public RentalDescription.TariffElement TarifEntry5 => TariffEntries.Count > 4 ? TariffEntries[4] : new RentalDescription.TariffElement();
public RentalDescription.TariffElement TarifEntry6 => TariffEntries.Count > 5 ? TariffEntries[5] : new RentalDescription.TariffElement();
public RentalDescription.TariffElement TarifEntry7 => TariffEntries.Count > 6 ? TariffEntries[6] : new RentalDescription.TariffElement();

View file

@ -152,8 +152,6 @@ namespace TINK.ViewModel.Bikes
m_oPolling = polling;
isConnected = IsConnectedDelegate();
OpenUrlInBrowser = openUrlInBrowser;
CollectionChanged += (sender, eventargs) =>
@ -389,11 +387,6 @@ namespace TINK.ViewModel.Bikes
return Exception.GetShortErrorInfoText(IsReportLevelVerbose);
}
if (!IsConnected)
{
return AppResources.ActivityTextConnectionStateOffline;
}
return ActionText ?? string.Empty;
}
}

View file

@ -51,6 +51,9 @@ namespace TINK.ViewModel.BikesAtStation
}
}
/// <summary>
/// Holds what should be executed on pull to refresh
/// </summary>
public Command RefreshCommand { get; }
/// <summary>
@ -92,14 +95,10 @@ namespace TINK.ViewModel.BikesAtStation
? string.Format(AppResources.MarkingBikesAtStationStationId, Station.Id)
: string.Empty;
/// <summary>
/// Holds what should be executed on pull to refresh
/// </summary>
RefreshCommand = new Command(async () => {
IsRefreshing = true;
await OnAppearing();
IsRefreshing = false;
await OnAppearingOrRefresh();
});
@ -242,10 +241,12 @@ namespace TINK.ViewModel.BikesAtStation
/// Invoked when page is shown.
/// Starts update process.
/// </summary>
public async Task OnAppearing()
public async Task OnAppearingOrRefresh()
{
IsIdle = false;
IsConnected = IsConnectedDelegate();
Log.ForContext<BikesAtStationPageViewModel>().Information($"Bikes at station {Station.StationName} is appearing, either due to tap on a station or to app being shown again.");
ActionText = AppResources.ActivityTextOneMomentPlease;
@ -294,7 +295,7 @@ namespace TINK.ViewModel.BikesAtStation
await OnAppearing(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}
@ -316,7 +317,7 @@ namespace TINK.ViewModel.BikesAtStation
await OnAppearing(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
}
@ -332,7 +333,7 @@ namespace TINK.ViewModel.BikesAtStation
await OnAppearing(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}
@ -360,7 +361,7 @@ namespace TINK.ViewModel.BikesAtStation
// Backup GUI synchronization context.
await OnAppearing(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
}

View file

@ -299,7 +299,7 @@ namespace TINK.ViewModel.Contact
{
// User decided to give access to locations permissions.
PermissionsService.OpenAppSettings();
ActionText = "";
ActionText = string.Empty;
IsProcessWithRunningProcessView = false;
IsMapPageEnabled = true;
return;
@ -405,7 +405,7 @@ namespace TINK.ViewModel.Contact
Log.ForContext<SelectStationPageViewModel>().Verbose("Update pins color done.");
Exception = resultStationsAndBikes.Exception;
ActionText = "";
ActionText = string.Empty;
IsProcessWithRunningProcessView = false;
IsMapPageEnabled = true;
}
@ -472,12 +472,12 @@ namespace TINK.ViewModel.Contact
await ViewService.ShowPage("//ContactPage");
#endif
IsMapPageEnabled = true;
ActionText = "";
ActionText = string.Empty;
}
catch (Exception exception)
{
IsMapPageEnabled = true;
ActionText = "";
ActionText = string.Empty;
Log.ForContext<SelectStationPageViewModel>().Error("Fehler beim Öffnen der Ansicht \"Fahrräder an Station\" aufgetreten. {Exception}", exception);
await ViewService.DisplayAlert(

View file

@ -25,6 +25,7 @@ using TINK.Services.Permissions;
using TINK.Settings;
using TINK.View;
using TINK.ViewModel.Bikes;
using Xamarin.Essentials;
using Xamarin.Forms;
using Command = Xamarin.Forms.Command;
@ -94,6 +95,9 @@ namespace TINK.ViewModel.FindBike
}
}
/// <summary>
/// Holds what should be executed on pull to refresh
/// </summary>
public Command RefreshCommand { get; }
/// <summary>
@ -136,14 +140,10 @@ namespace TINK.ViewModel.FindBike
Stations = stations ?? throw new ArgumentException(nameof(stations));
/// <summary>
/// Holds what should be executed on pull to refresh
/// </summary>
RefreshCommand = new Command(async () => {
IsRefreshing = true;
await OnAppearing();
IsRefreshing = false;
await SelectBike();
});
}
@ -152,12 +152,17 @@ namespace TINK.ViewModel.FindBike
/// Invoked when page is shown.
/// Starts update process.
/// </summary>
public async Task OnAppearing()
public async Task OnAppearingOrRefresh()
{
IsIdle = false;
Log.ForContext<FindBikePageViewModel>().Information("User request to show page FindBike- page re-appearing");
IsConnected = IsConnectedDelegate();
// Stop polling before getting bikes info.
await m_oViewUpdateManager.StopUpdatePeridically();
if (string.IsNullOrEmpty(BikeIdUserInput) /* Find bike page flyout was taped */
&& BikeCollection.Count > 0 /* Bike was successfully selected */)
{
@ -173,12 +178,12 @@ namespace TINK.ViewModel.FindBike
// Restart update.
await StartUpdateTask(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
}
@ -192,6 +197,8 @@ namespace TINK.ViewModel.FindBike
ActionText = AppResources.ActivityTextFindBikeLoadingBikes;
IsIdle = false;
IsConnected = IsConnectedDelegate();
Result<BikeCollection> bikes = null;
try
{
@ -220,7 +227,7 @@ namespace TINK.ViewModel.FindBike
AppResources.MessageAnswerOk);
}
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}
@ -241,7 +248,7 @@ namespace TINK.ViewModel.FindBike
string.Format(AppResources.MessageErrorSelectBikeNoBikeFound, BikeIdUserInput),
AppResources.MessageAnswerOk);
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}
@ -289,7 +296,7 @@ namespace TINK.ViewModel.FindBike
await StartUpdateTask(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}
@ -313,7 +320,7 @@ namespace TINK.ViewModel.FindBike
await StartUpdateTask(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}
@ -335,7 +342,7 @@ namespace TINK.ViewModel.FindBike
await StartUpdateTask(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}
@ -352,7 +359,7 @@ namespace TINK.ViewModel.FindBike
await StartUpdateTask(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}
@ -379,7 +386,7 @@ namespace TINK.ViewModel.FindBike
await StartUpdateTask(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
}
catch (Exception exception)
@ -391,7 +398,7 @@ namespace TINK.ViewModel.FindBike
Log.ForContext<FindBikePageViewModel>().Error("Running command to select bike failed. {Exception}", exception);
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}

View file

@ -26,6 +26,8 @@ using TINK.Services.BluetoothLock;
using TINK.Repository;
using TINK.Services.Geolocation;
using TINK.Model.State;
using TINK.ViewModel.Bikes;
#if !TRYNOTBACKSTYLE
@ -308,7 +310,7 @@ namespace TINK.ViewModel.Map
try
{
//Request Location Permission on iOS
if(DeviceInfo.Platform == DevicePlatform.iOS)
if (DeviceInfo.Platform == DevicePlatform.iOS)
{
var status = await PermissionsService.RequestAsync();
}
@ -336,11 +338,17 @@ namespace TINK.ViewModel.Map
if (!string.IsNullOrEmpty(resultStationsAndBikes?.GeneralData?.MerchantMessage)
&& !WasMerchantMessageAlreadyShown)
{
// Show COPRI message once.
await ViewService.DisplayAlert(
AppResources.MessageTitleInformation,
resultStationsAndBikes.GeneralData.MerchantMessage,
AppResources.MessageAnswerOk);
// Context switch should not be required because code is called from GUI thread
// but a xf-issue requires call (see issue #594).
TinkApp.PostAction( async (x) =>
{
// Show COPRI message once.
await ViewService.DisplayAlert(
AppResources.MessageTitleInformation,
resultStationsAndBikes.GeneralData.MerchantMessage,
AppResources.MessageAnswerOk);
}, null);
WasMerchantMessageAlreadyShown = true;
}
@ -405,7 +413,7 @@ namespace TINK.ViewModel.Map
}
Exception = resultStationsAndBikes.Exception;
ActionText = "";
ActionText = string.Empty;
IsProcessWithRunningProcessView = false;
IsNavBarVisible = true;
IsMapPageEnabled = true;
@ -542,7 +550,7 @@ namespace TINK.ViewModel.Map
{
// User decided to give access to locations permissions.
PermissionsService.OpenAppSettings();
ActionText = "";
ActionText = string.Empty;
IsProcessWithRunningProcessView = false;
IsNavBarVisible = true;
IsMapPageEnabled = true;
@ -655,7 +663,7 @@ namespace TINK.ViewModel.Map
{
try
{
Log.ForContext<MapPageViewModel>().Information($"User taped station {selectedStationId}.");
Log.ForContext<MapPageViewModel>().Information($"User taped station {selectedStationId}.");
// Lock action to prevent multiple instances of "BikeAtStation" being opened.
IsMapPageEnabled = false;
@ -673,13 +681,13 @@ namespace TINK.ViewModel.Map
await ViewService.PushAsync(ViewTypes.BikesAtStation);
IsMapPageEnabled = true;
ActionText = "";
ActionText = string.Empty;
}
}
catch (Exception exception)
{
IsMapPageEnabled = true;
ActionText = "";
ActionText = string.Empty;
Log.ForContext<MapPageViewModel>().Error("Fehler beim Öffnen der Ansicht \"Fahrräder an Station\" aufgetreten. {Exception}", exception);
await ViewService.DisplayAlert(
@ -851,11 +859,6 @@ namespace TINK.ViewModel.Map
return Exception.GetShortErrorInfoText(TinkApp.IsReportLevelVerbose);
}
if (!IsConnected)
{
return AppResources.ActivityTextConnectionStateOffline;
}
return ActionText ?? string.Empty;
}
}
@ -955,7 +958,7 @@ namespace TINK.ViewModel.Map
// Excpetions are handled insde update task;
}
ActionText = "";
ActionText = string.Empty;
IsProcessWithRunningProcessView = false;
IsNavBarVisible = true;
IsMapPageEnabled = true;
@ -964,7 +967,7 @@ namespace TINK.ViewModel.Map
catch (Exception l_oException)
{
Log.ForContext<MapPageViewModel>().Error("An error occurred switching view Cargobike/ Citybike.{}");
ActionText = "";
ActionText = string.Empty;
IsProcessWithRunningProcessView = false;
IsNavBarVisible = true;

View file

@ -22,6 +22,7 @@ using TINK.Services.Permissions;
using TINK.Settings;
using TINK.View;
using TINK.ViewModel.Bikes;
using Xamarin.Essentials;
using Xamarin.Forms;
using Command = Xamarin.Forms.Command;
@ -46,6 +47,11 @@ namespace TINK.ViewModel.MyBikes
}
}
/// <summary>
/// Holds what should be executed on pull to refresh
/// </summary>
public Command RefreshCommand { get; }
/// <summary>
/// Constructs bike collection view model in case information about occupied bikes is available.
/// </summary>
@ -87,20 +93,14 @@ namespace TINK.ViewModel.MyBikes
Stations = stations ?? throw new ArgumentException(nameof(stations));
/// <summary>
/// Holds what should be executed on pull to refresh
/// </summary>
RefreshCommand = new Command(async () => {
IsRefreshing = true;
await OnAppearing();
IsRefreshing = false;
await OnAppearingOrRefresh();
});
}
public Command RefreshCommand { get; }
/// <summary> Returns if info about the fact that user did not request or book any bikes is visible or not.<summary>
/// Gets message that logged in user has not booked any bikes.
/// </summary>
@ -127,15 +127,20 @@ namespace TINK.ViewModel.MyBikes
/// Invoked when page is shown.
/// Starts update process.
/// </summary>
public async Task OnAppearing()
public async Task OnAppearingOrRefresh()
{
IsIdle = false;
IsConnected = IsConnectedDelegate();
// Get my bikes from COPRI
Log.ForContext<MyBikesPageViewModel>().Information("User request to show page MyBikes/ page re-appearing");
ActionText = AppResources.ActivityTextMyBikesLoadingBikes;
// Stop polling before getting bikes info.
await m_oViewUpdateManager.StopUpdatePeridically();
var bikesOccupied = await ConnectorFactory(IsConnected).Query.GetBikesOccupiedAsync();
Exception = bikesOccupied.Exception; // Update communication error from query for bikes occupied.
@ -178,7 +183,7 @@ namespace TINK.ViewModel.MyBikes
await OnAppearing(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}
@ -200,7 +205,7 @@ namespace TINK.ViewModel.MyBikes
await OnAppearing(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}
@ -217,7 +222,7 @@ namespace TINK.ViewModel.MyBikes
await OnAppearing(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
return;
}
@ -244,7 +249,7 @@ namespace TINK.ViewModel.MyBikes
await OnAppearing(() => UpdateTask());
ActionText = "";
ActionText = string.Empty;
IsIdle = true;
}