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,213 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.IOS_THEME_CONFIG_KEY = exports.ANDROID_THEME_CONFIG_KEY = void 0;
7
- const cli_table_1 = __importDefault(require("cli-table"));
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const config_1 = __importDefault(require("./config"));
10
- const COLOR_REGEX = /^[a-zA-Z0-9]{6}$/;
11
- var ANDROID_THEME_CONFIG_KEY;
12
- (function (ANDROID_THEME_CONFIG_KEY) {
13
- ANDROID_THEME_CONFIG_KEY["backgroundColor"] = "backgroundColor";
14
- ANDROID_THEME_CONFIG_KEY["primaryColor"] = "primaryColor";
15
- ANDROID_THEME_CONFIG_KEY["darkPrimaryColor"] = "darkPrimaryColor";
16
- ANDROID_THEME_CONFIG_KEY["accentColor"] = "accentColor";
17
- ANDROID_THEME_CONFIG_KEY["titleTextColor"] = "titleTextColor";
18
- ANDROID_THEME_CONFIG_KEY["titleTextFont"] = "titleTextFont";
19
- ANDROID_THEME_CONFIG_KEY["titleTextSize"] = "titleTextSize";
20
- ANDROID_THEME_CONFIG_KEY["bodyTextColor"] = "bodyTextColor";
21
- ANDROID_THEME_CONFIG_KEY["bodyTextFont"] = "bodyTextFont";
22
- ANDROID_THEME_CONFIG_KEY["bodyTextSize"] = "bodyTextSize";
23
- ANDROID_THEME_CONFIG_KEY["footnoteTextColor"] = "footnoteTextColor";
24
- ANDROID_THEME_CONFIG_KEY["footnoteTextFont"] = "footnoteTextFont";
25
- ANDROID_THEME_CONFIG_KEY["footnoteTextSize"] = "footnoteTextSize";
26
- ANDROID_THEME_CONFIG_KEY["cameraInstructionsTextColor"] = "cameraInstructionsTextColor";
27
- ANDROID_THEME_CONFIG_KEY["cameraInstructionsTextFont"] = "cameraInstructionsTextFont";
28
- ANDROID_THEME_CONFIG_KEY["cameraInstructionsTextSize"] = "cameraInstructionsTextSize";
29
- ANDROID_THEME_CONFIG_KEY["cameraHintTextColor"] = "cameraHintTextColor";
30
- ANDROID_THEME_CONFIG_KEY["cameraHintTextFont"] = "cameraHintTextFont";
31
- ANDROID_THEME_CONFIG_KEY["cameraHintTextSize"] = "cameraHintTextSize";
32
- ANDROID_THEME_CONFIG_KEY["cameraGuideHintTextColor"] = "cameraGuideHintTextColor";
33
- ANDROID_THEME_CONFIG_KEY["cameraGuideHintTextFont"] = "cameraGuideHintTextFont";
34
- ANDROID_THEME_CONFIG_KEY["cameraGuideHintTextSize"] = "cameraGuideHintTextSize";
35
- // formLabelTextColor = "formLabelTextColor",
36
- // formLabelTextFont = "formLabelTextFont",
37
- ANDROID_THEME_CONFIG_KEY["textFieldTextColor"] = "textFieldTextColor";
38
- ANDROID_THEME_CONFIG_KEY["textFieldTextFont"] = "textFieldTextFont";
39
- ANDROID_THEME_CONFIG_KEY["pickerTextColor"] = "pickerTextColor";
40
- ANDROID_THEME_CONFIG_KEY["pickerTextFont"] = "pickerTextFont";
41
- ANDROID_THEME_CONFIG_KEY["buttonBackgroundColor"] = "buttonBackgroundColor";
42
- ANDROID_THEME_CONFIG_KEY["buttonDisabledBackgroundColor"] = "buttonDisabledBackgroundColor";
43
- ANDROID_THEME_CONFIG_KEY["buttonTouchedBackgroundColor"] = "buttonTouchedBackgroundColor";
44
- ANDROID_THEME_CONFIG_KEY["buttonTextColor"] = "buttonTextColor";
45
- ANDROID_THEME_CONFIG_KEY["buttonDisabledTextColor"] = "buttonDisabledTextColor";
46
- // buttonTextAlignment = "buttonTextAlignment",
47
- ANDROID_THEME_CONFIG_KEY["buttonCornerRadius"] = "buttonCornerRadius";
48
- ANDROID_THEME_CONFIG_KEY["buttonFont"] = "buttonFont";
49
- ANDROID_THEME_CONFIG_KEY["buttonTextSize"] = "buttonTextSize";
50
- ANDROID_THEME_CONFIG_KEY["progressColor"] = "progressColor";
51
- ANDROID_THEME_CONFIG_KEY["successAsset"] = "successAsset";
52
- ANDROID_THEME_CONFIG_KEY["failAsset"] = "failAsset";
53
- ANDROID_THEME_CONFIG_KEY["loadingAnimationAsset"] = "loadingAnimationAsset";
54
- ANDROID_THEME_CONFIG_KEY["loadingAnimationWidthPercent"] = "loadingAnimationWidthPercent";
55
- ANDROID_THEME_CONFIG_KEY["selfieAnimationAsset"] = "selfieAnimationAsset";
56
- ANDROID_THEME_CONFIG_KEY["selfieAnimationWidthPercent"] = "selfieAnimationWidthPercent";
57
- })(ANDROID_THEME_CONFIG_KEY = exports.ANDROID_THEME_CONFIG_KEY || (exports.ANDROID_THEME_CONFIG_KEY = {}));
58
- var IOS_THEME_CONFIG_KEY;
59
- (function (IOS_THEME_CONFIG_KEY) {
60
- IOS_THEME_CONFIG_KEY["backgroundColor"] = "backgroundColor";
61
- IOS_THEME_CONFIG_KEY["primaryColor"] = "primaryColor";
62
- IOS_THEME_CONFIG_KEY["darkPrimaryColor"] = "darkPrimaryColor";
63
- IOS_THEME_CONFIG_KEY["accentColor"] = "accentColor";
64
- IOS_THEME_CONFIG_KEY["progressColor"] = "progressColor";
65
- IOS_THEME_CONFIG_KEY["overlayBackgroundColor"] = "overlayBackgroundColor";
66
- IOS_THEME_CONFIG_KEY["titleTextColor"] = "titleTextColor";
67
- IOS_THEME_CONFIG_KEY["titleTextFont"] = "titleTextFont";
68
- IOS_THEME_CONFIG_KEY["titleTextSize"] = "titleTextSize";
69
- IOS_THEME_CONFIG_KEY["titleTextAlignment"] = "titleTextAlignment";
70
- IOS_THEME_CONFIG_KEY["bodyTextColor"] = "bodyTextColor";
71
- IOS_THEME_CONFIG_KEY["bodyTextFont"] = "bodyTextFont";
72
- IOS_THEME_CONFIG_KEY["bodyTextSize"] = "bodyTextSize";
73
- IOS_THEME_CONFIG_KEY["bodyTextAlignment"] = "bodyTextAlignment";
74
- IOS_THEME_CONFIG_KEY["footnoteTextColor"] = "footnoteTextColor";
75
- IOS_THEME_CONFIG_KEY["footnoteTextFont"] = "footnoteTextFont";
76
- IOS_THEME_CONFIG_KEY["footnoteTextSize"] = "footnoteTextSize";
77
- IOS_THEME_CONFIG_KEY["formLabelTextColor"] = "formLabelTextColor";
78
- IOS_THEME_CONFIG_KEY["formLabelTextFont"] = "formLabelTextFont";
79
- IOS_THEME_CONFIG_KEY["textFieldTextColor"] = "textFieldTextColor";
80
- IOS_THEME_CONFIG_KEY["textFieldBackgroundColor"] = "textFieldBackgroundColor";
81
- IOS_THEME_CONFIG_KEY["textFieldBorderColor"] = "textFieldBorderColor";
82
- IOS_THEME_CONFIG_KEY["pickerTextColor"] = "pickerTextColor";
83
- IOS_THEME_CONFIG_KEY["pickerTextFont"] = "pickerTextFont";
84
- IOS_THEME_CONFIG_KEY["cameraInstructionsTextColor"] = "cameraInstructionsTextColor";
85
- IOS_THEME_CONFIG_KEY["cameraInstructionsTextFont"] = "cameraInstructionsTextFont";
86
- IOS_THEME_CONFIG_KEY["cameraInstructionsTextSize"] = "cameraInstructionsTextFont";
87
- IOS_THEME_CONFIG_KEY["cameraHintTextColor"] = "cameraHintTextColor";
88
- IOS_THEME_CONFIG_KEY["cameraHintTextFont"] = "cameraHintTextFont";
89
- IOS_THEME_CONFIG_KEY["cameraHintTextSize"] = "cameraHintTextSize";
90
- IOS_THEME_CONFIG_KEY["cameraGuideHintTextColor"] = "cameraGuideHintTextColor";
91
- IOS_THEME_CONFIG_KEY["cameraGuideHintTextFont"] = "cameraGuideHintTextFont";
92
- IOS_THEME_CONFIG_KEY["cameraGuideHintTextSize"] = "cameraGuideHintTextSize";
93
- IOS_THEME_CONFIG_KEY["buttonBackgroundColor"] = "buttonBackgroundColor";
94
- IOS_THEME_CONFIG_KEY["buttonDisabledBackgroundColor"] = "buttonDisabledBackgroundColor";
95
- IOS_THEME_CONFIG_KEY["buttonTouchedBackgroundColor"] = "buttonTouchedBackgroundColor";
96
- IOS_THEME_CONFIG_KEY["buttonImageTintColor"] = "buttonImageTintColor";
97
- IOS_THEME_CONFIG_KEY["buttonImageHidden"] = "buttonImageHidden";
98
- IOS_THEME_CONFIG_KEY["buttonCornerRadius"] = "buttonCornerRadius";
99
- IOS_THEME_CONFIG_KEY["buttonTextAlignment"] = "buttonTextAlignment";
100
- IOS_THEME_CONFIG_KEY["buttonDisabledTextColor"] = "buttonDisabledTextColor";
101
- IOS_THEME_CONFIG_KEY["buttonTextColor"] = "buttonTextColor";
102
- IOS_THEME_CONFIG_KEY["buttonFont"] = "buttonFont";
103
- IOS_THEME_CONFIG_KEY["buttonTextSize"] = "buttonTextSize";
104
- IOS_THEME_CONFIG_KEY["selectedCellBackgroundColor"] = "selectedCellBackgroundColor";
105
- IOS_THEME_CONFIG_KEY["closeButtonTintColor"] = "closeButtonTintColor";
106
- IOS_THEME_CONFIG_KEY["cancelButtonBackgroundColor"] = "cancelButtonBackgroundColor";
107
- IOS_THEME_CONFIG_KEY["cameraButtonBackgroundColor"] = "cameraButtonBackgroundColor";
108
- IOS_THEME_CONFIG_KEY["cameraGuideCornersColor"] = "cameraGuideCornersColor";
109
- IOS_THEME_CONFIG_KEY["successAssetName"] = "successAssetName";
110
- IOS_THEME_CONFIG_KEY["successAssetWidth"] = "successAssetWidth";
111
- IOS_THEME_CONFIG_KEY["successAssetHeight"] = "successAssetHeight";
112
- IOS_THEME_CONFIG_KEY["verificationFailAssetName"] = "verificationFailAssetName";
113
- IOS_THEME_CONFIG_KEY["verificationFailAssetWidth"] = "verificationFailAssetWidth";
114
- IOS_THEME_CONFIG_KEY["verificationFailAssetHeight"] = "verificationFailAssetHeight";
115
- IOS_THEME_CONFIG_KEY["failAssetName"] = "failAssetName";
116
- IOS_THEME_CONFIG_KEY["failAssetWidth"] = "failAssetWidth";
117
- IOS_THEME_CONFIG_KEY["failAssetHeight"] = "failAssetHeight";
118
- IOS_THEME_CONFIG_KEY["loadingAnimationAssetName"] = "loadingAnimationAssetName";
119
- IOS_THEME_CONFIG_KEY["loadingAnimationAssetWidth"] = "loadingAnimationAssetWidth";
120
- IOS_THEME_CONFIG_KEY["loadingAnimationAssetHeight"] = "loadingAnimationAssetHeight";
121
- IOS_THEME_CONFIG_KEY["processingAnimationAssetName"] = "processingAnimationAssetName";
122
- IOS_THEME_CONFIG_KEY["processingAnimationAssetWidth"] = "processingAnimationAssetWidth";
123
- IOS_THEME_CONFIG_KEY["processingAnimationAssetHeight"] = "processingAnimationAssetHeight";
124
- IOS_THEME_CONFIG_KEY["selfieAnimationAssetName"] = "selfieAnimationAssetName";
125
- IOS_THEME_CONFIG_KEY["selfieAnimationAssetWidth"] = "selfieAnimationAssetWidth";
126
- IOS_THEME_CONFIG_KEY["selfieAnimationAssetHeight"] = "selfieAnimationAssetHeight";
127
- })(IOS_THEME_CONFIG_KEY = exports.IOS_THEME_CONFIG_KEY || (exports.IOS_THEME_CONFIG_KEY = {}));
128
- class Theme {
129
- async print(platform = "android") {
130
- const config = await config_1.default.get();
131
- const themeConfig = platform === "android" ? config["androidTheme"] : config["iosTheme"];
132
- let usesCustomFontAndroid = false;
133
- let usesCustomFontIos = false;
134
- const head = platform === "android"
135
- ? ["Style Item", "Value", "Note"]
136
- : ["Style Item", "Value", "Note"];
137
- const table = new cli_table_1.default({
138
- head,
139
- // prettier-ignore
140
- chars: { 'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' }
141
- });
142
- console.log("Specified theme values:");
143
- const keyEnum = platform === "android" ? ANDROID_THEME_CONFIG_KEY : IOS_THEME_CONFIG_KEY;
144
- for (const key in keyEnum) {
145
- let override = themeConfig[key];
146
- let colorOverride = key.includes("Color") || key.includes("color");
147
- if (override) {
148
- if (colorOverride) {
149
- override = normalizeColor(override, key);
150
- }
151
- else {
152
- override = override.toString();
153
- }
154
- }
155
- if (key.includes("Font")) {
156
- if (platform == "android") {
157
- usesCustomFontAndroid = true;
158
- }
159
- else {
160
- usesCustomFontIos = true;
161
- }
162
- }
163
- let row;
164
- row = [
165
- key,
166
- override
167
- ? valueColor(colorOverride, override)
168
- : chalk_1.default.yellow("unspecified"),
169
- key.includes("Font")
170
- ? chalk_1.default.cyan("Fonts that are not built-in need to be installed.")
171
- : ""
172
- ];
173
- table.push(row);
174
- }
175
- console.log(table.toString());
176
- if (usesCustomFontAndroid) {
177
- console.log(chalk_1.default.yellow(" NOTE") +
178
- ": 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");
179
- }
180
- if (usesCustomFontIos) {
181
- console.log(chalk_1.default.yellow(" NOTE") +
182
- ": 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");
183
- }
184
- // Add newline for spacing
185
- console.log("");
186
- }
187
- }
188
- // set default print color for non-color overrides
189
- function valueColor(isColorOverride, override) {
190
- return isColorOverride ? chalk_1.default.hex(override)(override) : chalk_1.default.magentaBright(override);
191
- }
192
- function normalizeColor(colorHex, themeKey) {
193
- let hex = colorHex;
194
- if (colorHex[0] === "#") {
195
- hex = colorHex.slice(1);
196
- }
197
- if (!COLOR_REGEX.test(hex)) {
198
- if (themeKey) {
199
- console.error(`Received a color value of ${chalk_1.default.yellow(colorHex)} for ${chalk_1.default.red(themeKey)}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk_1.default
200
- .bgHex("#FFFFFF")
201
- .hex("#7E66B7")("#290087")}`);
202
- }
203
- else {
204
- console.error(`Received a color value of ${chalk_1.default.yellow(colorHex)}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk_1.default
205
- .bgHex("#FFFFFF")
206
- .hex("#7E66B7")("#290087")}`);
207
- }
208
- console.log("");
209
- process.exit(1);
210
- }
211
- return colorHex;
212
- }
213
- exports.default = new Theme();
@@ -1,260 +0,0 @@
1
- import Table from "cli-table";
2
- import chalk from "chalk";
3
-
4
- import Config from "./config";
5
-
6
- const COLOR_REGEX = /^[a-zA-Z0-9]{6}$/;
7
-
8
- export enum ANDROID_THEME_CONFIG_KEY {
9
- backgroundColor = "backgroundColor",
10
- primaryColor = "primaryColor",
11
- darkPrimaryColor = "darkPrimaryColor",
12
- accentColor = "accentColor",
13
-
14
- titleTextColor = "titleTextColor",
15
- titleTextFont = "titleTextFont",
16
- titleTextSize = "titleTextSize",
17
-
18
- bodyTextColor = "bodyTextColor",
19
- bodyTextFont = "bodyTextFont",
20
- bodyTextSize = "bodyTextSize",
21
-
22
- footnoteTextColor = "footnoteTextColor",
23
- footnoteTextFont = "footnoteTextFont",
24
- footnoteTextSize = 'footnoteTextSize',
25
-
26
- cameraInstructionsTextColor = "cameraInstructionsTextColor",
27
- cameraInstructionsTextFont = "cameraInstructionsTextFont",
28
- cameraInstructionsTextSize = "cameraInstructionsTextSize",
29
-
30
- cameraHintTextColor = "cameraHintTextColor",
31
- cameraHintTextFont = "cameraHintTextFont",
32
- cameraHintTextSize = "cameraHintTextSize",
33
-
34
- cameraGuideHintTextColor = "cameraGuideHintTextColor",
35
- cameraGuideHintTextFont = "cameraGuideHintTextFont",
36
- cameraGuideHintTextSize = "cameraGuideHintTextSize",
37
-
38
- // formLabelTextColor = "formLabelTextColor",
39
- // formLabelTextFont = "formLabelTextFont",
40
-
41
- textFieldTextColor = "textFieldTextColor",
42
- textFieldTextFont = "textFieldTextFont",
43
-
44
- pickerTextColor = "pickerTextColor",
45
- pickerTextFont = "pickerTextFont",
46
-
47
- buttonBackgroundColor = "buttonBackgroundColor",
48
- buttonDisabledBackgroundColor = "buttonDisabledBackgroundColor",
49
- buttonTouchedBackgroundColor = "buttonTouchedBackgroundColor",
50
- buttonTextColor = "buttonTextColor",
51
- buttonDisabledTextColor = "buttonDisabledTextColor",
52
- // buttonTextAlignment = "buttonTextAlignment",
53
- buttonCornerRadius = "buttonCornerRadius",
54
- buttonFont = "buttonFont",
55
- buttonTextSize = "buttonTextSize",
56
- progressColor = "progressColor",
57
- successAsset = "successAsset",
58
- failAsset = "failAsset",
59
- loadingAnimationAsset = "loadingAnimationAsset",
60
- loadingAnimationWidthPercent = "loadingAnimationWidthPercent",
61
- selfieAnimationAsset = "selfieAnimationAsset",
62
- selfieAnimationWidthPercent = "selfieAnimationWidthPercent"
63
- }
64
-
65
- export enum IOS_THEME_CONFIG_KEY {
66
- backgroundColor = "backgroundColor",
67
- primaryColor = "primaryColor",
68
- darkPrimaryColor = "darkPrimaryColor",
69
- accentColor = "accentColor",
70
- progressColor = "progressColor",
71
- overlayBackgroundColor = "overlayBackgroundColor",
72
- titleTextColor = "titleTextColor",
73
- titleTextFont = "titleTextFont",
74
- titleTextSize = "titleTextSize",
75
- titleTextAlignment = "titleTextAlignment",
76
- bodyTextColor = "bodyTextColor",
77
- bodyTextFont = "bodyTextFont",
78
- bodyTextSize = "bodyTextSize",
79
- bodyTextAlignment = "bodyTextAlignment",
80
- footnoteTextColor = "footnoteTextColor",
81
- footnoteTextFont = "footnoteTextFont",
82
- footnoteTextSize = "footnoteTextSize",
83
- formLabelTextColor = "formLabelTextColor",
84
- formLabelTextFont = "formLabelTextFont",
85
- textFieldTextColor = "textFieldTextColor",
86
- textFieldBackgroundColor = "textFieldBackgroundColor",
87
- textFieldBorderColor = "textFieldBorderColor",
88
- pickerTextColor = "pickerTextColor",
89
- pickerTextFont = "pickerTextFont",
90
- cameraInstructionsTextColor = "cameraInstructionsTextColor",
91
- cameraInstructionsTextFont = "cameraInstructionsTextFont",
92
- cameraInstructionsTextSize = "cameraInstructionsTextFont",
93
- cameraHintTextColor = "cameraHintTextColor",
94
- cameraHintTextFont = "cameraHintTextFont",
95
- cameraHintTextSize = "cameraHintTextSize",
96
- cameraGuideHintTextColor = "cameraGuideHintTextColor",
97
- cameraGuideHintTextFont = "cameraGuideHintTextFont",
98
- cameraGuideHintTextSize = "cameraGuideHintTextSize",
99
- buttonBackgroundColor = "buttonBackgroundColor",
100
- buttonDisabledBackgroundColor = "buttonDisabledBackgroundColor",
101
- buttonTouchedBackgroundColor = "buttonTouchedBackgroundColor",
102
- buttonImageTintColor = "buttonImageTintColor",
103
- buttonImageHidden = "buttonImageHidden",
104
- buttonCornerRadius = "buttonCornerRadius",
105
- buttonTextAlignment = "buttonTextAlignment",
106
- buttonDisabledTextColor = "buttonDisabledTextColor",
107
- buttonTextColor = "buttonTextColor",
108
- buttonFont = "buttonFont",
109
- buttonTextSize = "buttonTextSize",
110
- selectedCellBackgroundColor = "selectedCellBackgroundColor",
111
- closeButtonTintColor = "closeButtonTintColor",
112
- cancelButtonBackgroundColor = "cancelButtonBackgroundColor",
113
- cameraButtonBackgroundColor = "cameraButtonBackgroundColor",
114
- cameraGuideCornersColor = "cameraGuideCornersColor",
115
- successAssetName = "successAssetName",
116
- successAssetWidth = "successAssetWidth",
117
- successAssetHeight = "successAssetHeight",
118
- verificationFailAssetName = "verificationFailAssetName",
119
- verificationFailAssetWidth = "verificationFailAssetWidth",
120
- verificationFailAssetHeight = "verificationFailAssetHeight",
121
- failAssetName = "failAssetName",
122
- failAssetWidth = "failAssetWidth",
123
- failAssetHeight = "failAssetHeight",
124
- loadingAnimationAssetName = "loadingAnimationAssetName",
125
- loadingAnimationAssetWidth = "loadingAnimationAssetWidth",
126
- loadingAnimationAssetHeight = "loadingAnimationAssetHeight",
127
- processingAnimationAssetName = "processingAnimationAssetName",
128
- processingAnimationAssetWidth = "processingAnimationAssetWidth",
129
- processingAnimationAssetHeight = "processingAnimationAssetHeight",
130
- selfieAnimationAssetName = "selfieAnimationAssetName",
131
- selfieAnimationAssetWidth = "selfieAnimationAssetWidth",
132
- selfieAnimationAssetHeight = "selfieAnimationAssetHeight",
133
- }
134
-
135
- export type AndroidThemeObject = {
136
- [key in ANDROID_THEME_CONFIG_KEY]: string | null | undefined;
137
- };
138
-
139
- export type IosThemeObject = {
140
- [key in IOS_THEME_CONFIG_KEY]: string | null | undefined;
141
- };
142
-
143
- export type ThemeObject = AndroidThemeObject | IosThemeObject;
144
-
145
- class Theme {
146
- async print(platform: string = "android") {
147
- const config = await Config.get();
148
- const themeConfig =
149
- platform === "android" ? config["androidTheme"] : config["iosTheme"];
150
- let usesCustomFontAndroid = false;
151
- let usesCustomFontIos = false;
152
-
153
- const head =
154
- platform === "android"
155
- ? ["Style Item", "Value", "Note"]
156
- : ["Style Item", "Value", "Note"];
157
-
158
- const table = new Table({
159
- head,
160
- // prettier-ignore
161
- chars: { 'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' }
162
- });
163
-
164
- console.log("Specified theme values:");
165
- const keyEnum =
166
- platform === "android" ? ANDROID_THEME_CONFIG_KEY : IOS_THEME_CONFIG_KEY;
167
- for (const key in keyEnum) {
168
- let override =
169
- themeConfig[key as ANDROID_THEME_CONFIG_KEY | IOS_THEME_CONFIG_KEY];
170
- let colorOverride = key.includes("Color") || key.includes("color");
171
-
172
- if (override) {
173
- if (colorOverride) {
174
- override = normalizeColor(override, key);
175
- } else {
176
- override = override.toString();
177
- }
178
- }
179
-
180
- if (key.includes("Font")) {
181
- if (platform == "android") {
182
- usesCustomFontAndroid = true;
183
- } else {
184
- usesCustomFontIos = true;
185
- }
186
- }
187
-
188
- let row;
189
-
190
- row = [
191
- key,
192
- override
193
- ? valueColor(colorOverride, override)
194
- : chalk.yellow("unspecified"),
195
- key.includes("Font")
196
- ? chalk.cyan("Fonts that are not built-in need to be installed.")
197
- : ""
198
- ];
199
-
200
- table.push(row);
201
- }
202
-
203
- console.log(table.toString());
204
-
205
- if (usesCustomFontAndroid) {
206
- console.log(
207
- chalk.yellow(" NOTE") +
208
- ": 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"
209
- );
210
- }
211
-
212
- if (usesCustomFontIos) {
213
- console.log(
214
- chalk.yellow(" NOTE") +
215
- ": 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"
216
- );
217
- }
218
-
219
- // Add newline for spacing
220
- console.log("");
221
- }
222
- }
223
-
224
- // set default print color for non-color overrides
225
- function valueColor(isColorOverride, override) {
226
- return isColorOverride ? chalk.hex(override)(override) : chalk.magentaBright(override);
227
- }
228
-
229
- function normalizeColor(colorHex: string, themeKey: string) {
230
- let hex = colorHex;
231
- if (colorHex[0] === "#") {
232
- hex = colorHex.slice(1);
233
- }
234
-
235
- if (!COLOR_REGEX.test(hex)) {
236
- if (themeKey) {
237
- console.error(
238
- `Received a color value of ${chalk.yellow(colorHex)} for ${chalk.red(
239
- themeKey
240
- )}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk
241
- .bgHex("#FFFFFF")
242
- .hex("#7E66B7")("#290087")}`
243
- );
244
- } else {
245
- console.error(
246
- `Received a color value of ${chalk.yellow(
247
- colorHex
248
- )}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk
249
- .bgHex("#FFFFFF")
250
- .hex("#7E66B7")("#290087")}`
251
- );
252
- }
253
- console.log("");
254
- process.exit(1);
255
- }
256
-
257
- return colorHex;
258
- }
259
-
260
- export default new Theme();
@@ -1,72 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const cosmiconfig_1 = require("cosmiconfig");
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const Theme_1 = require("./Theme");
9
- class Configuration {
10
- async loadConfig() {
11
- if (this.config)
12
- return this.config;
13
- try {
14
- const explorer = cosmiconfig_1.cosmiconfig("persona", { packageProp: "persona" });
15
- const result = await explorer.search();
16
- if (result == null) {
17
- return null;
18
- }
19
- this.config = result.config;
20
- return this.config;
21
- }
22
- catch (e) {
23
- console.error(e);
24
- process.exit(1);
25
- }
26
- }
27
- async get() {
28
- let config = await this.loadConfig();
29
- const androidThemeLines = [];
30
- for (const key in Theme_1.ANDROID_THEME_CONFIG_KEY) {
31
- androidThemeLines.push(` "${key}": null`);
32
- }
33
- const iosThemeLines = [];
34
- for (const key in Theme_1.IOS_THEME_CONFIG_KEY) {
35
- iosThemeLines.push(` "${key}": null`);
36
- }
37
- if (config == null) {
38
- console.log(`
39
- Missing configuration.
40
-
41
- In order to use this tool, it must be configured using a ${chalk_1.default.yellow("persona")} object within
42
- your package.json.
43
-
44
- To get started, paste the following configuration into your package.json
45
-
46
- {
47
- ...
48
-
49
- "persona": {
50
- "androidTheme": {
51
- ` +
52
- androidThemeLines.join(",\n") +
53
- `
54
- },
55
- "iosTheme": {
56
- ` +
57
- iosThemeLines.join(",\n") +
58
- `
59
- }
60
- }
61
-
62
- ...
63
- }
64
-
65
- and re-run this tool :).
66
- `);
67
- process.exit(1);
68
- }
69
- return config;
70
- }
71
- }
72
- exports.default = new Configuration();
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const Config_1 = __importDefault(require("./Config"));
7
- const prompts_1 = require("./lib/prompts");
8
- const AndroidThemeGenerator_1 = __importDefault(require("./tools/AndroidThemeGenerator"));
9
- const IosThemeInstructions_1 = __importDefault(require("./tools/IosThemeInstructions"));
10
- console.log("");
11
- console.log("============================================");
12
- console.log("Persona React Native SDK customization tool.");
13
- console.log("============================================");
14
- console.log("");
15
- const run = async () => {
16
- // Run this once to print warning messages if it's not configured.
17
- await Config_1.default.get();
18
- const { choice } = await prompts_1.whatWouldYouLikePrompt();
19
- switch (choice) {
20
- case prompts_1.TOOL_CHOICE.AndroidTheme:
21
- await AndroidThemeGenerator_1.default.run();
22
- break;
23
- case prompts_1.TOOL_CHOICE.iosTheme:
24
- await IosThemeInstructions_1.default.run();
25
- break;
26
- default:
27
- return;
28
- }
29
- };
30
- run();
@@ -1,30 +0,0 @@
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
-
6
- console.log("");
7
- console.log("============================================");
8
- console.log("Persona React Native SDK customization tool.");
9
- console.log("============================================");
10
- console.log("");
11
-
12
- const run = async () => {
13
- // Run this once to print warning messages if it's not configured.
14
- await Config.get();
15
-
16
- const { choice } = await whatWouldYouLikePrompt();
17
-
18
- switch (choice) {
19
- case TOOL_CHOICE.AndroidTheme:
20
- await AndroidThemeGenerator.run();
21
- break;
22
- case TOOL_CHOICE.iosTheme:
23
- await IosThemeInstructions.run();
24
- break;
25
- default:
26
- return;
27
- }
28
- };
29
-
30
- run();