Skip to content

Commit 6598c49

Browse files
committed
- Use bottomsheet instead of toolbar items (not work for iOS)
- Correct iOS impl
1 parent 86281dd commit 6598c49

File tree

3 files changed

+53
-47
lines changed

3 files changed

+53
-47
lines changed

src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Location.cs

+18-16
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public bool Enabled
2323
get => Plugin.Options.PuckType is not null;
2424
set
2525
{
26+
var options = Plugin.Options;
2627
if (!value)
2728
{
28-
Plugin.Options.PuckType = null;
29-
return;
29+
options.PuckType = null;
30+
}
31+
else
32+
{
33+
options.PuckType = TMBPuck2DConfiguration.MakeDefaultWithShowBearing(false);
3034
}
31-
32-
var options = Plugin.Options;
33-
options.PuckType = TMBPuck2DConfiguration.MakeDefaultWithShowBearing(false);
34-
3535
Plugin.Options = options;
3636
}
3737
}
@@ -48,7 +48,6 @@ public bool PulsingEnabled
4848
Plugin.Options.PuckType.Handle
4949
);
5050

51-
5251
return puck2D.Pulsing != null;
5352
}
5453
catch
@@ -117,16 +116,14 @@ public bool ShowAccuracyRing
117116

118117
try
119118
{
119+
var options = Plugin.Options;
120120
var puck2D = Runtime.GetNSObject<TMBPuck2DConfiguration>(
121-
Plugin.Options.PuckType.Handle
121+
options.PuckType.Handle
122122
);
123-
124-
if (puck2D.Pulsing is null)
125-
{
126-
return;
127-
}
128-
129123
puck2D.ShowsAccuracyRing = value;
124+
125+
options.PuckType = puck2D;
126+
Plugin.Options = options;
130127
}
131128
catch
132129
{
@@ -164,16 +161,21 @@ public float PulsingMaxRadius
164161

165162
try
166163
{
164+
var options = Plugin.Options;
167165
var puck2D = Runtime.GetNSObject<TMBPuck2DConfiguration>(
168-
Plugin.Options.PuckType.Handle
166+
options.PuckType.Handle
169167
);
170168

171169
if (puck2D.Pulsing is null)
172170
{
173171
return;
174172
}
175173

176-
puck2D.Pulsing.Radius = TMBPuck2DConfigurationPulsingRadius.FromConstant(value);
174+
puck2D.Pulsing.Radius = value <= 0
175+
? TMBPuck2DConfigurationPulsingRadius.Accuracy
176+
: TMBPuck2DConfigurationPulsingRadius.FromConstant(value);
177+
options.PuckType = puck2D;
178+
Plugin.Options = options;
177179
}
178180
catch
179181
{

src/qs/MapboxMauiQs/Examples/Lab/70.BasicLocationPulsingCircle/BasicLocationPulsingCircleExample.cs

+32-31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
using Microsoft.Maui.ApplicationModel;
3-
41
namespace MapboxMauiQs;
52

63
public class BasicLocationPulsingCircleExample : ContentPage, IExamplePage, IQueryAttributable
@@ -13,43 +10,47 @@ public BasicLocationPulsingCircleExample()
1310
iOSPage.SetUseSafeArea(this, false);
1411
Content = map = new MapboxView();
1512

16-
var toggleMapStyleToolbarItem = new ToolbarItem
17-
{
18-
Text = "Toggle Map Style",
19-
Command = new Command(ToggleMapboxStyle),
20-
Order = ToolbarItemOrder.Secondary,
21-
};
22-
ToolbarItems.Add(toggleMapStyleToolbarItem);
23-
24-
var toggleComponentToolbarItem = new ToolbarItem
25-
{
26-
Text = "Toggle Component",
27-
Command = new Command(ToggleComponent),
28-
Order = ToolbarItemOrder.Secondary,
29-
};
30-
ToolbarItems.Add(toggleComponentToolbarItem);
31-
32-
var togglePulsingToolbarItem = new ToolbarItem
13+
Title = "X";
14+
var openSettingsItem = new ToolbarItem
3315
{
34-
Text = "Toggle Pulsing",
35-
Command = new Command(TogglePulsing),
16+
IconImageSource = "ic_settings",
17+
Text = "Actions",
18+
Command = new Command(OpenSettings),
3619
Order = ToolbarItemOrder.Secondary,
3720
};
38-
ToolbarItems.Add(togglePulsingToolbarItem);
39-
40-
var pulsingRingToolbarItem = new ToolbarItem
41-
{
42-
Text = "Pulsing follow accuracy Ring",
43-
Command = new Command(ShowPulsingAccuracyRing),
44-
Order = ToolbarItemOrder.Secondary,
45-
};
46-
ToolbarItems.Add(pulsingRingToolbarItem);
21+
ToolbarItems.Add(openSettingsItem);
4722

4823
map.MapReady += Map_MapReadyAsync;
4924
map.MapLoaded += Map_MapLoaded;
5025
map.IndicatorPositionChanged += Map_IndicatorPositionChanged;
5126
}
5227

28+
private async void OpenSettings(object obj)
29+
{
30+
var action = await DisplayActionSheet(
31+
"Action", "Cancel", null,
32+
map.LocationComponent.Enabled
33+
? "Hide user location" : "Show user location",
34+
map.LocationComponent.PulsingEnabled
35+
? "Hide pulsing" : "Show pulsing",
36+
"Show accuracy ring"
37+
);
38+
39+
switch (action) {
40+
case "Hide user location":
41+
case "Show user location":
42+
ToggleComponent(action);
43+
break;
44+
case "Hide pulsing":
45+
case "Show pulsing":
46+
TogglePulsing(action);
47+
break;
48+
case "Show accuracy ring":
49+
ShowPulsingAccuracyRing(action);
50+
break;
51+
}
52+
}
53+
5354
private void ShowPulsingAccuracyRing(object obj)
5455
{
5556
map.LocationComponent.Enabled = true;
Loading

0 commit comments

Comments
 (0)