Start moving select dropdowns to use menus

This commit is contained in:
Brandon Presley 2022-11-16 18:01:40 +13:00
parent 19ec8ac5e9
commit e7e2f299da
2 changed files with 12 additions and 16 deletions

View File

@ -1,4 +1,5 @@
import {useTheme} from 'react-native-paper'
import {useState} from 'react'
import {Button, Menu, useTheme} from 'react-native-paper'
import RNPickerSelect from 'react-native-picker-select'
import {Item} from 'react-native-picker-select'
@ -12,18 +13,17 @@ export default function Select({
items: Item[]
}) {
const {colors} = useTheme()
const [show, setShow] = useState(false)
return (
<RNPickerSelect
style={{
placeholder: {
color: colors.primary,
},
}}
value={value}
placeholder={{}}
onValueChange={onChange}
items={items}
/>
<Menu
style={{alignSelf: 'flex-start', justifyContent: 'flex-start'}}
visible={show}
onDismiss={() => setShow(false)}
anchor={<Button style={{alignSelf: 'flex-start'}}>{value}</Button>}>
{items.map(item => (
<Menu.Item title={item.label} onPress={() => onChange(item.value)} />
))}
</Menu>
)
}

View File

@ -8,7 +8,6 @@ import {
Platform,
View,
} from 'react-native'
import DeviceTimeFormat from 'react-native-device-time-format'
import DocumentPicker from 'react-native-document-picker'
import {Button} from 'react-native-paper'
import {darkColors, lightColors} from './colors'
@ -62,9 +61,6 @@ export default function SettingsPage() {
})
if (Platform.OS !== 'android') return
NativeModules.AlarmModule.ignoringBattery(setIgnoring)
DeviceTimeFormat.is24HourFormat().then(is24 => {
if (is24) setFormatOptions(['P', 'P, k:m', 'ccc k:m', 'k:m'])
})
}, []),
)