1
1
using MapboxMapsObjC ;
2
2
using MapboxMaui . Locations ;
3
+ using ObjCRuntime ;
3
4
4
5
namespace MapboxMaui ;
5
6
using PlatformView = MapViewContainer ;
@@ -19,23 +20,167 @@ private TMBLocationManager Plugin
19
20
20
21
public bool Enabled
21
22
{
22
- get => throw new NotImplementedException ( ) ;
23
- set => throw new NotImplementedException ( ) ;
23
+ get => Plugin . Options . PuckType is not null ;
24
+ set
25
+ {
26
+ if ( ! value )
27
+ {
28
+ Plugin . Options . PuckType = null ;
29
+ return ;
30
+ }
31
+
32
+ var options = Plugin . Options ;
33
+ options . PuckType = TMBPuck2DConfiguration . MakeDefaultWithShowBearing ( false ) ;
34
+
35
+ Plugin . Options = options ;
36
+ }
24
37
}
25
38
26
39
public bool PulsingEnabled
27
40
{
28
- get => throw new NotImplementedException ( ) ;
29
- set => throw new NotImplementedException ( ) ;
41
+ get
42
+ {
43
+ if ( Plugin . Options . PuckType is null ) return false ;
44
+
45
+ try
46
+ {
47
+ var puck2D = Runtime . GetNSObject < TMBPuck2DConfiguration > (
48
+ Plugin . Options . PuckType . Handle
49
+ ) ;
50
+
51
+
52
+ return puck2D . Pulsing != null ;
53
+ }
54
+ catch
55
+ {
56
+ // When the native value isn't a valid TMBPuck2DConfiguration,
57
+ // Runtime.GetNSObject will throw an error
58
+ return false ;
59
+ }
60
+ }
61
+ set
62
+ {
63
+ if ( Plugin . Options . PuckType is null ) return ;
64
+
65
+ try
66
+ {
67
+ var options = Plugin . Options ;
68
+ var puck2D = Runtime . GetNSObject < TMBPuck2DConfiguration > (
69
+ options . PuckType . Handle
70
+ ) ;
71
+
72
+ if ( value is false )
73
+ {
74
+ // TODO Set this property to NULL
75
+ // or just set the inner property, IsEnabled, to false?
76
+ puck2D . Pulsing = null ;
77
+ }
78
+ else
79
+ {
80
+ puck2D . Pulsing = puck2D . Pulsing ?? TMBPuck2DConfigurationPulsing . Default ( ) ;
81
+ }
82
+ options . PuckType = puck2D ;
83
+ Plugin . Options = options ;
84
+ }
85
+ catch
86
+ {
87
+ // When the native value isn't a valid TMBPuck2DConfiguration,
88
+ // Runtime.GetNSObject will throw an error
89
+ return ;
90
+ }
91
+ }
30
92
}
31
93
public bool ShowAccuracyRing
32
94
{
33
- get => throw new NotImplementedException ( ) ;
34
- set => throw new NotImplementedException ( ) ;
95
+ get
96
+ {
97
+ if ( Plugin . Options . PuckType is null ) return false ;
98
+
99
+ try
100
+ {
101
+ var puck2D = Runtime . GetNSObject < TMBPuck2DConfiguration > (
102
+ Plugin . Options . PuckType . Handle
103
+ ) ;
104
+
105
+ return puck2D . ShowsAccuracyRing == true ;
106
+ }
107
+ catch
108
+ {
109
+ // When the native value isn't a valid TMBPuck2DConfiguration,
110
+ // Runtime.GetNSObject will throw an error
111
+ return false ;
112
+ }
113
+ }
114
+ set
115
+ {
116
+ if ( Plugin . Options . PuckType is null ) return ;
117
+
118
+ try
119
+ {
120
+ var puck2D = Runtime . GetNSObject < TMBPuck2DConfiguration > (
121
+ Plugin . Options . PuckType . Handle
122
+ ) ;
123
+
124
+ if ( puck2D . Pulsing is null )
125
+ {
126
+ return ;
127
+ }
128
+
129
+ puck2D . ShowsAccuracyRing = value ;
130
+ }
131
+ catch
132
+ {
133
+ // When the native value isn't a valid TMBPuck2DConfiguration,
134
+ // Runtime.GetNSObject will throw an error
135
+ return ;
136
+ }
137
+ }
35
138
}
36
139
public float PulsingMaxRadius
37
140
{
38
- get => throw new NotImplementedException ( ) ;
39
- set => throw new NotImplementedException ( ) ;
141
+ get
142
+ {
143
+ if ( Plugin . Options . PuckType is null ) return float . NegativeInfinity ;
144
+
145
+ try
146
+ {
147
+ var puck2D = Runtime . GetNSObject < TMBPuck2DConfiguration > (
148
+ Plugin . Options . PuckType . Handle
149
+ ) ;
150
+
151
+ return puck2D . Pulsing ? . Radius . Constant ? . FloatValue
152
+ ?? float . NegativeInfinity ;
153
+ }
154
+ catch
155
+ {
156
+ // When the native value isn't a valid TMBPuck2DConfiguration,
157
+ // Runtime.GetNSObject will throw an error
158
+ return float . NegativeInfinity ;
159
+ }
160
+ }
161
+ set
162
+ {
163
+ if ( Plugin . Options . PuckType is null ) return ;
164
+
165
+ try
166
+ {
167
+ var puck2D = Runtime . GetNSObject < TMBPuck2DConfiguration > (
168
+ Plugin . Options . PuckType . Handle
169
+ ) ;
170
+
171
+ if ( puck2D . Pulsing is null )
172
+ {
173
+ return ;
174
+ }
175
+
176
+ puck2D . Pulsing . Radius = TMBPuck2DConfigurationPulsingRadius . FromConstant ( value ) ;
177
+ }
178
+ catch
179
+ {
180
+ // When the native value isn't a valid TMBPuck2DConfiguration,
181
+ // Runtime.GetNSObject will throw an error
182
+ return ;
183
+ }
184
+ }
40
185
}
41
186
}
0 commit comments