react-native-persona 2.1.3 → 2.2.2
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 +31 -0
- package/README.md +156 -2
- package/{RNPersonaInquiry.podspec → RNPersonaInquiry2.podspec} +2 -2
- package/android/README.md +14 -0
- package/android/build.gradle +22 -99
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/withpersona/{sdk/reactnative/PersonaInquiryModule.java → sdk2/reactnative/PersonaInquiryModule2.java} +24 -14
- package/android/src/main/java/com/withpersona/{sdk/reactnative/PersonaInquiryPackage.java → sdk2/reactnative/PersonaInquiryPackage2.java} +3 -3
- package/android/src/main/java/com/withpersona/{sdk → sdk2}/reactnative/exceptions/InvalidConfiguration.java +1 -1
- package/android/src/main/res/values/theme.xml +2 -3
- package/ios/{PersonaInquiry.swift → PersonaInquiry2.swift} +17 -13
- package/ios/PersonaInquiryBridge.m +1 -1
- package/lib/commonjs/fields.js +141 -0
- package/lib/commonjs/fields.js.map +1 -0
- package/lib/commonjs/index.js +475 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/util.js +36 -0
- package/lib/commonjs/util.js.map +1 -0
- package/lib/commonjs/versions.js +25 -0
- package/lib/commonjs/versions.js.map +1 -0
- package/lib/module/fields.js +132 -0
- package/lib/module/fields.js.map +1 -0
- package/lib/module/index.js +435 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/util.js +29 -0
- package/lib/module/util.js.map +1 -0
- package/lib/module/versions.js +14 -0
- package/lib/module/versions.js.map +1 -0
- package/{generatedTypes/persona-tools/config.d.ts → lib/typescript/persona-tools/Config.d.ts} +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/Theme.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/index.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/lib/AndroidResourcePrinter.d.ts +2 -2
- package/{generatedTypes → lib/typescript}/persona-tools/lib/prompts.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/tools/AndroidThemeGenerator.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/tools/IosThemeInstructions.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/src/fields.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/src/index.d.ts +56 -5
- package/{generatedTypes → lib/typescript}/src/util.d.ts +0 -0
- package/lib/typescript/src/versions.d.ts +6 -0
- package/package.json +74 -18
- package/persona-tools/{config.ts → Config.ts} +7 -7
- package/persona-tools/Theme.ts +107 -107
- package/persona-tools/index.ts +9 -9
- package/persona-tools/lib/AndroidResourcePrinter.ts +4 -4
- package/persona-tools/tools/AndroidThemeGenerator.ts +18 -18
- package/persona-tools/tools/IosThemeInstructions.ts +8 -8
- package/src/fields.ts +7 -7
- package/src/index.ts +89 -26
- package/src/util.ts +2 -2
- package/src/versions.ts +12 -0
- package/generatedTypes/persona-tools/lib/AndroidResourcePrinter.spec.d.ts +0 -1
- package/generatedTypes/src/fields.spec.d.ts +0 -1
- package/generatedTypes/src/util.spec.d.ts +0 -1
- package/jest.config.js +0 -10
- package/persona-tools/Theme.js +0 -186
- package/persona-tools/config.js +0 -72
- package/persona-tools/index.js +0 -30
- package/persona-tools/lib/AndroidResourcePrinter.js +0 -573
- package/persona-tools/lib/AndroidResourcePrinter.spec.js +0 -914
- package/persona-tools/lib/AndroidResourcePrinter.spec.ts +0 -952
- package/persona-tools/lib/prompts.js +0 -39
- package/persona-tools/tools/AndroidThemeGenerator.js +0 -55
- package/persona-tools/tools/IosThemeInstructions.js +0 -34
- package/src/fields.js +0 -88
- package/src/fields.spec.js +0 -18
- package/src/fields.spec.ts +0 -17
- package/src/index.js +0 -271
- package/src/util.js +0 -29
- package/src/util.spec.js +0 -17
- package/src/util.spec.ts +0 -22
- package/tsconfig.json +0 -29
package/persona-tools/Theme.ts
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
import Table from
|
|
2
|
-
import chalk from
|
|
1
|
+
import Table from 'cli-table';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
3
|
|
|
4
|
-
import Config from
|
|
4
|
+
import Config from './Config';
|
|
5
5
|
|
|
6
6
|
const COLOR_REGEX = /^[a-zA-Z0-9]{6}$/;
|
|
7
7
|
|
|
8
8
|
export enum ANDROID_THEME_CONFIG_KEY {
|
|
9
|
-
backgroundColor =
|
|
10
|
-
primaryColor =
|
|
11
|
-
darkPrimaryColor =
|
|
12
|
-
accentColor =
|
|
9
|
+
backgroundColor = 'backgroundColor',
|
|
10
|
+
primaryColor = 'primaryColor',
|
|
11
|
+
darkPrimaryColor = 'darkPrimaryColor',
|
|
12
|
+
accentColor = 'accentColor',
|
|
13
13
|
|
|
14
|
-
titleTextColor =
|
|
15
|
-
titleTextFont =
|
|
14
|
+
titleTextColor = 'titleTextColor',
|
|
15
|
+
titleTextFont = 'titleTextFont',
|
|
16
16
|
|
|
17
|
-
bodyTextColor =
|
|
18
|
-
bodyTextFont =
|
|
17
|
+
bodyTextColor = 'bodyTextColor',
|
|
18
|
+
bodyTextFont = 'bodyTextFont',
|
|
19
19
|
|
|
20
|
-
footnoteTextColor =
|
|
21
|
-
footnoteTextFont =
|
|
20
|
+
footnoteTextColor = 'footnoteTextColor',
|
|
21
|
+
footnoteTextFont = 'footnoteTextFont',
|
|
22
22
|
|
|
23
23
|
// formLabelTextColor = "formLabelTextColor",
|
|
24
24
|
// formLabelTextFont = "formLabelTextFont",
|
|
25
25
|
|
|
26
|
-
textFieldTextColor =
|
|
27
|
-
textFieldTextFont =
|
|
26
|
+
textFieldTextColor = 'textFieldTextColor',
|
|
27
|
+
textFieldTextFont = 'textFieldTextFont',
|
|
28
28
|
|
|
29
|
-
pickerTextColor =
|
|
30
|
-
pickerTextFont =
|
|
29
|
+
pickerTextColor = 'pickerTextColor',
|
|
30
|
+
pickerTextFont = 'pickerTextFont',
|
|
31
31
|
|
|
32
|
-
buttonBackgroundColor =
|
|
33
|
-
buttonDisabledBackgroundColor =
|
|
34
|
-
buttonTouchedBackgroundColor =
|
|
35
|
-
buttonTextColor =
|
|
36
|
-
buttonDisabledTextColor =
|
|
32
|
+
buttonBackgroundColor = 'buttonBackgroundColor',
|
|
33
|
+
buttonDisabledBackgroundColor = 'buttonDisabledBackgroundColor',
|
|
34
|
+
buttonTouchedBackgroundColor = 'buttonTouchedBackgroundColor',
|
|
35
|
+
buttonTextColor = 'buttonTextColor',
|
|
36
|
+
buttonDisabledTextColor = 'buttonDisabledTextColor',
|
|
37
37
|
// buttonTextAlignment = "buttonTextAlignment",
|
|
38
|
-
buttonCornerRadius =
|
|
39
|
-
buttonFont =
|
|
40
|
-
progressColor =
|
|
41
|
-
successAsset =
|
|
42
|
-
failAsset =
|
|
43
|
-
loadingAnimationAsset =
|
|
44
|
-
loadingAnimationWidthPercent =
|
|
45
|
-
selfieAnimationAsset =
|
|
46
|
-
selfieAnimationWidthPercent =
|
|
38
|
+
buttonCornerRadius = 'buttonCornerRadius',
|
|
39
|
+
buttonFont = 'buttonFont',
|
|
40
|
+
progressColor = 'progressColor',
|
|
41
|
+
successAsset = 'successAsset',
|
|
42
|
+
failAsset = 'failAsset',
|
|
43
|
+
loadingAnimationAsset = 'loadingAnimationAsset',
|
|
44
|
+
loadingAnimationWidthPercent = 'loadingAnimationWidthPercent',
|
|
45
|
+
selfieAnimationAsset = 'selfieAnimationAsset',
|
|
46
|
+
selfieAnimationWidthPercent = 'selfieAnimationWidthPercent',
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export enum IOS_THEME_CONFIG_KEY {
|
|
50
|
-
backgroundColor =
|
|
51
|
-
primaryColor =
|
|
52
|
-
darkPrimaryColor =
|
|
53
|
-
accentColor =
|
|
54
|
-
overlayBackgroundColor =
|
|
55
|
-
titleTextColor =
|
|
56
|
-
titleTextFont =
|
|
57
|
-
bodyTextColor =
|
|
58
|
-
bodyTextFont =
|
|
59
|
-
footnoteTextColor =
|
|
60
|
-
footnoteTextFont =
|
|
61
|
-
formLabelTextColor =
|
|
62
|
-
formLabelTextFont =
|
|
63
|
-
textFieldTextColor =
|
|
64
|
-
textFieldBackgroundColor =
|
|
65
|
-
textFieldBorderColor =
|
|
66
|
-
pickerTextColor =
|
|
67
|
-
pickerTextFont =
|
|
68
|
-
buttonBackgroundColor =
|
|
69
|
-
buttonDisabledBackgroundColor =
|
|
70
|
-
buttonTouchedBackgroundColor =
|
|
71
|
-
buttonImageTintColor =
|
|
72
|
-
buttonTextColor =
|
|
73
|
-
buttonDisabledTextColor =
|
|
74
|
-
buttonTextAlignment =
|
|
75
|
-
buttonCornerRadius =
|
|
76
|
-
buttonFont =
|
|
77
|
-
selectedCellBackgroundColor =
|
|
78
|
-
closeButtonTintColor =
|
|
79
|
-
cancelButtonBackgroundColor =
|
|
80
|
-
progressColor =
|
|
81
|
-
cameraGuideCornersColor =
|
|
82
|
-
cameraButtonBackgroundColor =
|
|
83
|
-
successAssetName =
|
|
84
|
-
successAssetWidth =
|
|
85
|
-
successAssetHeight =
|
|
86
|
-
verificationFailAssetName =
|
|
87
|
-
verificationFailAssetWidth =
|
|
88
|
-
verificationFailAssetHeight =
|
|
89
|
-
failAssetName =
|
|
90
|
-
failAssetWidth =
|
|
91
|
-
failAssetHeight =
|
|
92
|
-
loadingAnimationAssetName =
|
|
93
|
-
loadingAnimationAssetWidth =
|
|
94
|
-
loadingAnimationAssetHeight =
|
|
95
|
-
processingAnimationAssetName =
|
|
96
|
-
processingAnimationAssetWidth =
|
|
97
|
-
processingAnimationAssetHeight =
|
|
98
|
-
selfieAnimationAssetName =
|
|
99
|
-
selfieAnimationAssetWidth =
|
|
100
|
-
selfieAnimationAssetHeight =
|
|
50
|
+
backgroundColor = 'backgroundColor',
|
|
51
|
+
primaryColor = 'primaryColor',
|
|
52
|
+
darkPrimaryColor = 'darkPrimaryColor',
|
|
53
|
+
accentColor = 'accentColor',
|
|
54
|
+
overlayBackgroundColor = 'overlayBackgroundColor',
|
|
55
|
+
titleTextColor = 'titleTextColor',
|
|
56
|
+
titleTextFont = 'titleTextFont',
|
|
57
|
+
bodyTextColor = 'bodyTextColor',
|
|
58
|
+
bodyTextFont = 'bodyTextFont',
|
|
59
|
+
footnoteTextColor = 'footnoteTextColor',
|
|
60
|
+
footnoteTextFont = 'footnoteTextFont',
|
|
61
|
+
formLabelTextColor = 'formLabelTextColor',
|
|
62
|
+
formLabelTextFont = 'formLabelTextFont',
|
|
63
|
+
textFieldTextColor = 'textFieldTextColor',
|
|
64
|
+
textFieldBackgroundColor = 'textFieldBackgroundColor',
|
|
65
|
+
textFieldBorderColor = 'textFieldBorderColor',
|
|
66
|
+
pickerTextColor = 'pickerTextColor',
|
|
67
|
+
pickerTextFont = 'pickerTextFont',
|
|
68
|
+
buttonBackgroundColor = 'buttonBackgroundColor',
|
|
69
|
+
buttonDisabledBackgroundColor = 'buttonDisabledBackgroundColor',
|
|
70
|
+
buttonTouchedBackgroundColor = 'buttonTouchedBackgroundColor',
|
|
71
|
+
buttonImageTintColor = 'buttonImageTintColor',
|
|
72
|
+
buttonTextColor = 'buttonTextColor',
|
|
73
|
+
buttonDisabledTextColor = 'buttonDisabledTextColor',
|
|
74
|
+
buttonTextAlignment = 'buttonTextAlignment',
|
|
75
|
+
buttonCornerRadius = 'buttonCornerRadius',
|
|
76
|
+
buttonFont = 'buttonFont',
|
|
77
|
+
selectedCellBackgroundColor = 'selectedCellBackgroundColor',
|
|
78
|
+
closeButtonTintColor = 'closeButtonTintColor',
|
|
79
|
+
cancelButtonBackgroundColor = 'cancelButtonBackgroundColor',
|
|
80
|
+
progressColor = 'progressColor',
|
|
81
|
+
cameraGuideCornersColor = 'cameraGuideCornersColor',
|
|
82
|
+
cameraButtonBackgroundColor = 'cameraButtonBackgroundColor',
|
|
83
|
+
successAssetName = 'successAssetName',
|
|
84
|
+
successAssetWidth = 'successAssetWidth',
|
|
85
|
+
successAssetHeight = 'successAssetHeight',
|
|
86
|
+
verificationFailAssetName = 'verificationFailAssetName',
|
|
87
|
+
verificationFailAssetWidth = 'verificationFailAssetWidth',
|
|
88
|
+
verificationFailAssetHeight = 'verificationFailAssetHeight',
|
|
89
|
+
failAssetName = 'failAssetName',
|
|
90
|
+
failAssetWidth = 'failAssetWidth',
|
|
91
|
+
failAssetHeight = 'failAssetHeight',
|
|
92
|
+
loadingAnimationAssetName = 'loadingAnimationAssetName',
|
|
93
|
+
loadingAnimationAssetWidth = 'loadingAnimationAssetWidth',
|
|
94
|
+
loadingAnimationAssetHeight = 'loadingAnimationAssetHeight',
|
|
95
|
+
processingAnimationAssetName = 'processingAnimationAssetName',
|
|
96
|
+
processingAnimationAssetWidth = 'processingAnimationAssetWidth',
|
|
97
|
+
processingAnimationAssetHeight = 'processingAnimationAssetHeight',
|
|
98
|
+
selfieAnimationAssetName = 'selfieAnimationAssetName',
|
|
99
|
+
selfieAnimationAssetWidth = 'selfieAnimationAssetWidth',
|
|
100
|
+
selfieAnimationAssetHeight = 'selfieAnimationAssetHeight',
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
export type AndroidThemeObject = {
|
|
@@ -111,17 +111,17 @@ export type IosThemeObject = {
|
|
|
111
111
|
export type ThemeObject = AndroidThemeObject | IosThemeObject;
|
|
112
112
|
|
|
113
113
|
class Theme {
|
|
114
|
-
async print(platform: string =
|
|
114
|
+
async print(platform: string = 'android') {
|
|
115
115
|
const config = await Config.get();
|
|
116
116
|
const themeConfig =
|
|
117
|
-
platform ===
|
|
117
|
+
platform === 'android' ? config.androidTheme : config.iosTheme;
|
|
118
118
|
let usesCustomFontAndroid = false;
|
|
119
119
|
let usesCustomFontIos = false;
|
|
120
120
|
|
|
121
121
|
const head =
|
|
122
|
-
platform ===
|
|
123
|
-
? [
|
|
124
|
-
: [
|
|
122
|
+
platform === 'android'
|
|
123
|
+
? ['Style Item', 'Value', 'Note']
|
|
124
|
+
: ['Style Item', 'Value', 'Note'];
|
|
125
125
|
|
|
126
126
|
const table = new Table({
|
|
127
127
|
head,
|
|
@@ -129,13 +129,13 @@ class Theme {
|
|
|
129
129
|
chars: { 'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
console.log(
|
|
132
|
+
console.log('Specified theme values:');
|
|
133
133
|
const keyEnum =
|
|
134
|
-
platform ===
|
|
134
|
+
platform === 'android' ? ANDROID_THEME_CONFIG_KEY : IOS_THEME_CONFIG_KEY;
|
|
135
135
|
for (const key in keyEnum) {
|
|
136
136
|
let override =
|
|
137
137
|
themeConfig[key as ANDROID_THEME_CONFIG_KEY | IOS_THEME_CONFIG_KEY];
|
|
138
|
-
let colorOverride = key.includes(
|
|
138
|
+
let colorOverride = key.includes('Color') || key.includes('color');
|
|
139
139
|
|
|
140
140
|
if (override) {
|
|
141
141
|
if (colorOverride) {
|
|
@@ -145,8 +145,8 @@ class Theme {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
if (key.includes(
|
|
149
|
-
if (platform ==
|
|
148
|
+
if (key.includes('Font')) {
|
|
149
|
+
if (platform == 'android') {
|
|
150
150
|
usesCustomFontAndroid = true;
|
|
151
151
|
} else {
|
|
152
152
|
usesCustomFontIos = true;
|
|
@@ -159,10 +159,10 @@ class Theme {
|
|
|
159
159
|
key,
|
|
160
160
|
override
|
|
161
161
|
? valueColor(colorOverride, override)
|
|
162
|
-
: chalk.yellow(
|
|
163
|
-
key.includes(
|
|
164
|
-
? chalk.cyan(
|
|
165
|
-
:
|
|
162
|
+
: chalk.yellow('unspecified'),
|
|
163
|
+
key.includes('Font')
|
|
164
|
+
? chalk.cyan('Fonts that are not built-in need to be installed.')
|
|
165
|
+
: '',
|
|
166
166
|
];
|
|
167
167
|
|
|
168
168
|
table.push(row);
|
|
@@ -172,20 +172,20 @@ class Theme {
|
|
|
172
172
|
|
|
173
173
|
if (usesCustomFontAndroid) {
|
|
174
174
|
console.log(
|
|
175
|
-
chalk.yellow(
|
|
176
|
-
|
|
175
|
+
chalk.yellow(' NOTE') +
|
|
176
|
+
': A font customization was made. If the font is not built-in to the Android platform (https://github.com/react-native-training/react-native-fonts#android), then the font(s) must first be installed. A guide to install a font can be found here: https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml'
|
|
177
177
|
);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
if (usesCustomFontIos) {
|
|
181
181
|
console.log(
|
|
182
|
-
chalk.yellow(
|
|
183
|
-
|
|
182
|
+
chalk.yellow(' NOTE') +
|
|
183
|
+
': A font customization was made. If the font is not built-in iOS (https://github.com/react-native-training/react-native-ios), then the font(s) must first be installed. A guide to install a font can be found here: https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app'
|
|
184
184
|
);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
// Add newline for spacing
|
|
188
|
-
console.log(
|
|
188
|
+
console.log('');
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
|
|
@@ -198,7 +198,7 @@ function valueColor(isColorOverride: boolean, override: string) {
|
|
|
198
198
|
|
|
199
199
|
function normalizeColor(colorHex: string, themeKey: string) {
|
|
200
200
|
let hex = colorHex;
|
|
201
|
-
if (colorHex[0] ===
|
|
201
|
+
if (colorHex[0] === '#') {
|
|
202
202
|
hex = colorHex.slice(1);
|
|
203
203
|
}
|
|
204
204
|
|
|
@@ -208,19 +208,19 @@ function normalizeColor(colorHex: string, themeKey: string) {
|
|
|
208
208
|
`Received a color value of ${chalk.yellow(colorHex)} for ${chalk.red(
|
|
209
209
|
themeKey
|
|
210
210
|
)}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk
|
|
211
|
-
.bgHex(
|
|
212
|
-
.hex(
|
|
211
|
+
.bgHex('#FFFFFF')
|
|
212
|
+
.hex('#7E66B7')('#290087')}`
|
|
213
213
|
);
|
|
214
214
|
} else {
|
|
215
215
|
console.error(
|
|
216
216
|
`Received a color value of ${chalk.yellow(
|
|
217
217
|
colorHex
|
|
218
218
|
)}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk
|
|
219
|
-
.bgHex(
|
|
220
|
-
.hex(
|
|
219
|
+
.bgHex('#FFFFFF')
|
|
220
|
+
.hex('#7E66B7')('#290087')}`
|
|
221
221
|
);
|
|
222
222
|
}
|
|
223
|
-
console.log(
|
|
223
|
+
console.log('');
|
|
224
224
|
process.exit(1);
|
|
225
225
|
}
|
|
226
226
|
|
package/persona-tools/index.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import Config from
|
|
2
|
-
import { TOOL_CHOICE, whatWouldYouLikePrompt } from
|
|
3
|
-
import AndroidThemeGenerator from
|
|
4
|
-
import IosThemeInstructions from
|
|
1
|
+
import Config from './Config';
|
|
2
|
+
import { TOOL_CHOICE, whatWouldYouLikePrompt } from './lib/prompts';
|
|
3
|
+
import AndroidThemeGenerator from './tools/AndroidThemeGenerator';
|
|
4
|
+
import IosThemeInstructions from './tools/IosThemeInstructions';
|
|
5
5
|
|
|
6
|
-
console.log(
|
|
7
|
-
console.log(
|
|
8
|
-
console.log(
|
|
9
|
-
console.log(
|
|
10
|
-
console.log(
|
|
6
|
+
console.log('');
|
|
7
|
+
console.log('============================================');
|
|
8
|
+
console.log('Persona React Native SDK customization tool.');
|
|
9
|
+
console.log('============================================');
|
|
10
|
+
console.log('');
|
|
11
11
|
|
|
12
12
|
const run = async () => {
|
|
13
13
|
// Run this once to print warning messages if it's not configured.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { create as createXml } from "xmlbuilder2";
|
|
2
|
-
import { AndroidThemeObject } from "../Theme";
|
|
3
|
-
import { XMLBuilder } from "xmlbuilder2/lib/interfaces";
|
|
2
|
+
import type { AndroidThemeObject } from "../Theme";
|
|
3
|
+
import type { XMLBuilder } from "xmlbuilder2/lib/interfaces";
|
|
4
4
|
|
|
5
5
|
class AndroidResourcePrinter {
|
|
6
6
|
theme: AndroidThemeObject;
|
|
@@ -73,8 +73,8 @@ class AndroidResourcePrinter {
|
|
|
73
73
|
})
|
|
74
74
|
.up();
|
|
75
75
|
this.root = this.root.ele("style", {
|
|
76
|
-
name: "Persona.
|
|
77
|
-
parent: "Base.Persona.
|
|
76
|
+
name: "Persona.Inquiry2.Theme",
|
|
77
|
+
parent: "Base.Persona.Inquiry2.Theme",
|
|
78
78
|
});
|
|
79
79
|
this.printQueue.forEach((fn) => fn());
|
|
80
80
|
this.root = this.root.up();
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import chalk from
|
|
3
|
-
import path from
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import path from 'path';
|
|
4
4
|
|
|
5
|
-
import Theme, { AndroidThemeObject } from
|
|
6
|
-
import { confirmThemeValues, confirmResourceFiles } from
|
|
7
|
-
import AndroidResourcePrinter from
|
|
8
|
-
import Configuration from
|
|
5
|
+
import Theme, { AndroidThemeObject } from '../Theme';
|
|
6
|
+
import { confirmThemeValues, confirmResourceFiles } from '../lib/prompts';
|
|
7
|
+
import AndroidResourcePrinter from '../lib/AndroidResourcePrinter';
|
|
8
|
+
import Configuration from '../Config';
|
|
9
9
|
|
|
10
10
|
const ANDROID_STYLES_RESOURCE_PATH =
|
|
11
|
-
|
|
11
|
+
'./android/app/src/main/res/values/styles_persona.xml';
|
|
12
12
|
const ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH =
|
|
13
|
-
|
|
13
|
+
'./android/app/src/main/res/drawable/rn_persona_button.xml';
|
|
14
14
|
const ANDROID_BUTTON_COLOR_RESOURCE_PATH =
|
|
15
|
-
|
|
15
|
+
'./android/app/src/main/res/color/rn_persona_button.xml';
|
|
16
16
|
|
|
17
17
|
class ThemeGenerator {
|
|
18
18
|
async run() {
|
|
@@ -22,25 +22,25 @@ class ThemeGenerator {
|
|
|
22
22
|
|
|
23
23
|
if (!themeValuesConfirmed) {
|
|
24
24
|
console.log(
|
|
25
|
-
chalk.yellow(
|
|
25
|
+
chalk.yellow('\nPlease adjust the values in package.json.\n')
|
|
26
26
|
);
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
console.log(
|
|
31
31
|
`\n${chalk.yellow(
|
|
32
|
-
|
|
32
|
+
'Creating an Android Resource files for your project at:'
|
|
33
33
|
)}\n
|
|
34
34
|
- ${ANDROID_STYLES_RESOURCE_PATH}
|
|
35
35
|
- ${ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH}
|
|
36
36
|
- ${ANDROID_BUTTON_COLOR_RESOURCE_PATH}\n`
|
|
37
37
|
);
|
|
38
38
|
console.log(
|
|
39
|
-
|
|
39
|
+
'Building your application with this resource file themes your Persona Inquiry flow.\n'
|
|
40
40
|
);
|
|
41
41
|
|
|
42
42
|
const config = await Configuration.get();
|
|
43
|
-
const theme = config
|
|
43
|
+
const theme = config.androidTheme as AndroidThemeObject;
|
|
44
44
|
|
|
45
45
|
const { style, buttonDrawable, buttonColor } = new AndroidResourcePrinter(
|
|
46
46
|
theme
|
|
@@ -53,7 +53,7 @@ class ThemeGenerator {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// Add a line after confirmation
|
|
56
|
-
console.log(
|
|
56
|
+
console.log('');
|
|
57
57
|
|
|
58
58
|
fs.mkdirSync(path.dirname(ANDROID_STYLES_RESOURCE_PATH), {
|
|
59
59
|
recursive: true,
|
|
@@ -65,7 +65,7 @@ class ThemeGenerator {
|
|
|
65
65
|
|
|
66
66
|
console.log(
|
|
67
67
|
`${chalk.green(
|
|
68
|
-
|
|
68
|
+
'Saved an Android style file at path:'
|
|
69
69
|
)} ${ANDROID_STYLES_RESOURCE_PATH}.`
|
|
70
70
|
);
|
|
71
71
|
|
|
@@ -78,7 +78,7 @@ class ThemeGenerator {
|
|
|
78
78
|
);
|
|
79
79
|
console.log(
|
|
80
80
|
`${chalk.green(
|
|
81
|
-
|
|
81
|
+
'Saved an Android drawable file at path:'
|
|
82
82
|
)} ${ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH}.`
|
|
83
83
|
);
|
|
84
84
|
|
|
@@ -91,7 +91,7 @@ class ThemeGenerator {
|
|
|
91
91
|
);
|
|
92
92
|
console.log(
|
|
93
93
|
`${chalk.green(
|
|
94
|
-
|
|
94
|
+
'Saved an Android color file at path:'
|
|
95
95
|
)} ${ANDROID_BUTTON_COLOR_RESOURCE_PATH}.`
|
|
96
96
|
);
|
|
97
97
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import Theme from
|
|
2
|
-
import { confirmThemeValues } from
|
|
3
|
-
import chalk from
|
|
1
|
+
import Theme from '../Theme';
|
|
2
|
+
import { confirmThemeValues } from '../lib/prompts';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
4
|
|
|
5
5
|
class IosThemeInstructions {
|
|
6
6
|
async run() {
|
|
7
|
-
await Theme.print(
|
|
7
|
+
await Theme.print('ios');
|
|
8
8
|
|
|
9
9
|
const { isConfirmed: themeValuesConfirmed } = await confirmThemeValues();
|
|
10
10
|
|
|
11
11
|
if (!themeValuesConfirmed) {
|
|
12
12
|
console.log(
|
|
13
|
-
chalk.yellow(
|
|
13
|
+
chalk.yellow('\nPlease adjust the values in package.json.\n')
|
|
14
14
|
);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
console.log(
|
|
19
|
-
`\n${chalk.yellow(
|
|
19
|
+
`\n${chalk.yellow('To theme the Persona Inquiry flow for iOS:')}`
|
|
20
20
|
);
|
|
21
21
|
console.log(
|
|
22
|
-
|
|
22
|
+
'Add the theme values to the Persona Inquiry SDK client by using the `.iosTheme` builder function'
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
console.log(`
|
|
@@ -30,7 +30,7 @@ class IosThemeInstructions {
|
|
|
30
30
|
.onCanceled(handleCanceled)
|
|
31
31
|
.onFailed(handleFailed)
|
|
32
32
|
.onError(handleError)
|
|
33
|
-
${chalk.green(
|
|
33
|
+
${chalk.green('+ .iosTheme(persona.iosTheme)')}
|
|
34
34
|
.build()
|
|
35
35
|
.start();
|
|
36
36
|
...
|
package/src/fields.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type RawInquiryField = {
|
|
|
9
9
|
|
|
10
10
|
export namespace InquiryField {
|
|
11
11
|
export class Integer implements InquiryField {
|
|
12
|
-
readonly type: string =
|
|
12
|
+
readonly type: string = 'integer';
|
|
13
13
|
readonly value?: number;
|
|
14
14
|
|
|
15
15
|
constructor(value?: number) {
|
|
@@ -18,7 +18,7 @@ export namespace InquiryField {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export class String implements InquiryField {
|
|
21
|
-
readonly type: string =
|
|
21
|
+
readonly type: string = 'string';
|
|
22
22
|
readonly value?: string;
|
|
23
23
|
|
|
24
24
|
constructor(value?: string) {
|
|
@@ -27,7 +27,7 @@ export namespace InquiryField {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export class Boolean implements InquiryField {
|
|
30
|
-
readonly type: string =
|
|
30
|
+
readonly type: string = 'boolean';
|
|
31
31
|
readonly value?: boolean;
|
|
32
32
|
|
|
33
33
|
constructor(value?: boolean) {
|
|
@@ -48,13 +48,13 @@ export namespace InquiryField {
|
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
50
50
|
switch (type) {
|
|
51
|
-
case
|
|
51
|
+
case 'integer':
|
|
52
52
|
return new InquiryField.Integer(Number.parseInt(value));
|
|
53
|
-
case
|
|
53
|
+
case 'string':
|
|
54
54
|
return new InquiryField.String(value);
|
|
55
|
-
case
|
|
55
|
+
case 'boolean':
|
|
56
56
|
return new InquiryField.Boolean(JSON.parse(value));
|
|
57
|
-
case
|
|
57
|
+
case 'unknown':
|
|
58
58
|
return new InquiryField.Unknown(value);
|
|
59
59
|
default:
|
|
60
60
|
return new InquiryField.Unknown(type);
|