react-native-persona 2.0.1 → 2.1.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.
- package/CHANGELOG.md +28 -2
- package/RNPersonaInquiry.podspec +1 -1
- package/android/build.gradle +1 -1
- package/generatedTypes/persona-tools/Theme.d.ts +95 -0
- package/generatedTypes/persona-tools/config.d.ts +15 -0
- package/generatedTypes/persona-tools/index.d.ts +1 -0
- package/generatedTypes/persona-tools/lib/AndroidResourcePrinter.d.ts +35 -0
- package/generatedTypes/persona-tools/lib/AndroidResourcePrinter.spec.d.ts +1 -0
- package/generatedTypes/persona-tools/lib/prompts.d.ts +8 -0
- package/generatedTypes/persona-tools/tools/AndroidThemeGenerator.d.ts +5 -0
- package/generatedTypes/persona-tools/tools/IosThemeInstructions.d.ts +5 -0
- package/generatedTypes/src/fields.d.ts +42 -0
- package/generatedTypes/src/fields.spec.d.ts +1 -0
- package/generatedTypes/src/index.d.ts +107 -0
- package/generatedTypes/src/util.d.ts +3 -0
- package/generatedTypes/src/util.spec.d.ts +1 -0
- package/package.json +5 -3
- package/persona-tools/Theme.js +186 -0
- package/persona-tools/config.js +72 -0
- package/persona-tools/index.js +30 -0
- package/persona-tools/index.ts +1 -1
- package/persona-tools/lib/AndroidResourcePrinter.js +573 -0
- package/persona-tools/lib/AndroidResourcePrinter.spec.js +914 -0
- package/persona-tools/lib/prompts.js +39 -0
- package/persona-tools/tools/AndroidThemeGenerator.js +55 -0
- package/persona-tools/tools/IosThemeInstructions.js +34 -0
- package/src/fields.js +88 -0
- package/src/fields.spec.js +18 -0
- package/src/index.js +271 -0
- package/src/util.js +29 -0
- package/src/util.spec.js +17 -0
|
@@ -0,0 +1,72 @@
|
|
|
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();
|
|
@@ -0,0 +1,30 @@
|
|
|
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();
|
package/persona-tools/index.ts
CHANGED
|
@@ -0,0 +1,573 @@
|
|
|
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.buttonColor = xmlbuilder2_1.create({ version: "1.0" }).ele("selector", {
|
|
15
|
+
"xmlns:android": "http://schemas.android.com/apk/res/android",
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
process() {
|
|
19
|
+
if (!this.hasTheme()) {
|
|
20
|
+
this.root = this.root.up();
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this.print();
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
style: this.root,
|
|
27
|
+
buttonDrawable: this.buttonDrawable,
|
|
28
|
+
buttonColor: this.buttonColor,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
print() {
|
|
32
|
+
this.primaryColor();
|
|
33
|
+
this.accentColor();
|
|
34
|
+
this.darkPrimaryColor();
|
|
35
|
+
this.backgroundColor();
|
|
36
|
+
this.titleText();
|
|
37
|
+
this.bodyText();
|
|
38
|
+
this.footnoteText();
|
|
39
|
+
// this.formLabelText();
|
|
40
|
+
this.textField();
|
|
41
|
+
this.pickerText();
|
|
42
|
+
this.button();
|
|
43
|
+
this.progressColor();
|
|
44
|
+
this.successAsset();
|
|
45
|
+
this.failAsset();
|
|
46
|
+
this.loadingAnimationAsset();
|
|
47
|
+
this.selfieAnimationAsset();
|
|
48
|
+
this.preprintQueue.forEach((fn) => fn());
|
|
49
|
+
// Precreate some style namespaces
|
|
50
|
+
this.root = this.root
|
|
51
|
+
.ele("style", {
|
|
52
|
+
name: "RN",
|
|
53
|
+
})
|
|
54
|
+
.up();
|
|
55
|
+
this.root = this.root
|
|
56
|
+
.ele("style", {
|
|
57
|
+
name: "RN.Persona",
|
|
58
|
+
})
|
|
59
|
+
.up();
|
|
60
|
+
this.root = this.root
|
|
61
|
+
.ele("style", {
|
|
62
|
+
name: "RN.Persona.Text",
|
|
63
|
+
})
|
|
64
|
+
.up();
|
|
65
|
+
this.root = this.root.ele("style", {
|
|
66
|
+
name: "Persona.Inquiry.Theme",
|
|
67
|
+
parent: "Base.Persona.Inquiry.Theme.Light",
|
|
68
|
+
});
|
|
69
|
+
this.printQueue.forEach((fn) => fn());
|
|
70
|
+
this.root = this.root.up();
|
|
71
|
+
this.postPrintQueue.forEach((fn) => fn());
|
|
72
|
+
}
|
|
73
|
+
hasTheme() {
|
|
74
|
+
return (Object.keys(this.theme).length > 0 &&
|
|
75
|
+
Object.values(this.theme).filter(Boolean).length > 0);
|
|
76
|
+
}
|
|
77
|
+
primaryColor() {
|
|
78
|
+
if (!this.theme.primaryColor)
|
|
79
|
+
return;
|
|
80
|
+
this.printQueue.push(() => {
|
|
81
|
+
this.root = this.root
|
|
82
|
+
.ele("item", { name: "colorPrimary" })
|
|
83
|
+
.txt(this.theme.primaryColor)
|
|
84
|
+
.up()
|
|
85
|
+
.txt(" ");
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
accentColor() {
|
|
89
|
+
if (!this.theme.accentColor)
|
|
90
|
+
return;
|
|
91
|
+
this.printQueue.push(() => {
|
|
92
|
+
this.root = this.root
|
|
93
|
+
.ele("item", { name: "colorAccent" })
|
|
94
|
+
.txt(this.theme.accentColor)
|
|
95
|
+
.up()
|
|
96
|
+
.txt(" ");
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
darkPrimaryColor() {
|
|
100
|
+
if (!this.theme.darkPrimaryColor)
|
|
101
|
+
return;
|
|
102
|
+
this.printQueue.push(() => {
|
|
103
|
+
this.root = this.root
|
|
104
|
+
.ele("item", { name: "colorPrimaryDark" })
|
|
105
|
+
.txt(this.theme.darkPrimaryColor)
|
|
106
|
+
.up()
|
|
107
|
+
.txt(" ");
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
backgroundColor() {
|
|
111
|
+
if (!this.theme.backgroundColor)
|
|
112
|
+
return;
|
|
113
|
+
this.preprintQueue.push(() => {
|
|
114
|
+
this.root = this.root
|
|
115
|
+
.ele("color", { name: "customPersonaBackgroundColor" })
|
|
116
|
+
.txt(this.theme.backgroundColor)
|
|
117
|
+
.up()
|
|
118
|
+
.txt(" ");
|
|
119
|
+
});
|
|
120
|
+
this.printQueue.push(() => {
|
|
121
|
+
this.root = this.root
|
|
122
|
+
.ele("item", { name: "android:colorBackground" })
|
|
123
|
+
.txt("@color/customPersonaBackgroundColor")
|
|
124
|
+
.up()
|
|
125
|
+
.txt(" ");
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
titleText() {
|
|
129
|
+
if (this.theme.titleTextColor || this.theme.titleTextFont) {
|
|
130
|
+
this.printQueue.push(() => {
|
|
131
|
+
this.root = this.root
|
|
132
|
+
.ele("item", { name: "personaTitleTextAppearance" })
|
|
133
|
+
.txt("@style/RN.Persona.Text.Title")
|
|
134
|
+
.up();
|
|
135
|
+
});
|
|
136
|
+
// Create a text appearance
|
|
137
|
+
this.postPrintQueue.push(() => {
|
|
138
|
+
this.root = this.root.ele("style", {
|
|
139
|
+
name: "RN.Persona.Text.Title",
|
|
140
|
+
parent: "Persona.Text.Body",
|
|
141
|
+
});
|
|
142
|
+
if (this.theme.titleTextColor) {
|
|
143
|
+
this.root = this.root
|
|
144
|
+
.ele("item", { name: "android:textColor" })
|
|
145
|
+
.txt(this.theme.titleTextColor)
|
|
146
|
+
.up();
|
|
147
|
+
}
|
|
148
|
+
if (this.theme.titleTextFont) {
|
|
149
|
+
// TODO: Add notice about how to add a custom font that can be
|
|
150
|
+
// referenced here on Android
|
|
151
|
+
this.root = this.root
|
|
152
|
+
.ele("item", { name: "android:fontFamily" })
|
|
153
|
+
.txt(this.theme.titleTextFont)
|
|
154
|
+
.up();
|
|
155
|
+
}
|
|
156
|
+
// Default values taken from `Persona.Text.Title`
|
|
157
|
+
// in shared/src/main/res/values/styles.xml
|
|
158
|
+
this.root = this.root
|
|
159
|
+
.ele("item", { name: "android:textSize" })
|
|
160
|
+
.txt("26sp")
|
|
161
|
+
.up()
|
|
162
|
+
.ele("item", { name: "android:textStyle" })
|
|
163
|
+
.txt("bold")
|
|
164
|
+
.up();
|
|
165
|
+
this.root = this.root.up();
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
this.printQueue.push(() => {
|
|
170
|
+
this.root = this.root
|
|
171
|
+
.ele("item", { name: "personaTitleTextAppearance" })
|
|
172
|
+
.txt("@style/Persona.Text.Title")
|
|
173
|
+
.up();
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
bodyText() {
|
|
178
|
+
if (this.theme.bodyTextColor || this.theme.bodyTextFont) {
|
|
179
|
+
this.printQueue.push(() => {
|
|
180
|
+
this.root = this.root
|
|
181
|
+
.ele("item", { name: "personaBodyTextAppearance" })
|
|
182
|
+
.txt("@style/RN.Persona.Text.Body")
|
|
183
|
+
.up();
|
|
184
|
+
});
|
|
185
|
+
// Create a text appearance
|
|
186
|
+
this.postPrintQueue.push(() => {
|
|
187
|
+
this.root = this.root.ele("style", {
|
|
188
|
+
name: "RN.Persona.Text.Body",
|
|
189
|
+
parent: "Persona.Text.Body",
|
|
190
|
+
});
|
|
191
|
+
if (this.theme.bodyTextColor) {
|
|
192
|
+
this.root = this.root
|
|
193
|
+
.ele("item", { name: "android:textColor" })
|
|
194
|
+
.txt(this.theme.bodyTextColor)
|
|
195
|
+
.up();
|
|
196
|
+
}
|
|
197
|
+
if (this.theme.bodyTextFont) {
|
|
198
|
+
// TODO: Add notice about how to add a custom font that can be
|
|
199
|
+
// referenced here on Android
|
|
200
|
+
this.root = this.root
|
|
201
|
+
.ele("item", { name: "android:fontFamily" })
|
|
202
|
+
.txt(this.theme.bodyTextFont)
|
|
203
|
+
.up();
|
|
204
|
+
}
|
|
205
|
+
// Default values taken from `Persona.Text.Body`
|
|
206
|
+
// in shared/src/main/res/values/styles.xml
|
|
207
|
+
this.root = this.root
|
|
208
|
+
.ele("item", { name: "android:textSize" })
|
|
209
|
+
.txt("18sp")
|
|
210
|
+
.up();
|
|
211
|
+
this.root = this.root.up();
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
this.printQueue.push(() => {
|
|
216
|
+
this.root = this.root
|
|
217
|
+
.ele("item", { name: "personaBodyTextAppearance" })
|
|
218
|
+
.txt("@style/Persona.Text.Body")
|
|
219
|
+
.up();
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
footnoteText() {
|
|
224
|
+
if (this.theme.footnoteTextColor || this.theme.footnoteTextFont) {
|
|
225
|
+
this.postPrintQueue.push(() => {
|
|
226
|
+
var _a, _b;
|
|
227
|
+
this.root = this.root
|
|
228
|
+
.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
|
+
.ele("item", { name: "android:textColor" })
|
|
234
|
+
.txt(
|
|
235
|
+
// Used default value found in the Android SDK
|
|
236
|
+
(_a = this.theme.footnoteTextColor) !== null && _a !== void 0 ? _a : "?android:attr/textColorTertiary")
|
|
237
|
+
.up();
|
|
238
|
+
if (this.theme.footnoteTextFont) {
|
|
239
|
+
this.root = this.root
|
|
240
|
+
.ele("item", { name: "android:fontFamily" })
|
|
241
|
+
.txt(
|
|
242
|
+
// Used default value found in the Android SDK
|
|
243
|
+
(_b = this.theme.footnoteTextFont) !== null && _b !== void 0 ? _b : "?android:attr/textColorTertiary")
|
|
244
|
+
.up();
|
|
245
|
+
}
|
|
246
|
+
this.root = this.root.up();
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
textField() {
|
|
251
|
+
if (this.theme.textFieldTextColor || this.theme.textFieldTextFont) {
|
|
252
|
+
this.printQueue.push(() => {
|
|
253
|
+
this.root = this.root
|
|
254
|
+
.ele("item", { name: "editTextStyle" })
|
|
255
|
+
.txt("@style/RN.Persona.EditText")
|
|
256
|
+
.up();
|
|
257
|
+
});
|
|
258
|
+
this.postPrintQueue.push(() => {
|
|
259
|
+
this.root = this.root
|
|
260
|
+
.ele("style", {
|
|
261
|
+
name: "RN.Persona.EditText",
|
|
262
|
+
parent: "Widget.AppCompat.EditText",
|
|
263
|
+
})
|
|
264
|
+
.ele("item", { name: "android:textAppearance" })
|
|
265
|
+
.txt("@style/RN.Persona.EditText.TextAppearance")
|
|
266
|
+
.up()
|
|
267
|
+
.ele("item", { name: "android:textColor" })
|
|
268
|
+
.txt(this.theme.textFieldTextColor)
|
|
269
|
+
.up()
|
|
270
|
+
.up();
|
|
271
|
+
this.root = this.root.ele("style", {
|
|
272
|
+
name: "RN.Persona.EditText.TextAppearance",
|
|
273
|
+
parent: "Base.TextAppearance.AppCompat.Medium",
|
|
274
|
+
});
|
|
275
|
+
if (this.theme.textFieldTextColor) {
|
|
276
|
+
this.root = this.root
|
|
277
|
+
.ele("item", { name: "android:textSize" })
|
|
278
|
+
.txt("18sp")
|
|
279
|
+
.up();
|
|
280
|
+
}
|
|
281
|
+
if (this.theme.textFieldTextFont) {
|
|
282
|
+
this.root = this.root
|
|
283
|
+
.ele("item", { name: "android:fontFamily" })
|
|
284
|
+
.txt(this.theme.textFieldTextFont)
|
|
285
|
+
.up();
|
|
286
|
+
}
|
|
287
|
+
this.root = this.root.up();
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
pickerText() {
|
|
292
|
+
if (this.theme.pickerTextColor || this.theme.pickerTextFont) {
|
|
293
|
+
this.printQueue.push(() => {
|
|
294
|
+
this.root = this.root
|
|
295
|
+
.ele("item", { name: "spinnerStyle" })
|
|
296
|
+
.txt("@style/RN.Persona.Spinner")
|
|
297
|
+
.up();
|
|
298
|
+
this.root = this.root
|
|
299
|
+
.ele("item", { name: "spinnerDropDownItemStyle" })
|
|
300
|
+
.txt("@style/RN.Persona.DropDownItem.Spinner")
|
|
301
|
+
.up();
|
|
302
|
+
});
|
|
303
|
+
this.postPrintQueue.push(() => {
|
|
304
|
+
var _a, _b;
|
|
305
|
+
// Build Rn.Persona.Spinner
|
|
306
|
+
this.root = this.root
|
|
307
|
+
.ele("style", {
|
|
308
|
+
name: "RN.Persona.Spinner",
|
|
309
|
+
parent: "Widget.AppCompat.Spinner",
|
|
310
|
+
})
|
|
311
|
+
.ele("item", { name: "android:textColor" })
|
|
312
|
+
.txt((_a = this.theme.pickerTextColor) !== null && _a !== void 0 ? _a : "?android:attr/textColorPrimary")
|
|
313
|
+
.up()
|
|
314
|
+
.ele("item", { name: "android:textAppearance" })
|
|
315
|
+
.txt(this.theme.pickerTextFont
|
|
316
|
+
? "@style/RN.Persona.Text.Spinner"
|
|
317
|
+
: "@style/Persona.Text.Body")
|
|
318
|
+
.up()
|
|
319
|
+
.up();
|
|
320
|
+
// Build RN.Persona.DropDownItem.Spinner
|
|
321
|
+
this.root = this.root
|
|
322
|
+
.ele("style", {
|
|
323
|
+
name: "RN.Persona.DropDownItem.Spinner",
|
|
324
|
+
parent: "Widget.AppCompat.DropDownItem.Spinner",
|
|
325
|
+
})
|
|
326
|
+
.ele("item", { name: "android:textColor" })
|
|
327
|
+
.txt((_b = this.theme.pickerTextColor) !== null && _b !== void 0 ? _b : "?android:attr/textColorPrimary")
|
|
328
|
+
.up()
|
|
329
|
+
.ele("item", { name: "android:textAppearance" })
|
|
330
|
+
.txt(this.theme.pickerTextFont
|
|
331
|
+
? "@style/RN.Persona.Text.Spinner"
|
|
332
|
+
: "@style/Persona.Text.Body")
|
|
333
|
+
.up()
|
|
334
|
+
.up();
|
|
335
|
+
// Build RN.Persona.Text.Spinner
|
|
336
|
+
this.root = this.root.ele("style", {
|
|
337
|
+
name: "RN.Persona.Text.Spinner",
|
|
338
|
+
});
|
|
339
|
+
if (this.theme.pickerTextColor) {
|
|
340
|
+
this.root = this.root
|
|
341
|
+
.ele("item", { name: "android:textColor" })
|
|
342
|
+
.txt(this.theme.pickerTextColor)
|
|
343
|
+
.up();
|
|
344
|
+
}
|
|
345
|
+
if (this.theme.pickerTextFont) {
|
|
346
|
+
// TODO: Add notice about how to add a custom font that can be
|
|
347
|
+
// referenced here on Android
|
|
348
|
+
this.root = this.root
|
|
349
|
+
.ele("item", { name: "android:fontFamily" })
|
|
350
|
+
.txt(this.theme.pickerTextFont)
|
|
351
|
+
.up();
|
|
352
|
+
}
|
|
353
|
+
this.root = this.root.up();
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
button() {
|
|
358
|
+
if (this.theme.buttonBackgroundColor ||
|
|
359
|
+
this.theme.buttonDisabledBackgroundColor ||
|
|
360
|
+
this.theme.buttonTouchedBackgroundColor ||
|
|
361
|
+
this.theme.buttonTextColor ||
|
|
362
|
+
this.theme.buttonDisabledTextColor ||
|
|
363
|
+
this.theme.buttonCornerRadius ||
|
|
364
|
+
this.theme.buttonFont) {
|
|
365
|
+
this.printQueue.push(() => {
|
|
366
|
+
this.root = this.root
|
|
367
|
+
.ele("item", { name: "buttonStyle" })
|
|
368
|
+
.txt("@style/RN.Persona.Button")
|
|
369
|
+
.up();
|
|
370
|
+
});
|
|
371
|
+
this.postPrintQueue.push(() => {
|
|
372
|
+
var _a, _b, _c, _d, _e;
|
|
373
|
+
this.root = this.root
|
|
374
|
+
.ele("style", {
|
|
375
|
+
name: "RN.Persona.Button",
|
|
376
|
+
parent: "android:style/Widget.Button",
|
|
377
|
+
})
|
|
378
|
+
// Taken from
|
|
379
|
+
// appcompat's res/values/values.xml
|
|
380
|
+
.ele("item", {
|
|
381
|
+
name: "android:minHeight",
|
|
382
|
+
})
|
|
383
|
+
.txt("48dip")
|
|
384
|
+
.up()
|
|
385
|
+
// Taken from
|
|
386
|
+
// appcompat's res/values/values.xml
|
|
387
|
+
.ele("item", {
|
|
388
|
+
name: "android:minWidth",
|
|
389
|
+
})
|
|
390
|
+
.txt("88dip")
|
|
391
|
+
.up()
|
|
392
|
+
// Taken from
|
|
393
|
+
// persona-android's shared/src/main/res/values/styles.xml
|
|
394
|
+
.ele("item", {
|
|
395
|
+
name: "android:textSize",
|
|
396
|
+
})
|
|
397
|
+
.txt("18sp")
|
|
398
|
+
.up()
|
|
399
|
+
.ele("item", {
|
|
400
|
+
name: "android:background",
|
|
401
|
+
})
|
|
402
|
+
.txt("@drawable/rn_persona_button")
|
|
403
|
+
.up()
|
|
404
|
+
.ele("item", {
|
|
405
|
+
name: "android:textColor",
|
|
406
|
+
})
|
|
407
|
+
.txt("@color/rn_persona_button")
|
|
408
|
+
.up()
|
|
409
|
+
.up();
|
|
410
|
+
// Disabled
|
|
411
|
+
this.buttonDrawable = this.buttonDrawable
|
|
412
|
+
.ele("item", {
|
|
413
|
+
"android:state_enabled": "false",
|
|
414
|
+
})
|
|
415
|
+
.ele("shape", { "android:shape": "rectangle" })
|
|
416
|
+
.ele("corners", {
|
|
417
|
+
"android:radius": this.theme.buttonCornerRadius
|
|
418
|
+
? `${this.theme.buttonCornerRadius}dp`
|
|
419
|
+
: "@dimen/abc_control_corner_material",
|
|
420
|
+
})
|
|
421
|
+
.up()
|
|
422
|
+
.ele("padding", {
|
|
423
|
+
"android:left": "@dimen/abc_button_padding_horizontal_material",
|
|
424
|
+
"android:top": "@dimen/abc_button_padding_vertical_material",
|
|
425
|
+
"android:right": "@dimen/abc_button_padding_horizontal_material",
|
|
426
|
+
"android:bottom": "@dimen/abc_button_padding_vertical_material",
|
|
427
|
+
})
|
|
428
|
+
.up()
|
|
429
|
+
.ele("solid", {
|
|
430
|
+
"android:color": this.theme.buttonDisabledBackgroundColor
|
|
431
|
+
? this.theme.buttonDisabledBackgroundColor
|
|
432
|
+
: "?attr/colorPrimaryDark",
|
|
433
|
+
})
|
|
434
|
+
.up()
|
|
435
|
+
.up()
|
|
436
|
+
.up();
|
|
437
|
+
// touched
|
|
438
|
+
this.buttonDrawable = this.buttonDrawable
|
|
439
|
+
.ele("item", {
|
|
440
|
+
"android:state_pressed": "true",
|
|
441
|
+
})
|
|
442
|
+
.ele("shape", { "android:shape": "rectangle" })
|
|
443
|
+
.ele("corners", {
|
|
444
|
+
"android:radius": this.theme.buttonCornerRadius
|
|
445
|
+
? `${this.theme.buttonCornerRadius}dp`
|
|
446
|
+
: "@dimen/abc_control_corner_material",
|
|
447
|
+
})
|
|
448
|
+
.up()
|
|
449
|
+
.ele("solid", {
|
|
450
|
+
"android:color": (_a = this.theme.buttonTouchedBackgroundColor) !== null && _a !== void 0 ? _a : "?attr/colorPrimaryDark",
|
|
451
|
+
})
|
|
452
|
+
.up()
|
|
453
|
+
.ele("padding", {
|
|
454
|
+
"android:left": "@dimen/abc_button_padding_horizontal_material",
|
|
455
|
+
"android:top": "@dimen/abc_button_padding_vertical_material",
|
|
456
|
+
"android:right": "@dimen/abc_button_padding_horizontal_material",
|
|
457
|
+
"android:bottom": "@dimen/abc_button_padding_vertical_material",
|
|
458
|
+
})
|
|
459
|
+
.up()
|
|
460
|
+
.up()
|
|
461
|
+
.up();
|
|
462
|
+
this.buttonDrawable = this.buttonDrawable
|
|
463
|
+
.ele("item")
|
|
464
|
+
.ele("shape", { "android:shape": "rectangle" })
|
|
465
|
+
.ele("corners", {
|
|
466
|
+
"android:radius": this.theme.buttonCornerRadius
|
|
467
|
+
? `${this.theme.buttonCornerRadius}dp`
|
|
468
|
+
: "@dimen/abc_control_corner_material",
|
|
469
|
+
})
|
|
470
|
+
.up()
|
|
471
|
+
.ele("solid", {
|
|
472
|
+
"android:color": (_b = this.theme.buttonBackgroundColor) !== null && _b !== void 0 ? _b : "?attr/colorPrimary",
|
|
473
|
+
})
|
|
474
|
+
.up()
|
|
475
|
+
.ele("padding", {
|
|
476
|
+
"android:left": "@dimen/abc_button_padding_horizontal_material",
|
|
477
|
+
"android:top": "@dimen/abc_button_padding_vertical_material",
|
|
478
|
+
"android:right": "@dimen/abc_button_padding_horizontal_material",
|
|
479
|
+
"android:bottom": "@dimen/abc_button_padding_vertical_material",
|
|
480
|
+
})
|
|
481
|
+
.up()
|
|
482
|
+
.up()
|
|
483
|
+
.up();
|
|
484
|
+
// Finish button drawable
|
|
485
|
+
this.buttonDrawable = this.buttonDrawable.up();
|
|
486
|
+
this.buttonColor = this.buttonColor
|
|
487
|
+
.ele("item", {
|
|
488
|
+
"android:state_enabled": "false",
|
|
489
|
+
"android:color": (_c = this.theme.buttonDisabledTextColor) !== null && _c !== void 0 ? _c : "@android:color/darker_gray",
|
|
490
|
+
})
|
|
491
|
+
.up()
|
|
492
|
+
.ele("item", {
|
|
493
|
+
"android:state_pressed": "true",
|
|
494
|
+
"android:color": (_d = this.theme.buttonTextColor) !== null && _d !== void 0 ? _d : "@android:color/white",
|
|
495
|
+
})
|
|
496
|
+
.up()
|
|
497
|
+
.ele("item", {
|
|
498
|
+
"android:color": (_e = this.theme.buttonTextColor) !== null && _e !== void 0 ? _e : "@android:color/white",
|
|
499
|
+
})
|
|
500
|
+
.up();
|
|
501
|
+
this.buttonColor = this.buttonColor.up();
|
|
502
|
+
this.root = this.root.up();
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
progressColor() {
|
|
507
|
+
if (this.theme.progressColor) {
|
|
508
|
+
this.printQueue.push(() => {
|
|
509
|
+
this.root = this.root
|
|
510
|
+
.ele("item", { name: "colorControlActivated" })
|
|
511
|
+
.txt(this.theme.progressColor)
|
|
512
|
+
.up();
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
successAsset() {
|
|
517
|
+
if (!this.theme.successAsset)
|
|
518
|
+
return;
|
|
519
|
+
this.printQueue.push(() => {
|
|
520
|
+
this.root = this.root
|
|
521
|
+
.ele("item", { name: "personaInquiryCompleteImage" })
|
|
522
|
+
.txt(this.theme.successAsset)
|
|
523
|
+
.up()
|
|
524
|
+
.txt(" ");
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
failAsset() {
|
|
528
|
+
if (!this.theme.failAsset)
|
|
529
|
+
return;
|
|
530
|
+
this.printQueue.push(() => {
|
|
531
|
+
this.root = this.root
|
|
532
|
+
.ele("item", { name: "personaInquiryFailImage" })
|
|
533
|
+
.txt(this.theme.failAsset)
|
|
534
|
+
.up()
|
|
535
|
+
.txt(" ");
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
loadingAnimationAsset() {
|
|
539
|
+
if (!this.theme.loadingAnimationAsset ||
|
|
540
|
+
!this.theme.loadingAnimationWidthPercent)
|
|
541
|
+
return;
|
|
542
|
+
this.printQueue.push(() => {
|
|
543
|
+
this.root = this.root
|
|
544
|
+
.ele("item", { name: "personaInquiryLoadingLottieRaw" })
|
|
545
|
+
.txt(this.theme.loadingAnimationAsset)
|
|
546
|
+
.up()
|
|
547
|
+
.txt(" ");
|
|
548
|
+
this.root = this.root
|
|
549
|
+
.ele("item", { name: "personaInquiryLoadingLottieWidthPercent" })
|
|
550
|
+
.txt(this.theme.loadingAnimationWidthPercent)
|
|
551
|
+
.up()
|
|
552
|
+
.txt(" ");
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
selfieAnimationAsset() {
|
|
556
|
+
if (!this.theme.selfieAnimationAsset ||
|
|
557
|
+
!this.theme.selfieAnimationWidthPercent)
|
|
558
|
+
return;
|
|
559
|
+
this.printQueue.push(() => {
|
|
560
|
+
this.root = this.root
|
|
561
|
+
.ele("item", { name: "personaInquirySelfieLottieRaw" })
|
|
562
|
+
.txt(this.theme.selfieAnimationAsset)
|
|
563
|
+
.up()
|
|
564
|
+
.txt(" ");
|
|
565
|
+
this.root = this.root
|
|
566
|
+
.ele("item", { name: "personaInquirySelfieLottieWidthPercent" })
|
|
567
|
+
.txt(this.theme.selfieAnimationWidthPercent)
|
|
568
|
+
.up()
|
|
569
|
+
.txt(" ");
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
exports.default = AndroidResourcePrinter;
|