From 1d13cb9c5d36962e6bed153822c63ced7cab5884 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Thu, 26 Oct 2023 20:30:41 +1300 Subject: [PATCH] Change select style --- Select.tsx | 73 ++++++++++++++++++++++++++---------------------- SettingsPage.tsx | 3 +- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/Select.tsx b/Select.tsx index b068398..78e3891 100644 --- a/Select.tsx +++ b/Select.tsx @@ -1,6 +1,13 @@ import React, { useCallback, useMemo, useState } from "react"; -import { View } from "react-native"; -import { Button, Menu, Subheading, useTheme } from "react-native-paper"; +import { Pressable, View } from "react-native"; +import { + Button, + IconButton, + Menu, + Subheading, + useTheme, +} from "react-native-paper"; +import AppInput from "./AppInput"; import { ITEM_PADDING } from "./constants"; export interface Item { @@ -22,13 +29,14 @@ function Select({ }) { const [show, setShow] = useState(false); const { colors } = useTheme(); + let menuButton: React.Ref = null; const selected = useMemo( () => items.find((item) => item.value === value) || items[0], [items, value] ); - const handlePress = useCallback( + const press = useCallback( (newValue: string) => { onChange(newValue); setShow(false); @@ -37,38 +45,35 @@ function Select({ ); return ( - - {label && {label}} - setShow(false)} - anchor={ - - } - > - {items.map((item) => ( - handlePress(item.value)} - /> - ))} - - + setShow(true)} + /> + + + } + > + {items.map((item) => ( + press(item.value)} + titleStyle={{ color: item.color || colors.onSurface }} + /> + ))} + ); } diff --git a/SettingsPage.tsx b/SettingsPage.tsx index e947f1f..e4aa143 100644 --- a/SettingsPage.tsx +++ b/SettingsPage.tsx @@ -2,7 +2,7 @@ import { NavigationProp, useNavigation } from "@react-navigation/native"; import { format } from "date-fns"; import { useCallback, useEffect, useMemo, useState } from "react"; import { useForm } from "react-hook-form"; -import { NativeModules, ScrollView } from "react-native"; +import { NativeModules, ScrollView, View } from "react-native"; import DocumentPicker from "react-native-document-picker"; import { Dirs, FileSystem } from "react-native-file-access"; import ConfirmDialog from "./ConfirmDialog"; @@ -324,6 +324,7 @@ export default function SettingsPage() { {switchesMarkup} + {selectsMarkup} {buttonsMarkup}