mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-21 21:46:27 +02:00
Fixed issue where location permissions was called infinite times on decline.
This commit is contained in:
parent
8aa3089f32
commit
34590fbc7d
3 changed files with 89 additions and 45 deletions
|
@ -282,7 +282,7 @@ namespace TINK
|
|||
if (_PermissionsService != null)
|
||||
return _PermissionsService;
|
||||
|
||||
_PermissionsService = new Services.Permissions.Plugin.Permissions();
|
||||
_PermissionsService = new Services.Permissions.Essentials.Permissions();
|
||||
return _PermissionsService;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ namespace TINK.View.Map
|
|||
/// <summary> View model to notify about whether page appears or hides. </summary>
|
||||
private MapPageViewModel MapPageViewModel { get; set; }
|
||||
|
||||
/// <summary> Initialization status to ensure initialization logic is not called multiple times. </summary>
|
||||
private bool viewInitialized = false;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs map page instance.
|
||||
/// </summary>
|
||||
|
@ -125,30 +128,22 @@ namespace TINK.View.Map
|
|||
public INavigationMasterDetail NavigationMasterDetail { private get; set; }
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when page is shown.
|
||||
/// Starts update process.
|
||||
/// </summary>
|
||||
protected async override void OnAppearing()
|
||||
{
|
||||
// Don't repeat the initialization if it has been completed already.
|
||||
if (viewInitialized) return;
|
||||
|
||||
// Pass reference to member Navigation to show bikes at station x dialog.
|
||||
try
|
||||
{
|
||||
Log.ForContext<MapPage>().Verbose("Constructing map page view model.");
|
||||
|
||||
#if TRYNOTBACKSTYLE
|
||||
MapPageViewModel = new MapPageViewModel();
|
||||
#else
|
||||
MapPageViewModel = new MapPageViewModel(
|
||||
App.ModelRoot,
|
||||
App.PermissionsService,
|
||||
App.BluetoothService,
|
||||
App.GeolocationServicesContainer.Active,
|
||||
(mapspan) => MyMap.MoveToRegion(mapspan),
|
||||
this,
|
||||
Navigation);
|
||||
#endif
|
||||
} catch (Exception exception)
|
||||
MapPageViewModel = createMapPageViewModel();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
Log.ForContext<MapPage>().Error("Constructing map page view model failed. {Exception}", exception);
|
||||
|
@ -171,15 +166,7 @@ namespace TINK.View.Map
|
|||
|
||||
try
|
||||
{
|
||||
if (Device.RuntimePlatform == Device.iOS)
|
||||
{
|
||||
TINKButton.BackgroundColor = Color.LightGray;
|
||||
TINKButton.BorderColor = Color.Black;
|
||||
TINKButton.Margin = new Thickness(10, 10, 10, 10);
|
||||
KonradButton.BackgroundColor = Color.LightGray;
|
||||
KonradButton.BorderColor = Color.Black;
|
||||
KonradButton.Margin = new Thickness(10, 10, 10, 10);
|
||||
}
|
||||
applyCustomiOSStyling();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -201,11 +188,7 @@ namespace TINK.View.Map
|
|||
try
|
||||
{
|
||||
// Pre move and scanle maps to avoid initial display of map in Rome.
|
||||
Log.ForContext<MapPage>().Verbose("Moving and scaling map.");
|
||||
MapPageViewModel.MoveAndScale(
|
||||
(mapSpan) => MyMap.MoveToRegion(mapSpan),
|
||||
App.ModelRoot.Uris.ActiveUri,
|
||||
App.ModelRoot.GroupFilterMapPage);
|
||||
premoveAndScaleMap();
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
|
@ -223,6 +206,54 @@ namespace TINK.View.Map
|
|||
Log.ForContext<MapPage>().Error("Invoking OnAppearing on map page view model failed. {Exception}", exception);
|
||||
return;
|
||||
}
|
||||
viewInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Premoves the Map to a certain location.
|
||||
/// </summary>
|
||||
private void premoveAndScaleMap()
|
||||
{
|
||||
Log.ForContext<MapPage>().Verbose("Moving and scaling map.");
|
||||
MapPageViewModel.MoveAndScale(
|
||||
(mapSpan) => MyMap.MoveToRegion(mapSpan),
|
||||
App.ModelRoot.Uris.ActiveUri,
|
||||
App.ModelRoot.GroupFilterMapPage);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates the Map Page's view model.
|
||||
/// </summary>
|
||||
private MapPageViewModel createMapPageViewModel()
|
||||
{
|
||||
Log.ForContext<MapPage>().Verbose("Constructing map page view model.");
|
||||
return new MapPageViewModel(
|
||||
App.ModelRoot,
|
||||
App.PermissionsService,
|
||||
App.BluetoothService,
|
||||
App.GeolocationServicesContainer.Active,
|
||||
(mapspan) => MyMap.MoveToRegion(mapspan),
|
||||
this,
|
||||
Navigation);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Applies iOS specific styling to branded Buttons.
|
||||
/// </summary>
|
||||
private void applyCustomiOSStyling()
|
||||
{
|
||||
if (Device.RuntimePlatform == Device.iOS)
|
||||
{
|
||||
TINKButton.BackgroundColor = Color.LightGray;
|
||||
TINKButton.BorderColor = Color.Black;
|
||||
TINKButton.Margin = new Thickness(10, 10, 10, 10);
|
||||
KonradButton.BackgroundColor = Color.LightGray;
|
||||
KonradButton.BorderColor = Color.Black;
|
||||
KonradButton.Margin = new Thickness(10, 10, 10, 10);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -236,7 +267,7 @@ namespace TINK.View.Map
|
|||
// View model might be null.
|
||||
await MapPageViewModel?.OnDisappearing();
|
||||
}
|
||||
|
||||
viewInitialized = false;
|
||||
base.OnDisappearing();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue