import { Colors } from '@/constants/Colors'; import { useColorScheme } from '@/hooks/useColorScheme'; import React from 'react'; import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; export type TimeTabType = 'day' | 'week' | 'month'; interface TimeTabSelectorProps { selectedTab: TimeTabType; onTabChange: (tab: TimeTabType) => void; } interface TabOption { key: TimeTabType; label: string; } const tabOptions: TabOption[] = [ { key: 'day', label: '按天' }, { key: 'week', label: '按周' }, { key: 'month', label: '按月' }, ]; export function TimeTabSelector({ selectedTab, onTabChange }: TimeTabSelectorProps) { const theme = useColorScheme() ?? 'light'; const colorTokens = Colors[theme]; return ( {tabOptions.map((option) => { const isSelected = selectedTab === option.key; return ( onTabChange(option.key)} activeOpacity={0.7} > {option.label} ); })} ); } const styles = StyleSheet.create({ container: { paddingHorizontal: 20, paddingVertical: 16, }, tabContainer: { flexDirection: 'row', borderRadius: 12, padding: 4, shadowColor: '#000', shadowOffset: { width: 0, height: 2, }, shadowOpacity: 0.05, shadowRadius: 4, elevation: 2, }, tab: { paddingVertical: 12, paddingHorizontal: 32, borderRadius: 16, justifyContent: 'center', alignItems: 'center', }, tabText: { fontSize: 14, textAlign: 'center', }, });