Skip to content

Commit 951dc2a

Browse files
committed
refactor(demo): add AppInputProps to TextInputs
1 parent 1f60713 commit 951dc2a

8 files changed

Lines changed: 31 additions & 7 deletions

File tree

examples/demo/src/components/modals/CustomNotificationModal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
KeyboardAvoidingView,
1010
Platform,
1111
} from 'react-native';
12-
import { AppColors, AppDialogStyles } from '../../theme';
12+
import { AppColors, AppDialogStyles, AppInputProps } from '../../theme';
1313

1414
interface Props {
1515
visible: boolean;
@@ -61,6 +61,7 @@ export default function CustomNotificationModal({
6161
value={title}
6262
onChangeText={setTitle}
6363
autoFocus
64+
{...AppInputProps}
6465
testID="custom_notification_title_input"
6566
/>
6667
<TextInput
@@ -69,6 +70,7 @@ export default function CustomNotificationModal({
6970
placeholderTextColor={AppColors.osGrey600}
7071
value={body}
7172
onChangeText={setBody}
73+
{...AppInputProps}
7274
testID="custom_notification_body_input"
7375
/>
7476
<View style={AppDialogStyles.actions}>

examples/demo/src/components/modals/LoginModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
TouchableOpacity,
1010
View,
1111
} from 'react-native';
12-
import { AppColors, AppDialogStyles } from '../../theme';
12+
import { AppColors, AppDialogStyles, AppInputProps } from '../../theme';
1313

1414
interface Props {
1515
visible: boolean;
@@ -55,6 +55,7 @@ export default function LoginModal({ visible, onConfirm, onClose }: Props) {
5555
value={userId}
5656
onChangeText={setUserId}
5757
autoFocus
58+
{...AppInputProps}
5859
testID="login_user_id_input"
5960
/>
6061
<View style={AppDialogStyles.actions}>

examples/demo/src/components/modals/MultiPairInputModal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Platform,
1212
} from 'react-native';
1313
import Icon from 'react-native-vector-icons/MaterialIcons';
14-
import { AppColors, AppDialogStyles } from '../../theme';
14+
import { AppColors, AppDialogStyles, AppInputProps } from '../../theme';
1515

1616
interface Row {
1717
id: number;
@@ -107,6 +107,7 @@ export default function MultiPairInputModal({
107107
value={row.key}
108108
onChangeText={t => updateRow(row.id, 'key', t)}
109109
autoFocus={idx === 0}
110+
{...AppInputProps}
110111
testID={idx === 0 ? 'multi_pair_key_0' : undefined}
111112
/>
112113
<TextInput
@@ -115,6 +116,7 @@ export default function MultiPairInputModal({
115116
placeholderTextColor={AppColors.osGrey600}
116117
value={row.value}
117118
onChangeText={t => updateRow(row.id, 'value', t)}
119+
{...AppInputProps}
118120
testID={idx === 0 ? 'multi_pair_value_0' : undefined}
119121
/>
120122
{rows.length > 1 && (

examples/demo/src/components/modals/OutcomeModal.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import {
99
KeyboardAvoidingView,
1010
Platform,
1111
} from 'react-native';
12-
import { AppColors, AppTextStyles, AppDialogStyles } from '../../theme';
12+
import {
13+
AppColors,
14+
AppTextStyles,
15+
AppDialogStyles,
16+
AppInputProps,
17+
} from '../../theme';
1318

1419
type OutcomeType = 'normal' | 'unique' | 'withValue';
1520

@@ -103,6 +108,7 @@ export default function OutcomeModal({
103108
value={name}
104109
onChangeText={setName}
105110
autoFocus
111+
{...AppInputProps}
106112
testID="outcome_name_input"
107113
/>
108114
{outcomeType === 'withValue' && (
@@ -113,6 +119,7 @@ export default function OutcomeModal({
113119
value={value}
114120
onChangeText={setValue}
115121
keyboardType="numeric"
122+
{...AppInputProps}
116123
testID="outcome_value_input"
117124
/>
118125
)}

examples/demo/src/components/modals/PairInputModal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
KeyboardAvoidingView,
1010
Platform,
1111
} from 'react-native';
12-
import { AppColors, AppDialogStyles } from '../../theme';
12+
import { AppColors, AppDialogStyles, AppInputProps } from '../../theme';
1313

1414
interface Props {
1515
visible: boolean;
@@ -78,6 +78,7 @@ export default function PairInputModal({
7878
value={keyValue}
7979
onChangeText={setKeyValue}
8080
autoFocus
81+
{...AppInputProps}
8182
testID={keyTestID}
8283
/>
8384
<TextInput
@@ -90,6 +91,7 @@ export default function PairInputModal({
9091
placeholderTextColor={AppColors.osGrey600}
9192
value={val}
9293
onChangeText={setVal}
94+
{...AppInputProps}
9395
testID={valueTestID}
9496
/>
9597
</View>

examples/demo/src/components/modals/SingleInputModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
KeyboardAvoidingView,
1010
Platform,
1111
} from 'react-native';
12-
import { AppColors, AppDialogStyles } from '../../theme';
12+
import { AppColors, AppDialogStyles, AppInputProps } from '../../theme';
1313

1414
interface Props {
1515
visible: boolean;
@@ -67,6 +67,7 @@ export default function SingleInputModal({
6767
onChangeText={setValue}
6868
keyboardType={keyboardType}
6969
autoFocus
70+
{...AppInputProps}
7071
testID={testID}
7172
/>
7273
<View style={AppDialogStyles.actions}>

examples/demo/src/components/modals/TrackEventModal.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
AppTextStyles,
1515
AppSpacing,
1616
AppDialogStyles,
17+
AppInputProps,
1718
} from '../../theme';
1819

1920
interface Props {
@@ -103,6 +104,7 @@ export default function TrackEventModal({
103104
value={name}
104105
onChangeText={setName}
105106
autoFocus
107+
{...AppInputProps}
106108
testID="track_event_name_input"
107109
/>
108110
<Text style={styles.label}>Properties (optional, JSON)</Text>
@@ -117,6 +119,7 @@ export default function TrackEventModal({
117119
value={propertiesText}
118120
onChangeText={handlePropertiesChange}
119121
multiline
122+
{...AppInputProps}
120123
testID="track_event_properties_input"
121124
/>
122125
{!!jsonError && <Text style={styles.errorText}>{jsonError}</Text>}

examples/demo/src/theme.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { StyleSheet } from 'react-native';
1+
import { StyleSheet, type TextInputProps } from 'react-native';
22

33
export const AppColors = {
44
osPrimary: '#E54B4D',
@@ -49,6 +49,12 @@ export const AppTheme = StyleSheet.create({
4949
},
5050
});
5151

52+
export const AppInputProps: TextInputProps = {
53+
autoCorrect: false,
54+
autoCapitalize: 'none',
55+
autoComplete: 'off',
56+
};
57+
5258
export const AppDialogStyles = StyleSheet.create({
5359
backdrop: {
5460
flex: 1,

0 commit comments

Comments
 (0)