Skip to content

Commit 2f200e0

Browse files
authored
TextField - fix screen cases (#3145)
* TextField - screen for snapshot tests * remove validateOnStart
1 parent 0fdcdcf commit 2f200e0

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

demo/src/screens/componentScreens/TextFieldScreen.tsx

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default class TextFieldScreen extends Component {
8181

8282
<View row bottom>
8383
<TextField
84-
placeholder="Floating placeholder"
84+
placeholder="FloatingPlaceholder"
8585
floatingPlaceholder
8686
floatingPlaceholderColor={{
8787
focus: Colors.$textDefault,
@@ -90,10 +90,12 @@ export default class TextFieldScreen extends Component {
9090
// floatingPlaceholderStyle={Typography.text60}
9191
// style={Typography.text60}
9292
containerStyle={{flex: 1}}
93+
preset={this.state.preset}
9394
/>
9495
<TextField
9596
placeholder="Placeholder"
9697
containerStyle={{flex: 1, marginLeft: Spacings.s6}}
98+
preset={this.state.preset}
9799
/>
98100
</View>
99101
</>
@@ -135,6 +137,7 @@ export default class TextFieldScreen extends Component {
135137
ref={this.input2}
136138
placeholder="Enter search term"
137139
trailingAccessory={this.renderTrailingAccessory()}
140+
preset={this.state.preset}
138141
/>
139142
<TextField
140143
ref={this.input2}
@@ -145,6 +148,7 @@ export default class TextFieldScreen extends Component {
145148
Kg.
146149
</Text>
147150
}
151+
preset={this.state.preset}
148152
/>
149153

150154
<Text marginB-s2 $textPrimary>Leading Accessory:</Text>
@@ -156,6 +160,7 @@ export default class TextFieldScreen extends Component {
156160
Https://
157161
</Text>
158162
}
163+
preset={this.state.preset}
159164
/>
160165
</>
161166
);
@@ -167,7 +172,7 @@ export default class TextFieldScreen extends Component {
167172
};
168173

169174
renderValidationExample() {
170-
const {errorPosition, preset} = this.state;
175+
const {errorPosition, preset, value} = this.state;
171176

172177
return (
173178
<>
@@ -180,7 +185,7 @@ export default class TextFieldScreen extends Component {
180185
</View>
181186

182187
<TextField
183-
value={this.state.value}
188+
value={value}
184189
onChangeText={value => this.setState({value})}
185190
label="Email"
186191
placeholder="Enter email"
@@ -189,12 +194,13 @@ export default class TextFieldScreen extends Component {
189194
// validationMessageStyle={Typography.text90R}
190195
validationMessagePosition={errorPosition}
191196
validate={['required', 'email']}
192-
validateOnChange
193197
onChangeValidity={(isValid: boolean) => console.warn('validity changed:', isValid, Date.now())}
198+
validateOnChange
194199
// validateOnStart
195200
// validateOnBlur
201+
preset={preset}
196202
/>
197-
<View row spread center>
203+
<View row spread center marginT-20>
198204
<TextField
199205
ref={this.inputWithValidation}
200206
label="Name"
@@ -249,7 +255,7 @@ export default class TextFieldScreen extends Component {
249255
};
250256

251257
renderStateColorsExample() {
252-
const {isReadonly, isDisabled} = this.state;
258+
const {isReadonly, isDisabled, preset} = this.state;
253259

254260
return (
255261
<>
@@ -278,6 +284,7 @@ export default class TextFieldScreen extends Component {
278284
validateOnChange
279285
readonly={isReadonly}
280286
editable={!isDisabled}
287+
preset={preset}
281288
/>
282289
</>
283290
);
@@ -333,7 +340,7 @@ export default class TextFieldScreen extends Component {
333340
);
334341
}
335342

336-
renderCherCounterExample() {
343+
renderCharCounterExample() {
337344
return (
338345
<>
339346
<Text h3 marginB-s3>
@@ -348,6 +355,7 @@ export default class TextFieldScreen extends Component {
348355
bottomAccessory={<Text text100>{Assets.emojis.grapes} {Assets.emojis.melon} {Assets.emojis.banana}</Text>}
349356
charCounterStyle={{color: Colors.$textGeneral}}
350357
maxLength={20}
358+
preset={this.state.preset}
351359
/>
352360
</>
353361
);
@@ -368,6 +376,7 @@ export default class TextFieldScreen extends Component {
368376
onChangeText={value => this.setState({value})}
369377
trailingAccessory={<Icon source={Assets.icons.demo.search}/>}
370378
// multiline
379+
preset={this.state.preset}
371380
/>
372381
</>
373382
);
@@ -385,13 +394,14 @@ export default class TextFieldScreen extends Component {
385394
floatingPlaceholder
386395
floatOnFocus
387396
hint="1-6 chars including numeric chars"
397+
preset={this.state.preset}
388398
/>
389399
</>
390400
);
391401
}
392402

393403
renderFormatterExample() {
394-
const {price} = this.state;
404+
const {price, preset} = this.state;
395405

396406
return (
397407
<>
@@ -409,12 +419,15 @@ export default class TextFieldScreen extends Component {
409419
// @ts-expect-error
410420
formatter={value => (isNaN(value) ? value : priceFormatter.format(Number(value)))}
411421
leadingAccessory={<Text marginR-s1 $textNeutral>$</Text>}
422+
preset={preset}
412423
/>
413424
</>
414425
);
415426
}
416427

417428
renderCustomAlignmentExample() {
429+
const {preset, errorPosition} = this.state;
430+
418431
return (
419432
<>
420433
<Text h3 marginB-3>
@@ -426,18 +439,25 @@ export default class TextFieldScreen extends Component {
426439
label="PIN"
427440
placeholder="XXXX"
428441
centered
429-
topTrailingAccessory={<Icon source={Assets.icons.demo.info} size={16}/>}
442+
topTrailingAccessory={<Icon source={Assets.icons.demo.info} size={16} marginL-s1/>}
430443
validate={'required'}
431444
validationMessage={'This field is required'}
432445
validateOnBlur
433-
validationMessagePosition={this.state.errorPosition}
446+
validationMessagePosition={errorPosition}
447+
preset={preset}
434448
/>
435449

436450
<Text marginB-s1 $textPrimary>Inline:</Text>
437451
<View row>
438-
<TextField placeholder="hours"/>
439-
<Text marginT-s1 marginH-s1>:</Text>
440-
<TextField placeholder="minutes"/>
452+
<TextField placeholder="hours" preset={preset}/>
453+
<Text
454+
marginT-s1={preset === TextField.presets.UNDERLINE}
455+
marginT-s2={preset === TextField.presets.OUTLINE}
456+
marginH-s1
457+
>
458+
:
459+
</Text>
460+
<TextField placeholder="minutes" preset={preset}/>
441461
</View>
442462
</>
443463
);
@@ -455,7 +475,7 @@ export default class TextFieldScreen extends Component {
455475
{this.renderValidationExample()}
456476
{this.renderHintExample()}
457477
{this.renderClearButtonExample()}
458-
{this.renderCherCounterExample()}
478+
{this.renderCharCounterExample()}
459479
{this.renderAccessoriesExample()}
460480
{this.renderStateColorsExample()}
461481
{this.renderDynamicFieldExample()}

0 commit comments

Comments
 (0)