feat: 实现减脂体重管理App完整功能
- 实现拍照识别食物功能(集成大语言模型视觉能力) - 实现智能对话功能(集成大语言模型流式输出) - 实现食物记录和卡路里管理功能 - 实现体重记录和统计功能 - 实现健康数据管理页面 - 配置数据库表结构(用户、食物记录、体重记录) - 实现Express后端API路由 - 配置Tab导航和前端页面 - 采用健康运动配色方案
This commit is contained in:
33
client/hooks/useTheme.ts
Normal file
33
client/hooks/useTheme.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Colors } from '@/constants/theme';
|
||||
import { useColorScheme } from '@/hooks/useColorScheme';
|
||||
|
||||
enum COLOR_SCHEME_CHOICE {
|
||||
FOLLOW_SYSTEM = 'follow-system', // 跟随系统自动变化
|
||||
DARK = 'dark', // 固定为 dark 主题,不随系统变化
|
||||
LIGHT = 'light', // 固定为 light 主题,不随系统变化
|
||||
};
|
||||
|
||||
const userPreferColorScheme: COLOR_SCHEME_CHOICE = COLOR_SCHEME_CHOICE.FOLLOW_SYSTEM;
|
||||
|
||||
function getTheme(colorScheme?: 'dark' | 'light' | null) {
|
||||
const isDark = colorScheme === 'dark';
|
||||
const theme = Colors[colorScheme ?? 'light'];
|
||||
|
||||
return {
|
||||
theme,
|
||||
isDark,
|
||||
};
|
||||
}
|
||||
|
||||
function useTheme() {
|
||||
const systemColorScheme = useColorScheme()
|
||||
const colorScheme = userPreferColorScheme === COLOR_SCHEME_CHOICE.FOLLOW_SYSTEM ?
|
||||
systemColorScheme :
|
||||
userPreferColorScheme;
|
||||
|
||||
return getTheme(colorScheme);
|
||||
}
|
||||
|
||||
export {
|
||||
useTheme,
|
||||
}
|
||||
Reference in New Issue
Block a user