mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-19 11:37:28 +02:00
Version 3.0.350
This commit is contained in:
parent
7f49fb0ac5
commit
40b96f0350
70 changed files with 12021 additions and 8388 deletions
|
@ -1,4 +1,4 @@
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms;
|
||||
using TINK.View;
|
||||
using TINK.Model.Station;
|
||||
using System;
|
||||
|
@ -22,6 +22,7 @@ using TINK.MultilingualResources;
|
|||
using TINK.Repository;
|
||||
using TINK.Services.Geolocation;
|
||||
using TINK.Model.State;
|
||||
using TINK.ViewModel.Map;
|
||||
|
||||
namespace TINK.ViewModel.Contact
|
||||
{
|
||||
|
@ -161,7 +162,7 @@ namespace TINK.ViewModel.Contact
|
|||
/// <summary>
|
||||
/// One time setup: Sets pins into map and connects to events.
|
||||
/// </summary>
|
||||
private void InitializePins(StationDictionary stations)
|
||||
private async void InitializePins(StationDictionary stations)
|
||||
{
|
||||
// Add pins to stations.
|
||||
Log.ForContext<SelectStationPageViewModel>().Debug($"Request to draw {stations.Count} pins.");
|
||||
|
@ -188,8 +189,35 @@ namespace TINK.ViewModel.Contact
|
|||
|
||||
Pins.Add(l_oPin);
|
||||
}
|
||||
|
||||
//Add blue dot for showing current location of user
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
currentLocation = await GeolocationService.GetAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
if (currentLocation != null)
|
||||
{
|
||||
var currentLocationPin = new Pin()
|
||||
{
|
||||
Position = new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
|
||||
Label = "currentLocationPin",
|
||||
Type = PinType.Place,
|
||||
Tag = "NotClickable",
|
||||
Icon = BitmapDescriptorFactory.FromBundle(currentLocationPinName)
|
||||
};
|
||||
|
||||
Pins.Add(currentLocationPin);
|
||||
}
|
||||
}
|
||||
|
||||
public string currentLocationPinName = $"Location_Pin{(DeviceInfo.Platform == DevicePlatform.Android ? ".png" : string.Empty)}";
|
||||
|
||||
/// <summary> Update all stations from TINK. </summary>
|
||||
/// <param name="stationsColorList">List of colors to apply.</param>
|
||||
private void UpdatePinsColor(IList<Color> stationsColorList)
|
||||
|
@ -199,24 +227,30 @@ namespace TINK.ViewModel.Contact
|
|||
// 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 colorPartPrefix = GetRessourceNameColorPart(stationsColorList[pinIndex]);
|
||||
|
||||
var l_iName = $"{indexPartPrefix.ToString().PadLeft(2, '0')}_{colorPartPrefix}{(DeviceInfo.Platform == DevicePlatform.Android ? ".png" : string.Empty)}";
|
||||
try
|
||||
if (Pins[pinIndex].Tag.ToString() == "NotClickable")
|
||||
{
|
||||
Pins[pinIndex].Icon = BitmapDescriptorFactory.FromBundle(l_iName);
|
||||
Pins[pinIndex].Icon = BitmapDescriptorFactory.FromBundle(currentLocationPinName);
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
else
|
||||
{
|
||||
Log.ForContext<SelectStationPageViewModel>().Error("Station icon {l_strName} can not be loaded. {@l_oException}.", l_oException);
|
||||
Pins[pinIndex].Label = stationId.ToString();
|
||||
Pins[pinIndex].Icon = BitmapDescriptorFactory.DefaultMarker(stationsColorList[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 colorPartPrefix = GetRessourceNameColorPart(stationsColorList[pinIndex]);
|
||||
|
||||
var l_iName = $"{indexPartPrefix.ToString().PadLeft(2, '0')}_{colorPartPrefix}{(DeviceInfo.Platform == DevicePlatform.Android ? ".png" : string.Empty)}";
|
||||
try
|
||||
{
|
||||
Pins[pinIndex].Icon = BitmapDescriptorFactory.FromBundle(l_iName);
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
Log.ForContext<SelectStationPageViewModel>().Error("Station icon {l_strName} can not be loaded. {@l_oException}.", l_oException);
|
||||
Pins[pinIndex].Label = stationId.ToString();
|
||||
Pins[pinIndex].Icon = BitmapDescriptorFactory.DefaultMarker(stationsColorList[pinIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
Pins[pinIndex].IsVisible = true;
|
||||
|
@ -449,14 +483,18 @@ namespace TINK.ViewModel.Contact
|
|||
/// <param name="selectedStationId">Id of station user clicked on.</param>
|
||||
public async void OnStationClicked(string selectedStationId)
|
||||
{
|
||||
try
|
||||
//Make shure currentLocationPin can not be clicked
|
||||
if (selectedStationId != "NotClickable")
|
||||
{
|
||||
Log.ForContext<SelectStationPageViewModel>().Information($"User taped station {selectedStationId}.");
|
||||
try
|
||||
{
|
||||
Log.ForContext<SelectStationPageViewModel>().Information($"User taped station {selectedStationId}.");
|
||||
|
||||
// Lock action to prevent multiple instances of "BikeAtStation" being opened.
|
||||
IsMapPageEnabled = false;
|
||||
|
||||
TinkApp.SelectedStation = TinkApp.Stations.FirstOrDefault(x => x.Id == selectedStationId)
|
||||
|
||||
// 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.
|
||||
|
||||
#if TRYNOTBACKSTYLE
|
||||
|
@ -468,23 +506,28 @@ namespace TINK.ViewModel.Contact
|
|||
// Show page.
|
||||
ViewService.ShowPage(ViewTypes.ContactPage, AppResources.MarkingContactPageTitle);
|
||||
#else
|
||||
await ViewService.ShowPage("//ContactPage");
|
||||
await ViewService.ShowPage("//ContactPage");
|
||||
#endif
|
||||
IsMapPageEnabled = true;
|
||||
ActionText = "";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
IsMapPageEnabled = true;
|
||||
ActionText = "";
|
||||
IsMapPageEnabled = true;
|
||||
ActionText = "";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
IsMapPageEnabled = true;
|
||||
ActionText = "";
|
||||
|
||||
Log.ForContext<SelectStationPageViewModel>().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");
|
||||
}
|
||||
Log.ForContext<SelectStationPageViewModel>().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
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -513,23 +556,26 @@ namespace TINK.ViewModel.Contact
|
|||
var colors = new List<Color>();
|
||||
foreach (var stationId in stationsId)
|
||||
{
|
||||
// Get color of given station.
|
||||
var bikesAtStation = bikesAll.Where(x => x.StationId == stationId).ToList();
|
||||
if (bikesAtStation.FirstOrDefault(x => x.State.Value.IsOccupied()) != null)
|
||||
if (stationId != "NotClickable")
|
||||
{
|
||||
// There is at least one requested or booked bike
|
||||
colors.Add(Color.LightBlue);
|
||||
continue;
|
||||
}
|
||||
// Get color of given station.
|
||||
var bikesAtStation = bikesAll.Where(x => x.StationId == stationId).ToList();
|
||||
if (bikesAtStation.FirstOrDefault(x => x.State.Value.IsOccupied()) != null)
|
||||
{
|
||||
// There is at least one requested or booked bike
|
||||
colors.Add(Color.LightBlue);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bikesAtStation.ToList().Count > 0)
|
||||
{
|
||||
// There is at least one bike available
|
||||
colors.Add(Color.Green);
|
||||
continue;
|
||||
}
|
||||
if (bikesAtStation.ToList().Count > 0)
|
||||
{
|
||||
// There is at least one bike available
|
||||
colors.Add(Color.Green);
|
||||
continue;
|
||||
}
|
||||
|
||||
colors.Add(Color.Red);
|
||||
colors.Add(Color.Red);
|
||||
}
|
||||
}
|
||||
|
||||
return colors;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue