添加了药物管理的核心功能,包括: - 药物列表展示和状态管理 - 添加新药物的完整流程 - 服药记录的创建和状态更新 - 药物管理界面,支持激活/停用操作 - Redux状态管理和API服务层 - 相关类型定义和辅助函数 主要文件: - app/(tabs)/medications.tsx - 主界面,集成Redux数据 - app/medications/add-medication.tsx - 添加药物流程 - app/medications/manage-medications.tsx - 药物管理界面 - store/medicationsSlice.ts - Redux状态管理 - services/medications.ts - API服务层 - types/medication.ts - 类型定义
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
// Fallback for using MaterialIcons on Android and web.
|
|
|
|
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
|
import { SymbolViewProps, SymbolWeight } from 'expo-symbols';
|
|
import { ComponentProps } from 'react';
|
|
import { OpaqueColorValue, type StyleProp, type TextStyle } from 'react-native';
|
|
|
|
type IconMapping = Record<SymbolViewProps['name'], ComponentProps<typeof MaterialIcons>['name']>;
|
|
type IconSymbolName = keyof typeof MAPPING;
|
|
|
|
/**
|
|
* Add your SF Symbols to Material Icons mappings here.
|
|
* - see Material Icons in the [Icons Directory](https://icons.expo.fyi).
|
|
* - see SF Symbols in the [SF Symbols](https://developer.apple.com/sf-symbols/) app.
|
|
*/
|
|
const MAPPING = {
|
|
'house.fill': 'home',
|
|
'paperplane.fill': 'send',
|
|
'chevron.left.forwardslash.chevron.right': 'code',
|
|
'chevron.right': 'chevron-right',
|
|
'chart.pie.fill': 'pie-chart',
|
|
'flag.fill': 'flag',
|
|
'trophy.fill': 'emoji-events',
|
|
'timer': 'timer',
|
|
'person.fill': 'person',
|
|
'plus': 'add',
|
|
'pills.fill': 'medication',
|
|
'person.3.fill': 'people',
|
|
'message.fill': 'message',
|
|
'info.circle': 'info',
|
|
'magnifyingglass': 'search',
|
|
'xmark': 'close',
|
|
} as IconMapping;
|
|
|
|
/**
|
|
* An icon component that uses native SF Symbols on iOS, and Material Icons on Android and web.
|
|
* This ensures a consistent look across platforms, and optimal resource usage.
|
|
* Icon `name`s are based on SF Symbols and require manual mapping to Material Icons.
|
|
*/
|
|
export function IconSymbol({
|
|
name,
|
|
size = 24,
|
|
color,
|
|
style,
|
|
}: {
|
|
name: IconSymbolName;
|
|
size?: number;
|
|
color: string | OpaqueColorValue;
|
|
style?: StyleProp<TextStyle>;
|
|
weight?: SymbolWeight;
|
|
}) {
|
|
return <MaterialIcons color={color} size={size} name={MAPPING[name]} style={style} />;
|
|
}
|