-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathInterfaceVariables.swift
416 lines (354 loc) · 15.9 KB
/
InterfaceVariables.swift
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
//
// InterfaceVariables.swift.swift
//
// Variables associated with Scribe's user interface.
//
import UIKit
// A proxy into which text is typed.
var proxy: UITextDocumentProxy!
var controllerLanguage = String()
var spaceBar = String()
// Variables for keyboard appearance.
var keyboardHeight: CGFloat!
var keyCornerRadius: CGFloat!
var buttonWidth = CGFloat(0)
var letterButtonWidth = CGFloat(0)
var numSymButtonWidth = CGFloat(0)
// Arrays for the possible keyboard views that are loaded with their characters.
var letterKeys = [[String]]()
var numberKeys = [[String]]()
var symbolKeys = [[String]]()
// View that stores hold-to-select key options and the corresponding key arrays.
var alternatesKeyView: UIView!
var keysWithAlternates = [String]()
// The main currency symbol that will receive the alternates view for iPhones.
var currencySymbol: String = ""
var currencySymbolAlternates = [String]()
let dollarAlternateKeys = ["₿", "¢", "₽", "₩", "¥", "£", "€"]
let euroAlternateKeys = ["₿", "¢", "₽", "₩", "¥", "£", "$"]
// Symbol keys that have consistent altnernates for iPhones.
var symbolKeysWithAlternatesLeft = ["/", "?", "!", "%", "&"]
let backslashAlternateKeys = ["\\"]
let questionMarkAlternateKeys = ["¿"]
let exclamationAlternateKeys = ["¡"]
let percentAlternateKeys = ["‰"]
let ampersandAlternateKeys = ["§"]
var symbolKeysWithAlternatesRight = ["'", "\"", "="]
let apostropheAlternateKeys = ["`", "´", "'"]
let quatationAlternateKeys = ["«", "»", "„", "“", "\""]
let equalSignAlternateKeys = ["≈", "±", "≠"]
var keysWithAlternatesLeft = [String]()
var keysWithAlternatesRight = [String]()
var keyAlternatesDict = [String: Array<String>]()
var aAlternateKeys = [String]()
var eAlternateKeys = [String]()
var еAlternateKeys = [String]() // Russian е
var iAlternateKeys = [String]()
var oAlternateKeys = [String]()
var uAlternateKeys = [String]()
var yAlternateKeys = [String]()
var sAlternateKeys = [String]()
var dAlternateKeys = [String]()
var cAlternateKeys = [String]()
var nAlternateKeys = [String]()
var ьAlternateKeys = [String]()
/// States of the keyboard corresponding to layouts found in KeyboardConstants.swift.
enum KeyboardState {
case letters
case numbers
case symbols
}
/// What the keyboard state is in regards to the shift key.
/// - normal: not capitalized
/// - shift: capitalized
/// - caps: caps-lock
enum ShiftButtonState {
case normal
case shift
case caps
}
// Baseline state variables.
var keyboardState: KeyboardState = .letters
var shiftButtonState: ShiftButtonState = .normal
var scribeBtnState: Bool! = false
// Variables and functions to determine display parameters.
var isLandscapeView: Bool = false
struct DeviceType {
static let isPhone = UIDevice.current.userInterfaceIdiom == .phone
static let isPad = UIDevice.current.userInterfaceIdiom == .pad
}
/// Determines if the device is in dark mode and sets the color scheme.
func checkDarkModeSetColors() {
if UITraitCollection.current.userInterfaceStyle == .dark {
keyColor = UIColor.systemGray2
specialKeyColor = UIColor.systemGray3
keyPressedColor = UIColor.systemGray
} else if UITraitCollection.current.userInterfaceStyle == .light {
keyColor = .white
specialKeyColor = UIColor.systemGray2
keyPressedColor = UIColor.systemGray5
}
}
/// Checks if the device is in landscape mode.
func checkLandscapeMode() {
if UIScreen.main.bounds.height < UIScreen.main.bounds.width {
isLandscapeView = true
} else if UIScreen.main.bounds.height > UIScreen.main.bounds.width {
isLandscapeView = false
}
}
// MARK: French interface variables
public enum FrenchKeyboardConstants {
// Keyboard key layouts.
static let letterKeysPhone = [
["a", "z", "e", "r", "t", "y", "u", "i", "o", "p"],
["q", "s", "d", "f", "g", "h", "j", "k", "l", "m"],
["shift", "w", "x", "c", "v", "b", "n", "'", "delete"],
["123", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let numberKeysPhone = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["-", "/", ":", ";", "(", ")", "€", "&", "@", "\""],
["#+=", ".", ",", "?", "!", "\'", "delete"],
["ABC", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let symbolKeysPhone = [
["[", "]", "{", "}", "#", "%", "^", "*", "+", "="],
["_", "\\", "|", "~", "<", ">", "$", "£", "¥", "·"],
["123", ".", ",", "?", "!", "\'", "delete"],
["ABC", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let letterKeysPad = [
["a", "z", "e", "r", "t", "y", "u", "i", "o", "p", "delete"],
["q", "s", "d", "f", "g", "h", "j", "k", "l", "m", "return"],
["shift", "w", "x", "c", "v", "b", "n", "'", ",", ".", "shift"],
[".?123", "selectKeyboard", "space", ".?123", "hideKeyboard"] // "undoArrow"
]
static let numberKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "delete"],
["@", "#", "&", "\"", "€", "(", "!", ")", "-", "*", "return"],
["#+=", "%", "_", "+", "=", "/", ";", ":", ",", ".", "#+="],
["ABC", "selectKeyboard", "space", "ABC", "hideKeyboard"] // "undoArrow"
]
static let symbolKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "delete"],
["~", "ᵒ", "[", "]", "{", "}", "^", "$", "£", "¥", "return"],
["123", "§", "<", ">", "|", "\\", "...", "·", "?", "'", "123"],
["ABC", "selectKeyboard", "space", "ABC", "hideKeyboard"] // "undoArrow"
]
// Alternate key vars.
static let keysWithAlternates = ["a", "e", "i", "o", "u", "y", "c", "n"]
static let keysWithAlternatesLeft = ["a", "e", "y", "c"]
static let keysWithAlternatesRight = ["i", "o", "u", "n"]
static let aAlternateKeys = ["à", "â", "æ", "á", "ä", "ã", "å", "ā", "ᵃ"]
static let eAlternateKeys = ["é", "è", "ê", "ë", "ę", "ė", "ē"]
static let iAlternateKeys = ["ī", "į", "í", "ì", "ï", "î"]
static let oAlternateKeys = ["ᵒ", "ō", "ø", "õ", "ó", "ò", "ö", "œ", "ô"]
static let uAlternateKeys = ["ū", "ú", "ü", "ù", "û"]
static let yAlternateKeys = ["ÿ"]
static let cAlternateKeys = ["ç", "ć", "č"]
static let nAlternateKeys = ["ń", "ñ"]
}
// MARK: German interface variables
public enum GermanKeyboardConstants {
// Keyboard key layouts.
static let letterKeysPhone = [
["q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "ü"],
["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä"],
["shift", "y", "x", "c", "v", "b", "n", "m", "delete"],
["123", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let numberKeysPhone = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["-", "/", ":", ";", "(", ")", "€", "&", "@", "\""],
["#+=", ".", ",", "?", "!", "\'", "delete"],
["ABC", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let symbolKeysPhone = [
["[", "]", "{", "}", "#", "%", "^", "*", "+", "="],
["_", "\\", "|", "~", "<", ">", "$", "£", "¥", "·"],
["123", ".", ",", "?", "!", "\'", "delete"],
["ABC", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let letterKeysPad = [
["q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "ü", "delete"],
["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä", "return"],
["shift", "y", "x", "c", "v", "b", "n", "m", ",", ".", "ß", "shift"],
[".?123", "selectKeyboard", "space", ".?123", "hideKeyboard"] // "undoArrow"
]
static let numberKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "+", "delete"],
["\"", "§", "€", "%", "&", "/", "(", ")", "=", "'", "#", "return"],
["#+=", "—", "`", "'", "...", "@", ";", ":", ",", ".", "-", "#+="],
["ABC", "selectKeyboard", "space", "ABC", "hideKeyboard"] // "undoArrow"
]
static let symbolKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "*", "delete"],
["$", "£", "¥", "¿", "―", "\\", "[", "]", "{", "}", "|", "return"],
["123", "¡", "<", ">", "≠", "·", "^", "~", "!", "?", "_", "123"],
["ABC", "selectKeyboard", "space", "ABC", "hideKeyboard"] // "undoArrow"
]
// Alternate key vars.
static let keysWithAlternates = ["a", "e", "i", "o", "u", "y", "s", "c", "n"]
static let keysWithAlternatesLeft = ["a", "e", "y", "s", "c"]
static let keysWithAlternatesRight = ["i", "o", "u", "n"]
static let aAlternateKeys = ["à", "á", "â", "æ", "ã", "å", "ā"]
static let eAlternateKeys = ["é", "è", "ê", "ë", "ė"]
static let iAlternateKeys = ["ì", "ī", "í", "î", "ï"]
static let oAlternateKeys = ["ō", "ø", "œ", "õ", "ó", "ò", "ô"]
static let uAlternateKeys = ["ū", "ú", "ù", "û"]
static let yAlternateKeys = ["ÿ"]
static let sAlternateKeys = ["ß", "ś", "š"]
static let cAlternateKeys = ["ç", "ć", "č"]
static let nAlternateKeys = ["ń", "ñ"]
}
// MARK: Portuguese interface variables
public enum PortugueseKeyboardConstants {
// Keyboard key layouts.
static let letterKeysPhone = [
["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
["a", "s", "d", "f", "g", "h", "j", "k", "l"],
["shift", "z", "x", "c", "v", "b", "n", "m", "delete"],
["123", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let numberKeysPhone = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["-", "/", ":", ";", "(", ")", "€", "&", "@", "\""],
["#+=", ".", ",", "?", "!", "\'", "delete"],
["ABC", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let symbolKeysPhone = [
["[", "]", "{", "}", "#", "%", "^", "*", "+", "="],
["_", "\\", "|", "~", "<", ">", "$", "£", "¥", "·"],
["123", ".", ",", "?", "!", "\'", "delete"],
["ABC", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let letterKeysPad = [
["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "delete"],
["a", "s", "d", "f", "g", "h", "j", "k", "l", "return"],
["shift", "z", "x", "c", "v", "b", "n", "m", "!", "?", "shift"],
[".?123", "selectKeyboard", "space", ".?123", "hideKeyboard"] // "undoArrow"
]
static let numberKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "delete"],
["@", "#", "$", "&", "*", "(", ")", "'", "\"", "return"],
["#+=", "%", "-", "+", "=", "/", ";", ":", ",", ".", "#+="],
["ABC", "selectKeyboard", "space", "ABC", "hideKeyboard"] // "undoArrow"
]
static let symbolKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "delete"],
["€", "£", "¥", "_", "^", "[", "]", "{", "}", "return"],
["123", "§", "|", "~", "...", "\\", "<", ">", "!", "?", "123"],
["ABC", "selectKeyboard", "space", "ABC", "hideKeyboard"] // "undoArrow"
]
// Alternate key vars.
static let keysWithAlternates = ["a", "e", "i", "o", "u", "c", "n"]
static let keysWithAlternatesLeft = ["a", "e", "c"]
static let keysWithAlternatesRight = ["i", "o", "u", "n"]
static let aAlternateKeys = ["á", "ã", "à", "â", "ä", "å", "æ", "ᵃ"]
static let eAlternateKeys = ["é", "ê", "è", "ę", "ė", "ē", "ë"]
static let iAlternateKeys = ["ī", "į", "ï", "ì", "î", "í"]
static let oAlternateKeys = ["ᵒ", "ō", "ø", "œ", "ö", "ò", "ô", "õ", "ó"]
static let uAlternateKeys = ["ū", "û", "ù", "ü", "ú"]
static let cAlternateKeys = ["ç"]
static let nAlternateKeys = ["ñ"]
}
// MARK: Russian interface variables
public enum RussianKeyboardConstants {
// Keyboard key layouts.
static let letterKeysPhone = [
["й", "ц", "у", "к", "е", "н", "г", "ш", "щ", "з", "х"],
["ф", "ы", "в", "а", "п", "р", "о", "л", "д", "ж", "э"],
["shift", "я", "ч", "с", "м", "и", "т", "ь", "б", "ю", "delete"],
["123", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let numberKeysPhone = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["-", "/", ":", ";", "(", ")", "€", "&", "@", "\""],
["#+=", ".", ",", "?", "!", "\'", "delete"],
["АБВ", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let symbolKeysPhone = [
["[", "]", "{", "}", "#", "%", "^", "*", "+", "="],
["_", "\\", "|", "~", "<", ">", "$", "£", "¥", "·"],
["123", ".", ",", "?", "!", "\'", "delete"],
["АБВ", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let letterKeysPad = [
["й", "ц", "у", "к", "е", "н", "г", "ш", "щ", "з", "х", "delete"],
["ф", "ы", "в", "а", "п", "р", "о", "л", "д", "ж", "э", "return"],
["shift", "я", "ч", "с", "м", "и", "т", "ь", "б", "ю", ".", "shift"],
[".?123", "selectKeyboard", "space", ".?123", "hideKeyboard"] // "undoArrow"
]
static let numberKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "—", "delete"],
["@", "#", "№", "₽", "ʼ", "&", "*", "(", ")", "'", "\"", "return"],
["#+=", "%", "_", "-", "+", "=", "≠", ";", ":", ",", ".", "#+="],
["АБВ", "selectKeyboard", "space", "АБВ", "hideKeyboard"] // "undoArrow"
]
static let symbolKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "—", "delete"],
["$", "€", "£", "¥", "±", "·", "`", "[", "]", "{", "}", "return"],
["123", "§", "|", "~", "...", "^", "\\", "<", ">", "!", "?", "123"],
["АБВ", "selectKeyboard", "space", "АБВ", "hideKeyboard"] // "undoArrow"
]
// Alternate key vars.
static let keysWithAlternates = ["е", "ь"]
static let keysWithAlternatesLeft = ["е"]
static let keysWithAlternatesRight = ["ь"]
static let еAlternateKeys = ["ë"]
static let ьAlternateKeys = ["Ъ"]
}
// MARK: Spanish interface variables
public class SpanishKeyboardConstants {
// Keyboard key layouts.
static let letterKeysPhone = [
["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
["a", "s", "d", "f", "g", "h", "j", "k", "l", "ñ"],
["shift", "z", "x", "c", "v", "b", "n", "m", "delete"],
["123", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let numberKeysPhone = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["-", "/", ":", ";", "(", ")", "$", "&", "@", "\""],
["#+=", ".", ",", "?", "!", "\'", "delete"],
["ABC", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let symbolKeysPhone = [
["[", "]", "{", "}", "#", "%", "^", "*", "+", "="],
["_", "\\", "|", "~", "<", ">", "€", "£", "¥", "·"],
["123", ".", ",", "?", "!", "\'", "delete"],
["ABC", "selectKeyboard", "space", "return"] // "undoArrow"
]
static let letterKeysPad = [
["q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "delete"],
["a", "s", "d", "f", "g", "h", "j", "k", "l", "ñ", "return"],
["shift", "y", "x", "c", "v", "b", "n", "m", ",", ".", "shift"],
[".?123", "selectKeyboard", "space", ".?123", "hideKeyboard"] // "undoArrow"
]
static let numberKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "delete"],
["@", "#", "$", "&", "*", "(", ")", "'", "\"", "+", "return"],
["#+=", "%", "_", "-", "=", "/", ";", ":", ",", ".", "#+="],
["ABC", "selectKeyboard", "space", "ABC", "hideKeyboard"] // "undoArrow"
]
static let symbolKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "*", "delete"],
["€", "£", "¥", "^", "[", "]", "{", "}", "ᵒ", "ᵃ", "return"],
["123", "§", "|", "~", "¶", "\\", "<", ">", "¡", "¿", "123"],
["ABC", "selectKeyboard", "space", "ABC", "hideKeyboard"] // "undoArrow"
]
// Alternate key vars.
static let keysWithAlternates = ["a", "e", "i", "o", "u", "s", "d", "c", "n"]
static let keysWithAlternatesLeft = ["a", "e", "s", "d", "c"]
static let keysWithAlternatesRight = ["i", "o", "u", "n"]
static let aAlternateKeys = ["á", "à", "ä", "â", "ã", "å", "ą", "æ", "ā", "ᵃ"]
static let eAlternateKeys = ["é", "è", "ë", "ê", "ę", "ė", "ē"]
static let iAlternateKeys = ["ī", "į", "î", "ì", "ï", "í"]
static let oAlternateKeys = ["ᵒ", "ō", "œ", "ø", "õ", "ô", "ö", "ó", "ò"]
static let uAlternateKeys = ["ū", "û", "ù", "ü", "ú"]
static let sAlternateKeys = ["š"]
static let dAlternateKeys = ["đ"]
static let cAlternateKeys = ["ç", "ć", "č"]
static let nAlternateKeys = ["ń"]
}