react-native-persona 1.2.10 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/RNPersonaInquiry.podspec +1 -1
  3. package/android/README.md +14 -0
  4. package/android/build.gradle +21 -100
  5. package/bin/persona-tool +1 -2
  6. package/lib/commonjs/index.js +477 -0
  7. package/lib/commonjs/index.js.map +1 -0
  8. package/lib/commonjs/persona-tools/AndroidResourcePrinter.js +694 -0
  9. package/lib/commonjs/persona-tools/AndroidResourcePrinter.js.map +1 -0
  10. package/lib/commonjs/persona-tools/Config.js +95 -0
  11. package/lib/commonjs/persona-tools/Config.js.map +1 -0
  12. package/lib/commonjs/persona-tools/Theme.js +228 -0
  13. package/lib/commonjs/persona-tools/Theme.js.map +1 -0
  14. package/lib/commonjs/persona-tools/index.js +41 -0
  15. package/lib/commonjs/persona-tools/index.js.map +1 -0
  16. package/lib/commonjs/persona-tools/prompts.js +48 -0
  17. package/lib/commonjs/persona-tools/prompts.js.map +1 -0
  18. package/lib/commonjs/persona-tools/tools/AndroidThemeGenerator.js +112 -0
  19. package/lib/commonjs/persona-tools/tools/AndroidThemeGenerator.js.map +1 -0
  20. package/lib/commonjs/persona-tools/tools/IosThemeInstructions.js +50 -0
  21. package/lib/commonjs/persona-tools/tools/IosThemeInstructions.js.map +1 -0
  22. package/lib/commonjs/util.js +36 -0
  23. package/lib/commonjs/util.js.map +1 -0
  24. package/lib/module/index.js +452 -0
  25. package/lib/module/index.js.map +1 -0
  26. package/lib/module/persona-tools/AndroidResourcePrinter.js +686 -0
  27. package/lib/module/persona-tools/AndroidResourcePrinter.js.map +1 -0
  28. package/lib/module/persona-tools/Config.js +82 -0
  29. package/lib/module/persona-tools/Config.js.map +1 -0
  30. package/lib/module/persona-tools/Theme.js +212 -0
  31. package/lib/module/persona-tools/Theme.js.map +1 -0
  32. package/lib/module/persona-tools/index.js +33 -0
  33. package/lib/module/persona-tools/index.js.map +1 -0
  34. package/lib/module/persona-tools/prompts.js +31 -0
  35. package/lib/module/persona-tools/prompts.js.map +1 -0
  36. package/lib/module/persona-tools/tools/AndroidThemeGenerator.js +82 -0
  37. package/lib/module/persona-tools/tools/AndroidThemeGenerator.js.map +1 -0
  38. package/lib/module/persona-tools/tools/IosThemeInstructions.js +37 -0
  39. package/lib/module/persona-tools/tools/IosThemeInstructions.js.map +1 -0
  40. package/lib/module/util.js +29 -0
  41. package/lib/module/util.js.map +1 -0
  42. package/{generatedTypes → lib/typescript}/index.d.ts +67 -3
  43. package/lib/typescript/persona-tools/AndroidResourcePrinter.d.ts +40 -0
  44. package/lib/typescript/persona-tools/Config.d.ts +15 -0
  45. package/lib/typescript/persona-tools/Theme.d.ts +124 -0
  46. package/lib/typescript/persona-tools/index.d.ts +1 -0
  47. package/lib/typescript/persona-tools/prompts.d.ts +8 -0
  48. package/lib/typescript/persona-tools/tools/AndroidThemeGenerator.d.ts +5 -0
  49. package/lib/typescript/persona-tools/tools/IosThemeInstructions.d.ts +5 -0
  50. package/lib/typescript/util.d.ts +3 -0
  51. package/package.json +79 -22
  52. package/src/index.ts +17 -18
  53. package/{persona-tools/lib → src/persona-tools}/AndroidResourcePrinter.ts +314 -278
  54. package/{persona-tools/config.ts → src/persona-tools/Config.ts} +7 -7
  55. package/src/persona-tools/Theme.ts +262 -0
  56. package/src/persona-tools/index.ts +30 -0
  57. package/{persona-tools/lib → src/persona-tools}/prompts.ts +11 -11
  58. package/{persona-tools → src/persona-tools}/tools/AndroidThemeGenerator.ts +31 -32
  59. package/{persona-tools → src/persona-tools}/tools/IosThemeInstructions.ts +8 -8
  60. package/src/util.ts +3 -3
  61. package/jest.config.js +0 -10
  62. package/persona-tools/Theme.js +0 -213
  63. package/persona-tools/Theme.ts +0 -260
  64. package/persona-tools/config.js +0 -72
  65. package/persona-tools/index.js +0 -30
  66. package/persona-tools/index.ts +0 -30
  67. package/persona-tools/lib/AndroidResourcePrinter.js +0 -832
  68. package/persona-tools/lib/AndroidResourcePrinter.spec.js +0 -1135
  69. package/persona-tools/lib/AndroidResourcePrinter.spec.ts +0 -1229
  70. package/persona-tools/lib/prompts.js +0 -39
  71. package/persona-tools/tools/AndroidThemeGenerator.js +0 -59
  72. package/persona-tools/tools/IosThemeInstructions.js +0 -34
  73. package/src/index.js +0 -307
  74. package/src/util.js +0 -29
  75. package/src/util.spec.js +0 -15
  76. package/src/util.spec.ts +0 -16
  77. package/tsconfig.json +0 -29
@@ -1,832 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const xmlbuilder2_1 = require("xmlbuilder2");
4
- class AndroidResourcePrinter {
5
- constructor(theme) {
6
- this.preprintQueue = [];
7
- this.printQueue = [];
8
- this.postPrintQueue = [];
9
- this.theme = theme;
10
- this.root = xmlbuilder2_1.create({ version: "1.0" }).ele("resources");
11
- this.buttonDrawable = xmlbuilder2_1.create({ version: "1.0" }).ele("selector", {
12
- "xmlns:android": "http://schemas.android.com/apk/res/android",
13
- });
14
- this.buttonSecondaryDrawable = xmlbuilder2_1.create({ version: "1.0" }).ele("selector", {
15
- "xmlns:android": "http://schemas.android.com/apk/res/android",
16
- });
17
- this.buttonColor = xmlbuilder2_1.create({ version: "1.0" }).ele("selector", {
18
- "xmlns:android": "http://schemas.android.com/apk/res/android",
19
- });
20
- }
21
- process() {
22
- if (!this.hasTheme()) {
23
- this.root = this.root.up();
24
- }
25
- else {
26
- this.print();
27
- }
28
- return {
29
- style: this.root,
30
- buttonDrawable: this.buttonDrawable,
31
- buttonSecondaryDrawable: this.buttonSecondaryDrawable,
32
- buttonColor: this.buttonColor,
33
- };
34
- }
35
- print() {
36
- this.primaryColor();
37
- this.accentColor();
38
- this.darkPrimaryColor();
39
- this.backgroundColor();
40
- this.titleText();
41
- this.bodyText();
42
- this.footnoteText();
43
- this.cameraInstructionsText();
44
- this.cameraHintText();
45
- this.cameraGuideHintText();
46
- // this.formLabelText();
47
- this.textField();
48
- this.pickerText();
49
- this.button();
50
- this.progressColor();
51
- this.successAsset();
52
- this.failAsset();
53
- this.loadingAnimationAsset();
54
- this.selfieAnimationAsset();
55
- this.preprintQueue.forEach((fn) => fn());
56
- // Precreate some style namespaces
57
- this.root = this.root
58
- .ele("style", {
59
- name: "RN",
60
- })
61
- .up();
62
- this.root = this.root
63
- .ele("style", {
64
- name: "RN.Persona",
65
- })
66
- .up();
67
- this.root = this.root
68
- .ele("style", {
69
- name: "RN.Persona.Text",
70
- })
71
- .up();
72
- this.root = this.root.ele("style", {
73
- name: "Persona.Inquiry.Theme",
74
- parent: "Base.Persona.Inquiry.Theme.Light",
75
- });
76
- this.printQueue.forEach((fn) => fn());
77
- this.root = this.root.up();
78
- this.postPrintQueue.forEach((fn) => fn());
79
- }
80
- hasTheme() {
81
- return (Object.keys(this.theme).length > 0 &&
82
- Object.values(this.theme).filter(Boolean).length > 0);
83
- }
84
- primaryColor() {
85
- if (!this.theme.primaryColor)
86
- return;
87
- this.printQueue.push(() => {
88
- this.root = this.root
89
- .ele("item", { name: "colorPrimary" })
90
- .txt(this.theme.primaryColor)
91
- .up()
92
- .txt(" ");
93
- });
94
- }
95
- accentColor() {
96
- if (!this.theme.accentColor)
97
- return;
98
- this.printQueue.push(() => {
99
- this.root = this.root
100
- .ele("item", { name: "colorAccent" })
101
- .txt(this.theme.accentColor)
102
- .up()
103
- .txt(" ");
104
- });
105
- }
106
- darkPrimaryColor() {
107
- if (!this.theme.darkPrimaryColor)
108
- return;
109
- this.printQueue.push(() => {
110
- this.root = this.root
111
- .ele("item", { name: "colorPrimaryDark" })
112
- .txt(this.theme.darkPrimaryColor)
113
- .up()
114
- .txt(" ");
115
- });
116
- }
117
- backgroundColor() {
118
- if (!this.theme.backgroundColor)
119
- return;
120
- this.preprintQueue.push(() => {
121
- this.root = this.root
122
- .ele("color", { name: "customPersonaBackgroundColor" })
123
- .txt(this.theme.backgroundColor)
124
- .up()
125
- .txt(" ");
126
- });
127
- this.printQueue.push(() => {
128
- this.root = this.root
129
- .ele("item", { name: "android:colorBackground" })
130
- .txt("@color/customPersonaBackgroundColor")
131
- .up()
132
- .txt(" ");
133
- });
134
- }
135
- titleText() {
136
- if (this.theme.titleTextColor || this.theme.titleTextSize || this.theme.titleTextFont) {
137
- this.printQueue.push(() => {
138
- this.root = this.root
139
- .ele("item", { name: "personaTitleTextAppearance" })
140
- .txt("@style/RN.Persona.Text.Title")
141
- .up();
142
- });
143
- // Create a text appearance
144
- this.postPrintQueue.push(() => {
145
- this.root = this.root.ele("style", {
146
- name: "RN.Persona.Text.Title",
147
- parent: "Persona.Text.Body",
148
- });
149
- if (this.theme.titleTextColor) {
150
- this.root = this.root
151
- .ele("item", { name: "android:textColor" })
152
- .txt(this.theme.titleTextColor)
153
- .up();
154
- }
155
- if (this.theme.titleTextFont) {
156
- // TODO: Add notice about how to add a custom font that can be
157
- // referenced here on Android
158
- this.root = this.root
159
- .ele("item", { name: "android:fontFamily" })
160
- .txt(this.theme.titleTextFont)
161
- .up();
162
- }
163
- // Default values taken from `Persona.Text.Title`
164
- // in shared/src/main/res/values/styles.xml
165
- const textSize = this.theme.titleTextSize ? `${this.theme.titleTextSize}sp` : "26sp";
166
- this.root = this.root
167
- .ele("item", { name: "android:textSize" })
168
- .txt(textSize)
169
- .up()
170
- .ele("item", { name: "android:textStyle" })
171
- .txt("bold")
172
- .up();
173
- this.root = this.root.up();
174
- });
175
- }
176
- else {
177
- this.printQueue.push(() => {
178
- this.root = this.root
179
- .ele("item", { name: "personaTitleTextAppearance" })
180
- .txt("@style/Persona.Text.Title")
181
- .up();
182
- });
183
- }
184
- }
185
- bodyText() {
186
- if (this.theme.bodyTextColor || this.theme.bodyTextSize || this.theme.bodyTextFont) {
187
- this.printQueue.push(() => {
188
- this.root = this.root
189
- .ele("item", { name: "personaBodyTextAppearance" })
190
- .txt("@style/RN.Persona.Text.Body")
191
- .up();
192
- });
193
- // Create a text appearance
194
- this.postPrintQueue.push(() => {
195
- this.root = this.root.ele("style", {
196
- name: "RN.Persona.Text.Body",
197
- parent: "Persona.Text.Body",
198
- });
199
- if (this.theme.bodyTextColor) {
200
- this.root = this.root
201
- .ele("item", { name: "android:textColor" })
202
- .txt(this.theme.bodyTextColor)
203
- .up();
204
- }
205
- if (this.theme.bodyTextFont) {
206
- // TODO: Add notice about how to add a custom font that can be
207
- // referenced here on Android
208
- this.root = this.root
209
- .ele("item", { name: "android:fontFamily" })
210
- .txt(this.theme.bodyTextFont)
211
- .up();
212
- }
213
- // Default values taken from `Persona.Text.Body`
214
- // in shared/src/main/res/values/styles.xml
215
- const textSize = this.theme.bodyTextSize ? `${this.theme.bodyTextSize}sp` : "18sp";
216
- this.root = this.root
217
- .ele("item", { name: "android:textSize" })
218
- .txt(textSize)
219
- .up();
220
-
221
- this.root = this.root.up();
222
- });
223
- }
224
- else {
225
- this.printQueue.push(() => {
226
- this.root = this.root
227
- .ele("item", { name: "personaBodyTextAppearance" })
228
- .txt("@style/Persona.Text.Body")
229
- .up();
230
- });
231
- }
232
- }
233
- footnoteText() {
234
- if (this.theme.footnoteTextColor || this.theme.footnoteTextFont) {
235
- this.postPrintQueue.push(() => {
236
- var _a, _b;
237
- this.root = this.root
238
- .ele("style", { name: "TextAppearance.AppCompat.Small" })
239
- .ele("item", { name: "android:textColor" })
240
- .txt((_a =
241
- // Used default value found in the Android SDK
242
- this.theme.footnoteTextColor) !== null && _a !== void 0 ? _a : "?android:attr/textColorTertiary")
243
- .up();
244
- if (this.theme.footnoteTextFont) {
245
- this.root = this.root
246
- .ele("item", { name: "android:fontFamily" })
247
- .txt((_b =
248
- // Used default value found in the Android SDK
249
- this.theme.footnoteTextFont) !== null && _b !== void 0 ? _b : "?android:attr/textColorTertiary")
250
- .up();
251
- }
252
- this.root = this.root
253
- .ele("item", { name: "android:textSize" })
254
- .txt((_b =
255
- // Default value found in the Android SDK
256
- this.theme.footnoteTextSize) !== null && _b !== void 0 ? `${_b}sp` : "@dimen/abc_text_size_small_material")
257
- .up();
258
-
259
- this.root = this.root.up();
260
- });
261
- }
262
- }
263
- cameraInstructionsText() {
264
- if (this.theme.cameraInstructionsTextColor ||
265
- this.theme.cameraInstructionsTextSize ||
266
- this.theme.cameraInstructionsTextFont) {
267
- this.printQueue.push(() => {
268
- this.root = this.root
269
- .ele("item", { name: "personaCameraTitleTextAppearance" })
270
- .txt("@style/RN.Persona.Text.CameraTitle")
271
- .up();
272
- });
273
-
274
- // Create a text appearance
275
- this.postPrintQueue.push(() => {
276
- this.root = this.root.ele("style", {
277
- name: "RN.Persona.Text.CameraTitle",
278
- parent: "Persona.Text.CameraTitle",
279
- });
280
-
281
- if (this.theme.cameraInstructionsTextColor) {
282
- this.root = this.root
283
- .ele("item", { name: "android:textColor" })
284
- .txt(this.theme.cameraInstructionsTextColor)
285
- .up();
286
- }
287
-
288
- if (this.theme.cameraInstructionsTextFont) {
289
- // TODO: Add notice about how to add a custom font that can be
290
- // referenced here on Android
291
- this.root = this.root
292
- .ele("item", { name: "android:fontFamily" })
293
- .txt(this.theme.cameraInstructionsTextFont)
294
- .up();
295
- }
296
-
297
- const textSize = this.theme.cameraInstructionsTextSize ?
298
- `${this.theme.cameraInstructionsTextSize}sp` : "20sp";
299
- this.root = this.root
300
- .ele("item", { name: "android:textSize" })
301
- .txt(textSize)
302
- .up();
303
-
304
- this.root = this.root.up();
305
- });
306
- } else {
307
- this.printQueue.push(() => {
308
- this.root = this.root
309
- .ele("item", { name: "personaCameraTitleTextAppearance" })
310
- .txt("@style/Persona.Text.CameraTitle")
311
- .up();
312
- });
313
- }
314
- }
315
- cameraHintText() {
316
- if (this.theme.cameraHintTextColor ||
317
- this.theme.cameraHintTextSize ||
318
- this.theme.cameraHintTextFont) {
319
- this.printQueue.push(() => {
320
- this.root = this.root
321
- .ele("item", { name: "personaCameraBodyTextAppearance" })
322
- .txt("@style/RN.Persona.Text.CameraBody")
323
- .up();
324
- });
325
-
326
- // Create a text appearance
327
- this.postPrintQueue.push(() => {
328
- this.root = this.root.ele("style", {
329
- name: "RN.Persona.Text.CameraBody",
330
- parent: "Persona.Text.CameraBody",
331
- });
332
-
333
- if (this.theme.cameraHintTextColor) {
334
- this.root = this.root
335
- .ele("item", { name: "android:textColor" })
336
- .txt(this.theme.cameraHintTextColor)
337
- .up();
338
- }
339
-
340
- if (this.theme.cameraHintTextFont) {
341
- // TODO: Add notice about how to add a custom font that can be
342
- // referenced here on Android
343
- this.root = this.root
344
- .ele("item", { name: "android:fontFamily" })
345
- .txt(this.theme.cameraHintTextFont)
346
- .up();
347
- }
348
-
349
- const textSize = this.theme.cameraHintTextSize ?
350
- `${this.theme.cameraHintTextSize}sp` : "16sp";
351
- this.root = this.root
352
- .ele("item", { name: "android:textSize" })
353
- .txt(textSize)
354
- .up();
355
-
356
- this.root = this.root.up();
357
- });
358
- } else {
359
- this.printQueue.push(() => {
360
- this.root = this.root
361
- .ele("item", { name: "personaCameraBodyTextAppearance" })
362
- .txt("@style/Persona.Text.CameraBody")
363
- .up();
364
- });
365
- }
366
- }
367
- cameraGuideHintText() {
368
- if (this.theme.cameraGuideHintTextColor ||
369
- this.theme.cameraGuideHintTextSize ||
370
- this.theme.cameraGuideHintTextFont) {
371
- this.printQueue.push(() => {
372
- this.root = this.root
373
- .ele("item", { name: "personaCameraHintTextAppearance" })
374
- .txt("@style/RN.Persona.Text.CameraHint")
375
- .up();
376
- });
377
-
378
- // Create a text appearance
379
- this.postPrintQueue.push(() => {
380
- this.root = this.root.ele("style", {
381
- name: "RN.Persona.Text.CameraHint",
382
- parent: "Persona.Text.CameraHint",
383
- });
384
-
385
- if (this.theme.cameraGuideHintTextColor) {
386
- this.root = this.root
387
- .ele("item", { name: "android:textColor" })
388
- .txt(this.theme.cameraGuideHintTextColor)
389
- .up();
390
- }
391
-
392
- if (this.theme.cameraGuideHintTextFont) {
393
- // TODO: Add notice about how to add a custom font that can be
394
- // referenced here on Android
395
- this.root = this.root
396
- .ele("item", { name: "android:fontFamily" })
397
- .txt(this.theme.cameraGuideHintTextFont)
398
- .up();
399
- }
400
-
401
- const textSize = this.theme.cameraGuideHintTextSize ?
402
- `${this.theme.cameraGuideHintTextSize}sp` : "20sp";
403
- this.root = this.root
404
- .ele("item", { name: "android:textSize" })
405
- .txt(textSize)
406
- .up();
407
-
408
- this.root = this.root.up();
409
- });
410
- } else {
411
- this.printQueue.push(() => {
412
- this.root = this.root
413
- .ele("item", { name: "personaCameraHintTextAppearance" })
414
- .txt("@style/Persona.Text.CameraHint")
415
- .up();
416
- });
417
- }
418
- }
419
- textField() {
420
- if (this.theme.textFieldTextColor || this.theme.textFieldTextFont) {
421
- this.printQueue.push(() => {
422
- this.root = this.root
423
- .ele("item", { name: "editTextStyle" })
424
- .txt("@style/RN.Persona.EditText")
425
- .up();
426
- });
427
- this.postPrintQueue.push(() => {
428
- this.root = this.root
429
- .ele("style", {
430
- name: "RN.Persona.EditText",
431
- parent: "Widget.AppCompat.EditText",
432
- })
433
- .ele("item", { name: "android:textAppearance" })
434
- .txt("@style/RN.Persona.EditText.TextAppearance")
435
- .up()
436
- .ele("item", { name: "android:textColor" })
437
- .txt(this.theme.textFieldTextColor)
438
- .up()
439
- .up();
440
- this.root = this.root.ele("style", {
441
- name: "RN.Persona.EditText.TextAppearance",
442
- parent: "Base.TextAppearance.AppCompat.Medium",
443
- });
444
- if (this.theme.textFieldTextColor) {
445
- this.root = this.root
446
- .ele("item", { name: "android:textSize" })
447
- .txt("18sp")
448
- .up();
449
- }
450
- if (this.theme.textFieldTextFont) {
451
- this.root = this.root
452
- .ele("item", { name: "android:fontFamily" })
453
- .txt(this.theme.textFieldTextFont)
454
- .up();
455
- }
456
- this.root = this.root.up();
457
- });
458
- }
459
- }
460
- pickerText() {
461
- if (this.theme.pickerTextColor || this.theme.pickerTextFont) {
462
- this.printQueue.push(() => {
463
- this.root = this.root
464
- .ele("item", { name: "spinnerStyle" })
465
- .txt("@style/RN.Persona.Spinner")
466
- .up();
467
- this.root = this.root
468
- .ele("item", { name: "spinnerDropDownItemStyle" })
469
- .txt("@style/RN.Persona.DropDownItem.Spinner")
470
- .up();
471
- });
472
- this.postPrintQueue.push(() => {
473
- var _a, _b;
474
- // Build Rn.Persona.Spinner
475
- this.root = this.root
476
- .ele("style", {
477
- name: "RN.Persona.Spinner",
478
- parent: "Widget.AppCompat.Spinner",
479
- })
480
- .ele("item", { name: "android:textColor" })
481
- .txt((_a = this.theme.pickerTextColor) !== null && _a !== void 0 ? _a : "?android:attr/textColorPrimary")
482
- .up()
483
- .ele("item", { name: "android:textAppearance" })
484
- .txt(this.theme.pickerTextFont
485
- ? "@style/RN.Persona.Text.Spinner"
486
- : "@style/Persona.Text.Body")
487
- .up()
488
- .up();
489
- // Build RN.Persona.DropDownItem.Spinner
490
- this.root = this.root
491
- .ele("style", {
492
- name: "RN.Persona.DropDownItem.Spinner",
493
- parent: "Widget.AppCompat.DropDownItem.Spinner",
494
- })
495
- .ele("item", { name: "android:textColor" })
496
- .txt((_b = this.theme.pickerTextColor) !== null && _b !== void 0 ? _b : "?android:attr/textColorPrimary")
497
- .up()
498
- .ele("item", { name: "android:textAppearance" })
499
- .txt(this.theme.pickerTextFont
500
- ? "@style/RN.Persona.Text.Spinner"
501
- : "@style/Persona.Text.Body")
502
- .up()
503
- .up();
504
- // Build RN.Persona.Text.Spinner
505
- this.root = this.root.ele("style", {
506
- name: "RN.Persona.Text.Spinner",
507
- });
508
- if (this.theme.pickerTextColor) {
509
- this.root = this.root
510
- .ele("item", { name: "android:textColor" })
511
- .txt(this.theme.pickerTextColor)
512
- .up();
513
- }
514
- if (this.theme.pickerTextFont) {
515
- // TODO: Add notice about how to add a custom font that can be
516
- // referenced here on Android
517
- this.root = this.root
518
- .ele("item", { name: "android:fontFamily" })
519
- .txt(this.theme.pickerTextFont)
520
- .up();
521
- }
522
- this.root = this.root.up();
523
- });
524
- }
525
- }
526
- button() {
527
- if (this.theme.buttonBackgroundColor ||
528
- this.theme.buttonDisabledBackgroundColor ||
529
- this.theme.buttonTouchedBackgroundColor ||
530
- this.theme.buttonTextColor ||
531
- this.theme.buttonDisabledTextColor ||
532
- this.theme.buttonCornerRadius ||
533
- this.theme.buttonFont ||
534
- this.theme.buttonTextSize) {
535
- const textSize = this.theme.buttonTextSize ? `${this.theme.buttonTextSize}sp` : "18sp";
536
- this.printQueue.push(() => {
537
- this.root = this.root
538
- .ele("item", { name: "buttonStyle" })
539
- .txt("@style/RN.Persona.Button")
540
- .up();
541
-
542
- this.root = this.root
543
- .ele("item", { name: "buttonStyleSecondary" })
544
- .txt("@style/RN.Persona.Button.Secondary")
545
- .up();
546
- });
547
- this.postPrintQueue.push(() => {
548
- var _a, _b, _c, _d, _e;
549
- this.root = this.root
550
- .ele("style", {
551
- name: "RN.Persona.Button",
552
- parent: "android:style/Widget.Button",
553
- })
554
- // Taken from
555
- // appcompat's res/values/values.xml
556
- .ele("item", {
557
- name: "android:minHeight",
558
- })
559
- .txt("48dip")
560
- .up()
561
- // Taken from
562
- // appcompat's res/values/values.xml
563
- .ele("item", {
564
- name: "android:minWidth",
565
- })
566
- .txt("88dip")
567
- .up()
568
- // Taken from
569
- // persona-android's shared/src/main/res/values/styles.xml
570
- .ele("item", {
571
- name: "android:textSize",
572
- })
573
- .txt(textSize)
574
- .up()
575
- .ele("item", {
576
- name: "android:background",
577
- })
578
- .txt("@drawable/rn_persona_button")
579
- .up()
580
- .ele("item", {
581
- name: "android:textColor",
582
- })
583
- .txt("@color/rn_persona_button")
584
- .up()
585
- .up();
586
- // Build RN.Persona.Button.Secondary
587
- this.root = this.root
588
- .ele("style", {
589
- name: "RN.Persona.Button.Secondary",
590
- parent: "RN.Persona.Button",
591
- })
592
- .ele("item", {
593
- name: "android:background",
594
- })
595
- .txt("@drawable/rn_persona_button_secondary")
596
- .up()
597
- .up();
598
- // Disabled
599
- this.buttonDrawable = this.buttonDrawable
600
- .ele("item", {
601
- "android:state_enabled": "false",
602
- })
603
- .ele("shape", { "android:shape": "rectangle" })
604
- .ele("corners", {
605
- "android:radius": this.theme.buttonCornerRadius
606
- ? `${this.theme.buttonCornerRadius}dp`
607
- : "@dimen/abc_control_corner_material",
608
- })
609
- .up()
610
- .ele("padding", {
611
- "android:left": "@dimen/abc_button_padding_horizontal_material",
612
- "android:top": "@dimen/abc_button_padding_vertical_material",
613
- "android:right": "@dimen/abc_button_padding_horizontal_material",
614
- "android:bottom": "@dimen/abc_button_padding_vertical_material",
615
- })
616
- .up()
617
- .ele("solid", {
618
- "android:color": this.theme.buttonDisabledBackgroundColor
619
- ? this.theme.buttonDisabledBackgroundColor
620
- : "?attr/colorPrimaryDark",
621
- })
622
- .up()
623
- .up()
624
- .up();
625
- // touched
626
- this.buttonDrawable = this.buttonDrawable
627
- .ele("item", {
628
- "android:state_pressed": "true",
629
- })
630
- .ele("shape", { "android:shape": "rectangle" })
631
- .ele("corners", {
632
- "android:radius": this.theme.buttonCornerRadius
633
- ? `${this.theme.buttonCornerRadius}dp`
634
- : "@dimen/abc_control_corner_material",
635
- })
636
- .up()
637
- .ele("solid", {
638
- "android:color": (_a = this.theme.buttonTouchedBackgroundColor) !== null && _a !== void 0 ? _a : "?attr/colorPrimaryDark",
639
- })
640
- .up()
641
- .ele("padding", {
642
- "android:left": "@dimen/abc_button_padding_horizontal_material",
643
- "android:top": "@dimen/abc_button_padding_vertical_material",
644
- "android:right": "@dimen/abc_button_padding_horizontal_material",
645
- "android:bottom": "@dimen/abc_button_padding_vertical_material",
646
- })
647
- .up()
648
- .up()
649
- .up();
650
- this.buttonDrawable = this.buttonDrawable
651
- .ele("item")
652
- .ele("shape", { "android:shape": "rectangle" })
653
- .ele("corners", {
654
- "android:radius": this.theme.buttonCornerRadius
655
- ? `${this.theme.buttonCornerRadius}dp`
656
- : "@dimen/abc_control_corner_material",
657
- })
658
- .up()
659
- .ele("solid", {
660
- "android:color": (_b = this.theme.buttonBackgroundColor) !== null && _b !== void 0 ? _b : "?attr/colorPrimary",
661
- })
662
- .up()
663
- .ele("padding", {
664
- "android:left": "@dimen/abc_button_padding_horizontal_material",
665
- "android:top": "@dimen/abc_button_padding_vertical_material",
666
- "android:right": "@dimen/abc_button_padding_horizontal_material",
667
- "android:bottom": "@dimen/abc_button_padding_vertical_material",
668
- })
669
- .up()
670
- .up()
671
- .up();
672
- // Disabled
673
- this.buttonSecondaryDrawable = this.buttonSecondaryDrawable
674
- .ele("item", {
675
- "android:state_enabled": "false",
676
- })
677
- .ele("shape", { "android:shape": "rectangle" })
678
- .ele("corners", {
679
- "android:radius": this.theme.buttonCornerRadius
680
- ? `${this.theme.buttonCornerRadius}dp`
681
- : "@dimen/abc_control_corner_material",
682
- })
683
- .up()
684
- .ele("padding", {
685
- "android:left": "@dimen/abc_button_padding_horizontal_material",
686
- "android:top": "@dimen/abc_button_padding_vertical_material",
687
- "android:right": "@dimen/abc_button_padding_horizontal_material",
688
- "android:bottom": "@dimen/abc_button_padding_vertical_material",
689
- })
690
- .up()
691
- .ele("solid", {
692
- "android:color": "@android:color/darker_gray",
693
- })
694
- .up()
695
- .up()
696
- .up();
697
- // touched
698
- this.buttonSecondaryDrawable = this.buttonSecondaryDrawable
699
- .ele("item", {
700
- "android:state_pressed": "true",
701
- })
702
- .ele("shape", { "android:shape": "rectangle" })
703
- .ele("corners", {
704
- "android:radius": this.theme.buttonCornerRadius
705
- ? `${this.theme.buttonCornerRadius}dp`
706
- : "@dimen/abc_control_corner_material",
707
- })
708
- .up()
709
- .ele("solid", {
710
- "android:color": "@color/grayButtonDark",
711
- })
712
- .up()
713
- .ele("padding", {
714
- "android:left": "@dimen/abc_button_padding_horizontal_material",
715
- "android:top": "@dimen/abc_button_padding_vertical_material",
716
- "android:right": "@dimen/abc_button_padding_horizontal_material",
717
- "android:bottom": "@dimen/abc_button_padding_vertical_material",
718
- })
719
- .up()
720
- .up()
721
- .up();
722
- this.buttonSecondaryDrawable = this.buttonSecondaryDrawable
723
- .ele("item")
724
- .ele("shape", { "android:shape": "rectangle" })
725
- .ele("corners", {
726
- "android:radius": this.theme.buttonCornerRadius
727
- ? `${this.theme.buttonCornerRadius}dp`
728
- : "@dimen/abc_control_corner_material",
729
- })
730
- .up()
731
- .ele("solid", {
732
- "android:color": "@color/grayButton",
733
- })
734
- .up()
735
- .ele("padding", {
736
- "android:left": "@dimen/abc_button_padding_horizontal_material",
737
- "android:top": "@dimen/abc_button_padding_vertical_material",
738
- "android:right": "@dimen/abc_button_padding_horizontal_material",
739
- "android:bottom": "@dimen/abc_button_padding_vertical_material",
740
- })
741
- .up()
742
- .up()
743
- .up();
744
- // Finish button drawable
745
- this.buttonDrawable = this.buttonDrawable.up();
746
- this.buttonSecondaryDrawable = this.buttonSecondaryDrawable.up();
747
- this.buttonColor = this.buttonColor
748
- .ele("item", {
749
- "android:state_enabled": "false",
750
- "android:color": (_c = this.theme.buttonDisabledTextColor) !== null && _c !== void 0 ? _c : "@android:color/darker_gray",
751
- })
752
- .up()
753
- .ele("item", {
754
- "android:state_pressed": "true",
755
- "android:color": (_d = this.theme.buttonTextColor) !== null && _d !== void 0 ? _d : "@android:color/white",
756
- })
757
- .up()
758
- .ele("item", {
759
- "android:color": (_e = this.theme.buttonTextColor) !== null && _e !== void 0 ? _e : "@android:color/white",
760
- })
761
- .up();
762
- this.buttonColor = this.buttonColor.up();
763
- this.root = this.root.up();
764
- });
765
- }
766
- }
767
- progressColor() {
768
- if (this.theme.progressColor) {
769
- this.printQueue.push(() => {
770
- this.root = this.root
771
- .ele("item", { name: "colorControlActivated" })
772
- .txt(this.theme.progressColor)
773
- .up();
774
- });
775
- }
776
- }
777
- successAsset() {
778
- if (!this.theme.successAsset)
779
- return;
780
- this.printQueue.push(() => {
781
- this.root = this.root
782
- .ele("item", { name: "personaInquiryCompleteImage" })
783
- .txt(this.theme.successAsset)
784
- .up()
785
- .txt(" ");
786
- });
787
- }
788
- failAsset() {
789
- if (!this.theme.failAsset)
790
- return;
791
- this.printQueue.push(() => {
792
- this.root = this.root
793
- .ele("item", { name: "personaInquiryFailImage" })
794
- .txt(this.theme.failAsset)
795
- .up()
796
- .txt(" ");
797
- });
798
- }
799
- loadingAnimationAsset() {
800
- if (!this.theme.loadingAnimationAsset || !this.theme.loadingAnimationWidthPercent)
801
- return;
802
- this.printQueue.push(() => {
803
- this.root = this.root
804
- .ele("item", { name: "personaInquiryLoadingLottieRaw" })
805
- .txt(this.theme.loadingAnimationAsset)
806
- .up()
807
- .txt(" ");
808
- this.root = this.root
809
- .ele("item", { name: "personaInquiryLoadingLottieWidthPercent" })
810
- .txt(this.theme.loadingAnimationWidthPercent)
811
- .up()
812
- .txt(" ");
813
- });
814
- }
815
- selfieAnimationAsset() {
816
- if (!this.theme.selfieAnimationAsset || !this.theme.selfieAnimationWidthPercent)
817
- return;
818
- this.printQueue.push(() => {
819
- this.root = this.root
820
- .ele("item", { name: "personaInquirySelfieLottieRaw" })
821
- .txt(this.theme.selfieAnimationAsset)
822
- .up()
823
- .txt(" ");
824
- this.root = this.root
825
- .ele("item", { name: "personaInquirySelfieLottieWidthPercent" })
826
- .txt(this.theme.selfieAnimationWidthPercent)
827
- .up()
828
- .txt(" ");
829
- });
830
- }
831
- }
832
- exports.default = AndroidResourcePrinter;