mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 05:47:28 +02:00
Version 3.0.361
This commit is contained in:
parent
faf68061f4
commit
cba4da9357
88 changed files with 1119 additions and 1502 deletions
|
@ -27,6 +27,11 @@ using TINK.Repository;
|
|||
using TINK.Services.Geolocation;
|
||||
using TINK.Model.State;
|
||||
using TINK.ViewModel.Bikes;
|
||||
using Location = Xamarin.Essentials.Location;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -238,31 +243,38 @@ namespace TINK.ViewModel.Map
|
|||
{
|
||||
Log.ForContext<MapPageViewModel>().Debug($"Starting update of stations pins color for {stationsColorList.Count} stations...");
|
||||
|
||||
int MyBikesCount = 0;
|
||||
// Update colors of pins.
|
||||
for (int pinIndex = 0; pinIndex < stationsColorList.Count; pinIndex++)
|
||||
{
|
||||
var indexPartPrefix = int.TryParse(Pins[pinIndex].Tag.ToString(), out int stationId)
|
||||
&& stationId <= CUSTOM_ICONS_COUNT
|
||||
? $"{stationId}" // there is a station marker with index letter for given station id
|
||||
: "Open"; // there is no station marker. Use open marker.
|
||||
var indexPartPrefix = int.TryParse(Pins[pinIndex].Tag.ToString(), out int stationId)
|
||||
&& stationId <= CUSTOM_ICONS_COUNT
|
||||
? $"{stationId}" // there is a station marker with index letter for given station id
|
||||
: "Open"; // there is no station marker. Use open marker.
|
||||
|
||||
var colorPartPrefix = GetRessourceNameColorPart(stationsColorList[pinIndex]);
|
||||
var colorPartPrefix = GetRessourceNameColorPart(stationsColorList[pinIndex]);
|
||||
if (colorPartPrefix == "Blue" || colorPartPrefix == "LightBlue")
|
||||
{
|
||||
MyBikesCount = MyBikesCount + 1;
|
||||
};
|
||||
|
||||
var name = $"{indexPartPrefix.ToString().PadLeft(2, '0')}_{colorPartPrefix}{(DeviceInfo.Platform == DevicePlatform.Android ? ".png" : string.Empty)}";
|
||||
try
|
||||
{
|
||||
Pins[pinIndex].Icon = BitmapDescriptorFactory.FromBundle(name);
|
||||
}
|
||||
catch (Exception excption)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Station icon {name} can not be loaded. {@excption}.", name, excption);
|
||||
Pins[pinIndex].Label = stationId.ToString();
|
||||
Pins[pinIndex].Icon = BitmapDescriptorFactory.DefaultMarker(stationsColorList[pinIndex]);
|
||||
}
|
||||
var name = $"{indexPartPrefix.ToString().PadLeft(2, '0')}_{colorPartPrefix}{(DeviceInfo.Platform == DevicePlatform.Android ? ".png" : string.Empty)}";
|
||||
try
|
||||
{
|
||||
Pins[pinIndex].Icon = BitmapDescriptorFactory.FromBundle(name);
|
||||
}
|
||||
catch (Exception excption)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Station icon {name} can not be loaded. {@excption}.", name, excption);
|
||||
Pins[pinIndex].Label = stationId.ToString();
|
||||
Pins[pinIndex].Icon = BitmapDescriptorFactory.DefaultMarker(stationsColorList[pinIndex]);
|
||||
}
|
||||
|
||||
Pins[pinIndex].IsVisible = true;
|
||||
}
|
||||
|
||||
MyBikesCountText = MyBikesCount > 0 ? string.Format(MyBikesCount.ToString()) : string.Empty;
|
||||
|
||||
var pinsCount = Pins.Count;
|
||||
for (int pinIndex = stationsColorList.Count; pinIndex < pinsCount; pinIndex++)
|
||||
{
|
||||
|
@ -273,6 +285,20 @@ namespace TINK.ViewModel.Map
|
|||
Log.ForContext<MapPageViewModel>().Debug("Update of stations pins color done.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// label for number of reserved/rented bikes;
|
||||
/// </summary>
|
||||
private string _myBikesCountText = string.Empty;
|
||||
public string MyBikesCountText
|
||||
{
|
||||
get { return _myBikesCountText; }
|
||||
set
|
||||
{
|
||||
_myBikesCountText = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(MyBikesCountText)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets the color related part of the ressrouce name.</summary>
|
||||
/// <param name="color">Color to get name for.</param>
|
||||
/// <returns>Resource name.</returns>
|
||||
|
@ -340,7 +366,7 @@ namespace TINK.ViewModel.Map
|
|||
{
|
||||
// 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) =>
|
||||
TinkApp.PostAction(async (x) =>
|
||||
{
|
||||
// Show COPRI message once.
|
||||
await ViewService.DisplayAlert(
|
||||
|
@ -376,11 +402,11 @@ namespace TINK.ViewModel.Map
|
|||
{
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (status == Status.Granted)
|
||||
{
|
||||
// Get from smart device
|
||||
mapSpan = await GetFromLocationService(status);
|
||||
}
|
||||
{
|
||||
// Get from smart device
|
||||
mapSpan = await GetFromLocationService(status);
|
||||
}
|
||||
}
|
||||
|
||||
if (mapSpan == null)
|
||||
{
|
||||
|
@ -462,16 +488,16 @@ namespace TINK.ViewModel.Map
|
|||
{
|
||||
if (Pins.Count > 0 && Pins.Count != stations.Count)
|
||||
{
|
||||
// Either
|
||||
// - user logged in/ logged out which might lead to more/ less stations beeing available
|
||||
// - new stations were added/ existing ones remove
|
||||
Pins.Clear();
|
||||
// Either
|
||||
// - user logged in/ logged out which might lead to more/ less stations beeing available
|
||||
// - new stations were added/ existing ones remove
|
||||
Pins.Clear();
|
||||
}
|
||||
|
||||
// Check if there are alreay any pins to the map
|
||||
// i.e detecte first call of member OnAppearing after construction
|
||||
if (Pins.Count <= 0)
|
||||
{
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Debug($"{(ActiveFilterMap.GetGroup().Any() ? $"Active map filter is {string.Join(",", ActiveFilterMap.GetGroup())}." : "Map filter is off.")}");
|
||||
|
||||
// Map was not yet initialized.
|
||||
|
@ -546,15 +572,15 @@ namespace TINK.ViewModel.Map
|
|||
AppResources.MessageAnswerYes,
|
||||
AppResources.MessageAnswerNo);
|
||||
|
||||
if (dialogResult)
|
||||
{
|
||||
// User decided to give access to locations permissions.
|
||||
PermissionsService.OpenAppSettings();
|
||||
ActionText = string.Empty;
|
||||
IsProcessWithRunningProcessView = false;
|
||||
IsNavBarVisible = true;
|
||||
IsMapPageEnabled = true;
|
||||
}
|
||||
if (dialogResult)
|
||||
{
|
||||
// User decided to give access to locations permissions.
|
||||
PermissionsService.OpenAppSettings();
|
||||
ActionText = string.Empty;
|
||||
IsProcessWithRunningProcessView = false;
|
||||
IsNavBarVisible = true;
|
||||
IsMapPageEnabled = true;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
@ -661,40 +687,40 @@ namespace TINK.ViewModel.Map
|
|||
/// <param name="selectedStationId">Id of station user clicked on.</param>
|
||||
public async void OnStationClicked(string selectedStationId)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Information($"User taped station {selectedStationId}.");
|
||||
try
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Information($"User taped station {selectedStationId}.");
|
||||
|
||||
// Lock action to prevent multiple instances of "BikeAtStation" being opened.
|
||||
IsMapPageEnabled = false;
|
||||
// Lock action to prevent multiple instances of "BikeAtStation" being opened.
|
||||
IsMapPageEnabled = false;
|
||||
|
||||
TinkApp.SelectedStation = TinkApp.Stations.FirstOrDefault(x => x.Id == selectedStationId)
|
||||
?? new Station(selectedStationId, new List<string>(), null); // Station might not be in list StationDictinaly because this list is not updatd in background task.
|
||||
TinkApp.SelectedStation = TinkApp.Stations.FirstOrDefault(x => x.Id == selectedStationId)
|
||||
?? new Station(selectedStationId, new List<string>(), null); // Station might not be in list StationDictinaly because this list is not updatd in background task.
|
||||
|
||||
#if TRYNOTBACKSTYLE
|
||||
m_oNavigation.ShowPage(
|
||||
typeof(BikesAtStationPage),
|
||||
p_strStationName);
|
||||
#else
|
||||
{
|
||||
// Show page.
|
||||
await ViewService.PushAsync(ViewTypes.BikesAtStation);
|
||||
|
||||
IsMapPageEnabled = true;
|
||||
ActionText = string.Empty;
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// Show page.
|
||||
await ViewService.PushAsync(ViewTypes.BikesAtStation);
|
||||
|
||||
IsMapPageEnabled = true;
|
||||
ActionText = string.Empty;
|
||||
|
||||
Log.ForContext<MapPageViewModel>().Error("Fehler beim Öffnen der Ansicht \"Fahrräder an Station\" aufgetreten. {Exception}", exception);
|
||||
await ViewService.DisplayAlert(
|
||||
"Fehler",
|
||||
$"Fehler beim Öffnen der Ansicht \"Fahrräder an Station\" aufgetreten. {exception.Message}",
|
||||
"OK");
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
IsMapPageEnabled = true;
|
||||
ActionText = string.Empty;
|
||||
|
||||
Log.ForContext<MapPageViewModel>().Error("Fehler beim Öffnen der Ansicht \"Fahrräder an Station\" aufgetreten. {Exception}", exception);
|
||||
await ViewService.DisplayAlert(
|
||||
"Fehler",
|
||||
$"Fehler beim Öffnen der Ansicht \"Fahrräder an Station\" aufgetreten. {exception.Message}",
|
||||
"OK");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -858,11 +884,44 @@ namespace TINK.ViewModel.Map
|
|||
// An error occurred getting data from copri.
|
||||
return Exception.GetShortErrorInfoText(TinkApp.IsReportLevelVerbose);
|
||||
}
|
||||
if (!IsConnected)
|
||||
{
|
||||
return AppResources.ActivityTextConnectionStateOffline;
|
||||
}
|
||||
|
||||
return ActionText ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Processes request to view my bikes.</summary>
|
||||
public System.Windows.Input.ICommand OnMyBikesButtonClicked => new Xamarin.Forms.Command(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Information($"User clicked on MyBikesButton.");
|
||||
|
||||
// Lock action to prevent multiple instances of "BikeAtStation" being opened.
|
||||
IsMapPageEnabled = false;
|
||||
|
||||
// Show page.
|
||||
await ViewService.PushAsync(ViewTypes.MyBikesPage);
|
||||
|
||||
IsMapPageEnabled = true;
|
||||
ActionText = string.Empty;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
IsMapPageEnabled = true;
|
||||
ActionText = string.Empty;
|
||||
|
||||
Log.ForContext<MapPageViewModel>().Error("Fehler beim Öffnen der Ansicht \"Meine Räder\" aufgetreten. {Exception}", exception);
|
||||
await ViewService.DisplayAlert(
|
||||
"Fehler",
|
||||
$"Fehler beim Öffnen der Ansicht \"Meine Räder\" aufgetreten. {exception.Message}",
|
||||
"OK");
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary> Command object to bind login button to view model.</summary>
|
||||
public System.Windows.Input.ICommand OnToggleTinkToKonrad => new Xamarin.Forms.Command(async () => await ToggleTinkToKonrad());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue