react-native-persona 1.2.5 → 1.2.9
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.
- package/CHANGELOG.md +28 -0
- package/RNPersonaInquiry.podspec +1 -1
- package/android/build.gradle +1 -1
- package/ios/PersonaInquiry.swift +46 -14
- package/package.json +2 -2
- package/persona-tools/Theme.js +31 -7
- package/persona-tools/Theme.ts +34 -7
- package/persona-tools/lib/AndroidResourcePrinter.js +271 -10
- package/persona-tools/lib/AndroidResourcePrinter.spec.js +227 -6
- package/persona-tools/lib/AndroidResourcePrinter.spec.ts +285 -8
- package/persona-tools/lib/AndroidResourcePrinter.ts +280 -12
- package/persona-tools/tools/AndroidThemeGenerator.js +5 -1
- package/persona-tools/tools/AndroidThemeGenerator.ts +22 -3
|
@@ -11,6 +11,9 @@ class AndroidResourcePrinter {
|
|
|
11
11
|
this.buttonDrawable = xmlbuilder2_1.create({ version: "1.0" }).ele("selector", {
|
|
12
12
|
"xmlns:android": "http://schemas.android.com/apk/res/android",
|
|
13
13
|
});
|
|
14
|
+
this.buttonSecondaryDrawable = xmlbuilder2_1.create({ version: "1.0" }).ele("selector", {
|
|
15
|
+
"xmlns:android": "http://schemas.android.com/apk/res/android",
|
|
16
|
+
});
|
|
14
17
|
this.buttonColor = xmlbuilder2_1.create({ version: "1.0" }).ele("selector", {
|
|
15
18
|
"xmlns:android": "http://schemas.android.com/apk/res/android",
|
|
16
19
|
});
|
|
@@ -25,6 +28,7 @@ class AndroidResourcePrinter {
|
|
|
25
28
|
return {
|
|
26
29
|
style: this.root,
|
|
27
30
|
buttonDrawable: this.buttonDrawable,
|
|
31
|
+
buttonSecondaryDrawable: this.buttonSecondaryDrawable,
|
|
28
32
|
buttonColor: this.buttonColor,
|
|
29
33
|
};
|
|
30
34
|
}
|
|
@@ -36,6 +40,9 @@ class AndroidResourcePrinter {
|
|
|
36
40
|
this.titleText();
|
|
37
41
|
this.bodyText();
|
|
38
42
|
this.footnoteText();
|
|
43
|
+
this.cameraInstructionsText();
|
|
44
|
+
this.cameraHintText();
|
|
45
|
+
this.cameraGuideHintText();
|
|
39
46
|
// this.formLabelText();
|
|
40
47
|
this.textField();
|
|
41
48
|
this.pickerText();
|
|
@@ -126,7 +133,7 @@ class AndroidResourcePrinter {
|
|
|
126
133
|
});
|
|
127
134
|
}
|
|
128
135
|
titleText() {
|
|
129
|
-
if (this.theme.titleTextColor || this.theme.titleTextFont) {
|
|
136
|
+
if (this.theme.titleTextColor || this.theme.titleTextSize || this.theme.titleTextFont) {
|
|
130
137
|
this.printQueue.push(() => {
|
|
131
138
|
this.root = this.root
|
|
132
139
|
.ele("item", { name: "personaTitleTextAppearance" })
|
|
@@ -155,9 +162,10 @@ class AndroidResourcePrinter {
|
|
|
155
162
|
}
|
|
156
163
|
// Default values taken from `Persona.Text.Title`
|
|
157
164
|
// in shared/src/main/res/values/styles.xml
|
|
165
|
+
const textSize = this.theme.titleTextSize ? `${this.theme.titleTextSize}sp` : "26sp";
|
|
158
166
|
this.root = this.root
|
|
159
167
|
.ele("item", { name: "android:textSize" })
|
|
160
|
-
.txt(
|
|
168
|
+
.txt(textSize)
|
|
161
169
|
.up()
|
|
162
170
|
.ele("item", { name: "android:textStyle" })
|
|
163
171
|
.txt("bold")
|
|
@@ -175,7 +183,7 @@ class AndroidResourcePrinter {
|
|
|
175
183
|
}
|
|
176
184
|
}
|
|
177
185
|
bodyText() {
|
|
178
|
-
if (this.theme.bodyTextColor || this.theme.bodyTextFont) {
|
|
186
|
+
if (this.theme.bodyTextColor || this.theme.bodyTextSize || this.theme.bodyTextFont) {
|
|
179
187
|
this.printQueue.push(() => {
|
|
180
188
|
this.root = this.root
|
|
181
189
|
.ele("item", { name: "personaBodyTextAppearance" })
|
|
@@ -204,10 +212,12 @@ class AndroidResourcePrinter {
|
|
|
204
212
|
}
|
|
205
213
|
// Default values taken from `Persona.Text.Body`
|
|
206
214
|
// in shared/src/main/res/values/styles.xml
|
|
215
|
+
const textSize = this.theme.bodyTextSize ? `${this.theme.bodyTextSize}sp` : "18sp";
|
|
207
216
|
this.root = this.root
|
|
208
217
|
.ele("item", { name: "android:textSize" })
|
|
209
|
-
.txt(
|
|
218
|
+
.txt(textSize)
|
|
210
219
|
.up();
|
|
220
|
+
|
|
211
221
|
this.root = this.root.up();
|
|
212
222
|
});
|
|
213
223
|
}
|
|
@@ -226,10 +236,6 @@ class AndroidResourcePrinter {
|
|
|
226
236
|
var _a, _b;
|
|
227
237
|
this.root = this.root
|
|
228
238
|
.ele("style", { name: "TextAppearance.AppCompat.Small" })
|
|
229
|
-
.ele("item", { name: "android:textSize" })
|
|
230
|
-
// Used default value found in the Android SDK
|
|
231
|
-
.txt("@dimen/abc_text_size_small_material")
|
|
232
|
-
.up()
|
|
233
239
|
.ele("item", { name: "android:textColor" })
|
|
234
240
|
.txt((_a =
|
|
235
241
|
// Used default value found in the Android SDK
|
|
@@ -243,10 +249,173 @@ class AndroidResourcePrinter {
|
|
|
243
249
|
this.theme.footnoteTextFont) !== null && _b !== void 0 ? _b : "?android:attr/textColorTertiary")
|
|
244
250
|
.up();
|
|
245
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
|
+
|
|
246
259
|
this.root = this.root.up();
|
|
247
260
|
});
|
|
248
261
|
}
|
|
249
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
|
+
}
|
|
250
419
|
textField() {
|
|
251
420
|
if (this.theme.textFieldTextColor || this.theme.textFieldTextFont) {
|
|
252
421
|
this.printQueue.push(() => {
|
|
@@ -361,12 +530,19 @@ class AndroidResourcePrinter {
|
|
|
361
530
|
this.theme.buttonTextColor ||
|
|
362
531
|
this.theme.buttonDisabledTextColor ||
|
|
363
532
|
this.theme.buttonCornerRadius ||
|
|
364
|
-
this.theme.buttonFont
|
|
533
|
+
this.theme.buttonFont ||
|
|
534
|
+
this.theme.buttonTextSize) {
|
|
535
|
+
const textSize = this.theme.buttonTextSize ? `${this.theme.buttonTextSize}sp` : "18sp";
|
|
365
536
|
this.printQueue.push(() => {
|
|
366
537
|
this.root = this.root
|
|
367
538
|
.ele("item", { name: "buttonStyle" })
|
|
368
539
|
.txt("@style/RN.Persona.Button")
|
|
369
540
|
.up();
|
|
541
|
+
|
|
542
|
+
this.root = this.root
|
|
543
|
+
.ele("item", { name: "buttonStyleSecondary" })
|
|
544
|
+
.txt("@style/RN.Persona.Button.Secondary")
|
|
545
|
+
.up();
|
|
370
546
|
});
|
|
371
547
|
this.postPrintQueue.push(() => {
|
|
372
548
|
var _a, _b, _c, _d, _e;
|
|
@@ -394,7 +570,7 @@ class AndroidResourcePrinter {
|
|
|
394
570
|
.ele("item", {
|
|
395
571
|
name: "android:textSize",
|
|
396
572
|
})
|
|
397
|
-
.txt(
|
|
573
|
+
.txt(textSize)
|
|
398
574
|
.up()
|
|
399
575
|
.ele("item", {
|
|
400
576
|
name: "android:background",
|
|
@@ -407,6 +583,18 @@ class AndroidResourcePrinter {
|
|
|
407
583
|
.txt("@color/rn_persona_button")
|
|
408
584
|
.up()
|
|
409
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();
|
|
410
598
|
// Disabled
|
|
411
599
|
this.buttonDrawable = this.buttonDrawable
|
|
412
600
|
.ele("item", {
|
|
@@ -481,8 +669,81 @@ class AndroidResourcePrinter {
|
|
|
481
669
|
.up()
|
|
482
670
|
.up()
|
|
483
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();
|
|
484
744
|
// Finish button drawable
|
|
485
745
|
this.buttonDrawable = this.buttonDrawable.up();
|
|
746
|
+
this.buttonSecondaryDrawable = this.buttonSecondaryDrawable.up();
|
|
486
747
|
this.buttonColor = this.buttonColor
|
|
487
748
|
.ele("item", {
|
|
488
749
|
"android:state_enabled": "false",
|