-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeneralSettings.js
49 lines (45 loc) · 1.83 KB
/
GeneralSettings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React, { useState } from 'react';
import { View } from 'react-native';
import { Input } from 'react-native-elements';
const GeneralSettings = ({ generalSettings, onSetGeneralSetting, styles }) => {
const [internalNumDaysUntilShopping, setInternalNumDaysUntilShopping] = useState(generalSettings.numDaysUntilShopping || 0);
const [internalGreetingText, setInternalGreetingText] = useState(generalSettings.greetingText);
const items = [
{
key: 'greeting-text',
label: 'Greeting text',
placeholder: 'Hello',
value: internalGreetingText,
onChangeText: (text => setInternalGreetingText(text)),
onSubmitEditing: (() => { onSetGeneralSetting('greetingText', internalGreetingText) })
},
{
key: 'num-days-until-shopping',
label: 'Num. days until shopping',
placeholder: 7,
value: internalNumDaysUntilShopping,
onChangeText: (text => setInternalNumDaysUntilShopping(text)),
onSubmitEditing: (() => { onSetGeneralSetting('numDaysUntilShopping', parseInt(internalNumDaysUntilShopping)) })
}
]
return (
<View>
{
items.map(i => (
<Input
key={i.key}
label={i.label}
labelStyle={styles.input.labelStyle}
inputStyle={styles.input.inputStyle}
containerStyle={styles.input.containerStyle}
placeholder={i.placeholder + ''}
onChangeText={i.onChangeText}
value={i.value + ''}
onSubmitEditing={i.onSubmitEditing}
/>
))
}
</View>
)
}
export default GeneralSettings