Polish mobile and web experience
This commit is contained in:
@@ -62,7 +62,12 @@ export function DateTimeField({
|
||||
<View style={styles.wrapper}>
|
||||
<Text style={[styles.label, { color: colors.mutedForeground }]}>{label}</Text>
|
||||
<Pressable
|
||||
accessible
|
||||
accessibilityLabel={`${label}, ${
|
||||
mode === "date" ? formatDate(value) : formatDateTime(value)
|
||||
}`}
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ expanded: open }}
|
||||
onPress={openPicker}
|
||||
style={({ pressed }) => [
|
||||
styles.trigger,
|
||||
|
||||
@@ -3,7 +3,9 @@ import {
|
||||
Text,
|
||||
TextInput,
|
||||
View,
|
||||
type StyleProp,
|
||||
type TextInputProps,
|
||||
type ViewStyle,
|
||||
} from "react-native";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
|
||||
@@ -17,6 +19,7 @@ type InputProps = TextInputProps & {
|
||||
leftIcon?: keyof typeof Ionicons.glyphMap;
|
||||
labelAccessory?: React.ReactNode;
|
||||
hint?: string;
|
||||
containerStyle?: StyleProp<ViewStyle>;
|
||||
};
|
||||
|
||||
export function Input({
|
||||
@@ -26,13 +29,14 @@ export function Input({
|
||||
leftIcon,
|
||||
labelAccessory,
|
||||
hint,
|
||||
containerStyle,
|
||||
style,
|
||||
...props
|
||||
}: InputProps) {
|
||||
const { colors } = useAppTheme();
|
||||
|
||||
return (
|
||||
<View style={styles.wrapper}>
|
||||
<View style={[styles.wrapper, containerStyle]}>
|
||||
<View style={styles.labelRow}>
|
||||
<Text style={[styles.label, { color: colors.foreground }]}>
|
||||
{label}
|
||||
|
||||
@@ -7,6 +7,8 @@ import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
type StyleProp,
|
||||
type ViewStyle,
|
||||
} from "react-native";
|
||||
|
||||
import { fonts, radii, spacing } from "@/constants/theme";
|
||||
@@ -26,6 +28,8 @@ type SelectFieldProps = {
|
||||
required?: boolean;
|
||||
error?: string;
|
||||
onValueChange: (value: string) => void;
|
||||
onBlur?: () => void;
|
||||
containerStyle?: StyleProp<ViewStyle>;
|
||||
};
|
||||
|
||||
export function SelectField({
|
||||
@@ -37,19 +41,29 @@ export function SelectField({
|
||||
required,
|
||||
error,
|
||||
onValueChange,
|
||||
onBlur,
|
||||
containerStyle,
|
||||
}: SelectFieldProps) {
|
||||
const { colors } = useAppTheme();
|
||||
const [open, setOpen] = useState(false);
|
||||
const selected = options.find((option) => option.value === value);
|
||||
|
||||
function close() {
|
||||
setOpen(false);
|
||||
onBlur?.();
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.wrapper}>
|
||||
<View style={[styles.wrapper, containerStyle]}>
|
||||
<Text style={[styles.label, { color: colors.foreground }]}>
|
||||
{label}
|
||||
{required ? <Text style={{ color: colors.destructive }}> *</Text> : null}
|
||||
</Text>
|
||||
<Pressable
|
||||
accessible
|
||||
accessibilityLabel={`${label}, ${selected?.label ?? placeholder}`}
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ disabled: Boolean(disabled), expanded: open }}
|
||||
disabled={disabled}
|
||||
onPress={() => setOpen(true)}
|
||||
style={({ pressed }) => [
|
||||
@@ -77,18 +91,18 @@ export function SelectField({
|
||||
|
||||
<Modal
|
||||
animationType="slide"
|
||||
onRequestClose={() => setOpen(false)}
|
||||
onRequestClose={close}
|
||||
transparent
|
||||
visible={open}
|
||||
>
|
||||
<Pressable style={styles.backdrop} onPress={() => setOpen(false)}>
|
||||
<Pressable style={styles.backdrop} onPress={close}>
|
||||
<Pressable
|
||||
style={[styles.sheet, { backgroundColor: colors.background }]}
|
||||
onPress={(event) => event.stopPropagation()}
|
||||
>
|
||||
<View style={[styles.sheetHeader, { borderBottomColor: colors.border }]}>
|
||||
<Text style={[styles.sheetTitle, { color: colors.foreground }]}>{label}</Text>
|
||||
<Pressable accessibilityRole="button" onPress={() => setOpen(false)}>
|
||||
<Pressable accessibilityRole="button" onPress={close}>
|
||||
<Text style={[styles.done, { color: colors.primary }]}>Done</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
@@ -101,7 +115,7 @@ export function SelectField({
|
||||
accessibilityRole="button"
|
||||
onPress={() => {
|
||||
onValueChange(option.value);
|
||||
setOpen(false);
|
||||
close();
|
||||
}}
|
||||
style={({ pressed }) => [
|
||||
styles.option,
|
||||
|
||||
Reference in New Issue
Block a user