Download mobile/src/components/ui/RouteButton.tsx from Anirudh1950/MentraOS: direct link, hf CLI and curl.
- Browser
- Download file 4.18 kB
-
https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mobile/src/components/ui/RouteButton.tsx
- Command line
-
hf download hf://Anirudh1950/MentraOS/mobile/src/components/ui/RouteButton.tsx
-
curl -L -o RouteButton.tsx https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mobile/src/components/ui/RouteButton.tsx
4.18 kB
| import {router as _router} from "expo-router" | |
| import {View, Pressable, TouchableOpacity, TextStyle, ViewStyle} from "react-native" | |
| import {Icon, Text} from "@/components/ignite" | |
| import {useAppTheme} from "@/contexts/ThemeContext" | |
| import GlassView from "@/components/ui/GlassView" | |
| interface StatusCardProps { | |
| label: string | |
| text?: string | |
| style?: ViewStyle | |
| textStyle?: TextStyle | |
| iconStart?: React.ReactNode | |
| iconEnd?: React.ReactNode | |
| subtitle?: string | |
| onPress?: () => void | |
| } | |
| export function StatusCard({label, style, iconStart, iconEnd, textStyle, subtitle, onPress}: StatusCardProps) { | |
| // Extract flex from style to apply to TouchableOpacity wrapper | |
| const {flex, ...restStyle} = (style || {}) as ViewStyle & {flex?: number} | |
| const content = ( | |
| <GlassView | |
| androidShadowSize="sm" | |
| className="bg-primary-foreground px-4 py-3 flex-row justify-between items-center rounded-2xl" | |
| style={[restStyle]}> | |
| <View className="flex-row items-center gap-4"> | |
| {iconStart && <View className="justify-center items-center">{iconStart}</View>} | |
| <View className="gap-1"> | |
| <Text className="text-sm text-secondary-foreground" style={textStyle} text={label} /> | |
| {subtitle && <Text className="text-muted-foreground text-xs" text={subtitle} />} | |
| </View> | |
| </View> | |
| {iconEnd && iconEnd} | |
| </GlassView> | |
| ) | |
| if (onPress) { | |
| return ( | |
| <TouchableOpacity onPress={onPress} style={flex !== undefined ? {flex} : undefined}> | |
| {content} | |
| </TouchableOpacity> | |
| ) | |
| } | |
| if (flex !== undefined) { | |
| return <View style={{flex}}>{content}</View> | |
| } | |
| return content | |
| } | |
| interface RouteButtonProps { | |
| label: string | |
| subtitle?: string | |
| onPress?: () => void | |
| onLongPress?: () => void | |
| position?: "top" | "bottom" | "middle" | |
| text?: string | |
| style?: ViewStyle | |
| icon?: React.ReactNode | |
| preset?: "default" | "destructive" | |
| disabled?: boolean | |
| } | |
| export function RouteButton({ | |
| label, | |
| subtitle, | |
| onPress, | |
| onLongPress, | |
| style, | |
| text, | |
| icon, | |
| preset = "default", | |
| disabled = false, | |
| }: RouteButtonProps) { | |
| const {theme} = useAppTheme() | |
| const isDestructive = preset === "destructive" | |
| let labelColor = theme.colors.secondary_foreground | |
| if (disabled) labelColor = theme.colors.muted_foreground | |
| else if (isDestructive) labelColor = theme.colors.destructive | |
| return ( | |
| <GlassView | |
| androidShadowSize="sm" | |
| className="bg-primary-foreground px-4 rounded-2xl" | |
| style={[disabled && {opacity: 0.5}, style]}> | |
| <Pressable | |
| onPress={onPress} | |
| onAccessibilityTap={() => { | |
| if (!disabled) onPress?.() | |
| }} | |
| onLongPress={onLongPress} | |
| disabled={disabled || !onPress} | |
| hitSlop={4} | |
| style={({pressed}) => ({opacity: pressed ? 0.2 : 1})}> | |
| <View className="items-center py-2 flex-row"> | |
| <View | |
| style={{ | |
| flexDirection: "column", | |
| paddingVertical: 8, | |
| flex: 1, | |
| gap: theme.spacing.s1, | |
| }}> | |
| <View className="flex-row items-center gap-4"> | |
| {icon && <View className="justify-center items-center">{icon}</View>} | |
| <Text style={{color: labelColor}} className="text-sm text-secondary-foreground" text={label} /> | |
| </View> | |
| {subtitle && <Text className="text-muted-foreground text-xs" text={subtitle} />} | |
| </View> | |
| {onPress && ( | |
| <View className="bg-background rounded-full p-3 w-12 h-12 ml-3 flex-shrink-0"> | |
| <Icon | |
| name="arrow-right" | |
| size={24} | |
| color={disabled ? theme.colors.muted_foreground : theme.colors.foreground} | |
| /> | |
| </View> | |
| )} | |
| {text && ( | |
| <Text | |
| className="text-text text-base flex-shrink-0 font-light ml-3 text-ellipsis max-w-[70%] align-center justify-center" | |
| text={text} | |
| /> | |
| )} | |
| </View> | |
| </Pressable> | |
| </GlassView> | |
| ) | |
| } | |