Skip to content

Commit

Permalink
Merge pull request #399 from amay077/issue_371
Browse files Browse the repository at this point in the history
Fix UiSettings.ZoomControls enabled not processed
  • Loading branch information
amay077 authored Oct 26, 2017
2 parents af06fc3 + c30eb39 commit 4b28414
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ namespace Xamarin.Forms.GoogleMaps.Logics.Android
{
internal sealed class UiSettingsLogic : BaseUiSettingsLogic<GoogleMap>
{
// These properties are 'null' when call Initialize()
// If 'not null' then set true/false in app's page constructor.
public bool? RotateGesturesEnabled { get; private set; }
public bool? MyLocationButtonEnabled { get; private set; }
public bool? ScrollGesturesEnabled { get; private set; }
public bool? ZoomControlsEnabled { get; private set; }
public bool? ZoomGesturesEnabled { get; private set; }

public override void Initialize()
{
base.Initialize();
Expand All @@ -20,11 +28,13 @@ protected override void OnUpdateCompassEnabled()
protected override void OnUpdateRotateGesturesEnabled()
{
NativeMap.UiSettings.RotateGesturesEnabled = Map.UiSettings.RotateGesturesEnabled;
RotateGesturesEnabled = Map.UiSettings.RotateGesturesEnabled;
}

protected override void OnUpdateMyLocationButtonEnabled()
{
NativeMap.UiSettings.MyLocationButtonEnabled = Map.UiSettings.MyLocationButtonEnabled;
MyLocationButtonEnabled = Map.UiSettings.MyLocationButtonEnabled;
}

protected override void OnUpdateIndoorLevelPickerEnabled()
Expand All @@ -35,6 +45,7 @@ protected override void OnUpdateIndoorLevelPickerEnabled()
protected override void OnUpdateScrollGesturesEnabled()
{
NativeMap.UiSettings.ScrollGesturesEnabled = Map.UiSettings.ScrollGesturesEnabled;
ScrollGesturesEnabled = Map.UiSettings.ScrollGesturesEnabled;
}

protected override void OnUpdateTiltGesturesEnabled()
Expand All @@ -45,11 +56,13 @@ protected override void OnUpdateTiltGesturesEnabled()
protected override void OnUpdateZoomControlsEnabled()
{
NativeMap.UiSettings.ZoomControlsEnabled = Map.UiSettings.ZoomControlsEnabled;
ZoomControlsEnabled = Map.UiSettings.ZoomControlsEnabled;
}

protected override void OnUpdateZoomGesturesEnabled()
{
NativeMap.UiSettings.ZoomGesturesEnabled = Map.UiSettings.ZoomGesturesEnabled;
ZoomGesturesEnabled = Map.UiSettings.ZoomGesturesEnabled;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ void OnMapReady(GoogleMap map)
map.SetOnMapLongClickListener(this);
map.SetOnMyLocationButtonClickListener(this);

_uiSettingsLogic.Initialize();
UpdateIsShowingUser();
UpdateHasScrollEnabled();
UpdateHasZoomEnabled();
UpdateHasRotationEnabled();
UpdateIsShowingUser(_uiSettingsLogic.MyLocationButtonEnabled);
UpdateHasScrollEnabled(_uiSettingsLogic.ScrollGesturesEnabled);
UpdateHasZoomEnabled(_uiSettingsLogic.ZoomControlsEnabled, _uiSettingsLogic.ZoomGesturesEnabled);
UpdateHasRotationEnabled(_uiSettingsLogic.RotateGesturesEnabled);
UpdateIsTrafficEnabled();
UpdateIndoorEnabled();
UpdateMapStyle();
_uiSettingsLogic.Initialize();

SetMapType();
SetPadding();
Expand Down Expand Up @@ -284,30 +284,33 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
}
}

private void UpdateIsShowingUser()
private void UpdateIsShowingUser(bool? initialMyLocationButtonEnabled = null)
{
NativeMap.MyLocationEnabled = NativeMap.UiSettings.MyLocationButtonEnabled = Map.IsShowingUser;
NativeMap.MyLocationEnabled = Map.IsShowingUser;
NativeMap.UiSettings.MyLocationButtonEnabled = initialMyLocationButtonEnabled ?? Map.IsShowingUser;
}

private void UpdateMyLocationEnabled()
private void UpdateMyLocationEnabled(bool? initialMyLocationEnabled = null)
{
NativeMap.MyLocationEnabled = Map.MyLocationEnabled;
NativeMap.MyLocationEnabled = initialMyLocationEnabled ?? Map.MyLocationEnabled;
}

private void UpdateHasScrollEnabled()
private void UpdateHasScrollEnabled(bool? initialScrollGesturesEnabled = null)
{
NativeMap.UiSettings.ScrollGesturesEnabled = Map.HasScrollEnabled;
NativeMap.UiSettings.ScrollGesturesEnabled = initialScrollGesturesEnabled ?? Map.HasScrollEnabled;
}

private void UpdateHasZoomEnabled()
private void UpdateHasZoomEnabled(
bool? initialZoomControlsEnabled = null,
bool? initialZoomGesturesEnabled = null)
{
NativeMap.UiSettings.ZoomControlsEnabled = Map.HasZoomEnabled;
NativeMap.UiSettings.ZoomGesturesEnabled = Map.HasZoomEnabled;
NativeMap.UiSettings.ZoomControlsEnabled = initialZoomControlsEnabled ?? Map.HasZoomEnabled;
NativeMap.UiSettings.ZoomGesturesEnabled = initialZoomGesturesEnabled ?? Map.HasZoomEnabled;
}

private void UpdateHasRotationEnabled()
private void UpdateHasRotationEnabled(bool? initialRotateGesturesEnabled = null)
{
NativeMap.UiSettings.RotateGesturesEnabled = Map.HasRotationEnabled;
NativeMap.UiSettings.RotateGesturesEnabled = initialRotateGesturesEnabled ?? Map.HasRotationEnabled;
}

private void UpdateIsTrafficEnabled()
Expand Down

0 comments on commit 4b28414

Please sign in to comment.