- Replace mobile placeholder with Expo Router app (tabs, playback, auth, library) - Move Convex backend to @otunes/convex for web and mobile reuse - Update web app imports and API routes to use shared package
141 lines
3.0 KiB
TypeScript
141 lines
3.0 KiB
TypeScript
import {
|
|
ActivityIndicator,
|
|
Pressable,
|
|
PressableProps,
|
|
StyleSheet,
|
|
Text,
|
|
TextInput,
|
|
TextInputProps,
|
|
View,
|
|
} from "react-native"
|
|
|
|
import { radius, spacing, useThemeColors } from "@/lib/theme"
|
|
|
|
type ButtonProps = Omit<PressableProps, "style"> & {
|
|
title: string
|
|
variant?: "primary" | "secondary" | "ghost" | "destructive"
|
|
loading?: boolean
|
|
style?: PressableProps["style"]
|
|
}
|
|
|
|
export function Button({
|
|
title,
|
|
variant = "primary",
|
|
loading = false,
|
|
disabled,
|
|
...props
|
|
}: ButtonProps) {
|
|
const colors = useThemeColors()
|
|
const isDisabled = disabled || loading
|
|
|
|
const backgroundColor =
|
|
variant === "primary"
|
|
? colors.primary
|
|
: variant === "secondary"
|
|
? colors.muted
|
|
: variant === "destructive"
|
|
? colors.destructive
|
|
: "transparent"
|
|
|
|
const textColor =
|
|
variant === "primary"
|
|
? colors.primaryForeground
|
|
: variant === "destructive"
|
|
? "#fff"
|
|
: colors.foreground
|
|
|
|
return (
|
|
<Pressable
|
|
{...props}
|
|
disabled={isDisabled}
|
|
style={({ pressed }) => ({
|
|
minHeight: 44,
|
|
borderRadius: radius.md,
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
paddingHorizontal: spacing.lg,
|
|
paddingVertical: spacing.sm,
|
|
backgroundColor,
|
|
opacity: isDisabled ? 0.5 : pressed ? 0.85 : 1,
|
|
})}
|
|
>
|
|
{loading ? (
|
|
<ActivityIndicator color={textColor} />
|
|
) : (
|
|
<Text style={[styles.buttonText, { color: textColor }]}>{title}</Text>
|
|
)}
|
|
</Pressable>
|
|
)
|
|
}
|
|
|
|
export function Input({ style, ...props }: TextInputProps) {
|
|
const colors = useThemeColors()
|
|
return (
|
|
<TextInput
|
|
{...props}
|
|
placeholderTextColor={colors.mutedForeground}
|
|
style={[
|
|
styles.input,
|
|
{
|
|
color: colors.foreground,
|
|
backgroundColor: colors.muted,
|
|
borderColor: colors.border,
|
|
},
|
|
style,
|
|
]}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export function Card({ children }: { children: React.ReactNode }) {
|
|
const colors = useThemeColors()
|
|
return (
|
|
<View style={[styles.card, { backgroundColor: colors.card, borderColor: colors.border }]}>
|
|
{children}
|
|
</View>
|
|
)
|
|
}
|
|
|
|
export function LoadingView() {
|
|
const colors = useThemeColors()
|
|
return (
|
|
<View style={styles.loading}>
|
|
<ActivityIndicator color={colors.foreground} size="large" />
|
|
</View>
|
|
)
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
button: {
|
|
minHeight: 44,
|
|
borderRadius: radius.md,
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
paddingHorizontal: spacing.lg,
|
|
paddingVertical: spacing.sm,
|
|
},
|
|
buttonText: {
|
|
fontSize: 16,
|
|
fontWeight: "600",
|
|
},
|
|
input: {
|
|
minHeight: 44,
|
|
borderRadius: radius.md,
|
|
borderWidth: 1,
|
|
paddingHorizontal: spacing.md,
|
|
fontSize: 16,
|
|
},
|
|
card: {
|
|
borderRadius: radius.lg,
|
|
borderWidth: 1,
|
|
padding: spacing.lg,
|
|
gap: spacing.md,
|
|
},
|
|
loading: {
|
|
flex: 1,
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
padding: spacing.xl,
|
|
},
|
|
})
|