-
Notifications
You must be signed in to change notification settings - Fork 1
/
View1.xojo_code
256 lines (250 loc) · 7.75 KB
/
View1.xojo_code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#tag IOSView
Begin iosView View1
BackButtonTitle = ""
Compatibility = ""
LargeTitleMode = "2"
Left = 0
NavigationBarVisible= False
TabIcon = ""
TabTitle = ""
Title = "Xojo Speedometer"
Top = 0
Begin iOSRectangle Rectangle1
AccessibilityHint= ""
AccessibilityLabel= ""
AutoLayout = Rectangle1, 4, BottomLayoutGuide, 4, False, +1.00, 1, 1, 0, , True
AutoLayout = Rectangle1, 1, <Parent>, 1, False, +1.00, 1, 1, 0, , True
AutoLayout = Rectangle1, 2, <Parent>, 2, False, +1.00, 1, 1, 0, , True
AutoLayout = Rectangle1, 3, <Parent>, 3, False, +1.00, 1, 1, 0, , True
BorderColor = &c00000000
BorderWidth = 2.0
CornerHeight = 0.0
CornerWidth = 0.0
FillColor = &c00000000
Height = 480.0
Left = 0
LockedInPosition= False
Scope = 2
Top = 0
Visible = True
Width = 320.0
Begin iOSButton AboutButton
AccessibilityHint= ""
AccessibilityLabel= ""
AutoLayout = AboutButton, 8, , 0, False, +1.00, 1, 1, 30, , True
AutoLayout = AboutButton, 2, <Parent>, 2, False, +1.00, 1, 1, -*kStdGapCtlToViewH, , True
AutoLayout = AboutButton, 3, TopLayoutGuide, 4, False, +1.00, 1, 1, 0, , True
AutoLayout = AboutButton, 7, , 0, False, +1.00, 1, 1, 50, , True
Caption = "About"
Enabled = True
Height = 30.0
Left = 250
LockedInPosition= False
PanelIndex = 0
Parent = "Rectangle1"
Scope = 2
TextColor = &c007AFF00
TextFont = ""
TextSize = 0
Top = 20
Visible = True
Width = 50.0
End
End
Begin iOSLabel SpeedLabel
AccessibilityHint= ""
AccessibilityLabel= ""
AutoLayout = SpeedLabel, 8, , 0, False, +1.00, 1, 1, 243, , True
AutoLayout = SpeedLabel, 1, <Parent>, 1, False, +1.00, 1, 1, 0, , True
AutoLayout = SpeedLabel, 2, <Parent>, 2, False, +1.00, 1, 1, 0, , True
AutoLayout = SpeedLabel, 3, TopLayoutGuide, 4, False, +1.00, 1, 1, *kStdControlGapV, , True
Enabled = True
Height = 243.0
Left = 0
LineBreakMode = "0"
LockedInPosition= False
Scope = 2
Text = "0"
TextAlignment = "1"
TextColor = &cFF000000
TextFont = "System Bold "
TextSize = 148
Top = 28
Visible = True
Width = 320.0
End
Begin iOSLocation SpeedTracker
Accuracy = "0"
AuthorizationState= "0"
Enabled = True
Left = 0
LockedInPosition= False
PanelIndex = -1
Parent = ""
Scope = 2
Top = 0
End
Begin iOSSegmentedControl UnitsSelector
AccessibilityHint= ""
AccessibilityLabel= ""
AutoLayout = UnitsSelector, 4, BottomLayoutGuide, 3, False, +1.00, 1, 1, -*kStdControlGapV, , True
AutoLayout = UnitsSelector, 8, , 0, True, +1.00, 1, 1, 29, , True
AutoLayout = UnitsSelector, 1, <Parent>, 1, False, +1.00, 1, 1, *kStdGapCtlToViewH, , True
AutoLayout = UnitsSelector, 2, <Parent>, 2, False, +1.00, 1, 1, -*kStdGapCtlToViewH, , True
Caption = ""
Enabled = True
Height = 29.0
Left = 20
LockedInPosition= False
Scope = 2
Segments = "Kilometers per Hour\n\nTrue\rMiles per Hour\n\nFalse"
Top = 443
Value = 0
Visible = True
Width = 280.0
End
Begin iOSLabel UnitLabel
AccessibilityHint= ""
AccessibilityLabel= ""
AutoLayout = UnitLabel, 8, , 0, False, +1.00, 1, 1, 86, , True
AutoLayout = UnitLabel, 1, UnitsSelector, 1, False, +1.00, 1, 1, 0, , True
AutoLayout = UnitLabel, 2, UnitsSelector, 2, False, +1.00, 1, 1, 0, , True
AutoLayout = UnitLabel, 3, SpeedLabel, 4, False, +1.00, 1, 1, 0, , True
Enabled = True
Height = 86.0
Left = 20
LineBreakMode = "0"
LockedInPosition= False
Scope = 2
Text = "km/h"
TextAlignment = "1"
TextColor = &cFFFFFF00
TextFont = "System Bold "
TextSize = 48
Top = 271
Visible = True
Width = 280.0
End
End
#tag EndIOSView
#tag WindowCode
#tag Event
Sub Open()
SpeedTracker.Accuracy = iOSLocation.Accuracies.BestForNavigation
If SpeedTracker.AuthorizationState = iOSLocation.AuthorizationStates.AuthorizedWhenInUse Then
// we've got our requested authorization state, start getting LocationChanged events
SpeedTracker.Enabled = True
Else
// we don't have authorization yet, so ask for it
SpeedTracker.RequestInUseAuthorization
End If
End Sub
#tag EndEvent
#tag EndWindowCode
#tag Events AboutButton
#tag Event
Sub Action()
Dim v As New AboutView
PushTo(v)
End Sub
#tag EndEvent
#tag EndEvents
#tag Events SpeedTracker
#tag Event
Sub AuthorizationChanged()
If Me.AuthorizationState = iOSLocation.AuthorizationStates.AuthorizedWhenInUse Then
// start getting LocationChanged events
Me.Enabled = True
End If
End Sub
#tag EndEvent
#tag Event
Sub LocationChanged(latitude As Double, longitude As Double, accuracy As Double, altitude As Double, altitudeAccuracy As Double, course As Double, speed As Double)
// speed is meters per second
Dim kph As Double = speed * 3.6
Dim mph As Double = kph / 1.60934
If UnitsSelector.Value = 0 Then
SpeedLabel.Text = kph.ToText(Locale.Current, "###")
UnitLabel.Text = "km/h"
Else
SpeedLabel.Text = mph.ToText(Locale.Current, "###")
UnitLabel.Text = "MPH"
End If
End Sub
#tag EndEvent
#tag EndEvents
#tag ViewBehavior
#tag ViewProperty
Name="LargeTitleMode"
Visible=true
Group="Behavior"
InitialValue="2"
Type="LargeTitleDisplayModes"
EditorType="Enum"
#tag EnumValues
"0 - Automatic"
"1 - Always"
"2 - Never"
#tag EndEnumValues
#tag EndViewProperty
#tag ViewProperty
Name="BackButtonTitle"
Group="Behavior"
Type="Text"
EditorType="MultiLineEditor"
#tag EndViewProperty
#tag ViewProperty
Name="Index"
Visible=true
Group="ID"
InitialValue="-2147483648"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Left"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Name"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="NavigationBarVisible"
Group="Behavior"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="Super"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="TabIcon"
Group="Behavior"
Type="iOSImage"
#tag EndViewProperty
#tag ViewProperty
Name="TabTitle"
Group="Behavior"
Type="Text"
#tag EndViewProperty
#tag ViewProperty
Name="Title"
Group="Behavior"
Type="Text"
EditorType="MultiLineEditor"
#tag EndViewProperty
#tag ViewProperty
Name="Top"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag EndViewBehavior