fix: pg db timezone, dialog mount child when visible, show non expired link and more
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { useKeyboard } from "../src/useKeyboard";
|
||||
import type { ReactNode } from "react";
|
||||
import { Text, Pressable } from "react-native";
|
||||
|
||||
@@ -5,6 +6,7 @@ export interface ButtonProps {
|
||||
children: ReactNode;
|
||||
onPress?: () => void;
|
||||
variant?: 'default' | 'secondary' | 'destructive';
|
||||
shortcut?: string;
|
||||
}
|
||||
|
||||
const STYLES: Record<NonNullable<ButtonProps['variant']>, { backgroundColor: string, color: string }> = {
|
||||
@@ -13,10 +15,15 @@ const STYLES: Record<NonNullable<ButtonProps['variant']>, { backgroundColor: str
|
||||
destructive: { backgroundColor: 'red', color: 'white' },
|
||||
};
|
||||
|
||||
export function Button({ children, variant, onPress }: ButtonProps) {
|
||||
export function Button({ children, variant, onPress, shortcut }: ButtonProps) {
|
||||
const { backgroundColor, color } = STYLES[variant || "default"];
|
||||
|
||||
useKeyboard((key) => {
|
||||
if (!shortcut || !onPress) return;
|
||||
if (key.name == shortcut) onPress();
|
||||
});
|
||||
|
||||
return <Pressable onPress={onPress} style={{ backgroundColor }}>
|
||||
<Text style={{ fontFamily: 'mono', color }}> {children} </Text>
|
||||
<Text style={{ fontFamily: 'mono', color }}> {children}{shortcut && ` (${shortcut})`} </Text>
|
||||
</Pressable>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user