feat(health): 新增日照时长监测卡片与 HealthKit 集成
- iOS 端集成 HealthKit 日照时间 (TimeInDaylight) 数据获取接口 - 新增 SunlightCard 组件,支持查看今日数据及最近30天历史趋势图表 - 更新统计页和自定义设置页,支持开启/关闭日照卡片 - 优化 HealthDataCard 组件,支持自定义图标组件和副标题显示 - 更新多语言文件及应用版本号至 1.1.6
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Image } from '@/components/ui/Image';
|
||||
import React from 'react';
|
||||
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
||||
import { ImageSourcePropType, Pressable, StyleSheet, Text, View } from 'react-native';
|
||||
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
|
||||
|
||||
interface HealthDataCardProps {
|
||||
@@ -9,14 +9,22 @@ interface HealthDataCardProps {
|
||||
unit: string;
|
||||
style?: object;
|
||||
onPress?: () => void;
|
||||
icon?: React.ReactNode;
|
||||
iconSource?: ImageSourcePropType;
|
||||
subtitle?: string;
|
||||
}
|
||||
|
||||
const defaultIconSource = require('@/assets/images/icons/icon-blood-oxygen.png');
|
||||
|
||||
const HealthDataCard: React.FC<HealthDataCardProps> = ({
|
||||
title,
|
||||
value,
|
||||
unit,
|
||||
style,
|
||||
onPress
|
||||
onPress,
|
||||
icon,
|
||||
iconSource,
|
||||
subtitle
|
||||
}) => {
|
||||
const Container = onPress ? Pressable : View;
|
||||
|
||||
@@ -30,13 +38,22 @@ const HealthDataCard: React.FC<HealthDataCardProps> = ({
|
||||
accessibilityHint={onPress ? `${title} details` : undefined}
|
||||
>
|
||||
<View style={styles.headerRow}>
|
||||
<Image source={require('@/assets/images/icons/icon-blood-oxygen.png')} style={styles.titleIcon} />
|
||||
{icon ? (
|
||||
<View style={styles.iconWrapper}>{icon}</View>
|
||||
) : (
|
||||
<Image source={iconSource ?? defaultIconSource} style={styles.titleIcon} />
|
||||
)}
|
||||
<Text style={styles.title}>{title}</Text>
|
||||
</View>
|
||||
<View style={styles.valueContainer}>
|
||||
<Text style={styles.value}>{value}</Text>
|
||||
<Text style={styles.unit}>{unit}</Text>
|
||||
</View>
|
||||
{subtitle ? (
|
||||
<Text style={styles.subtitle} numberOfLines={1}>
|
||||
{subtitle}
|
||||
</Text>
|
||||
) : null}
|
||||
</Container>
|
||||
</Animated.View>
|
||||
);
|
||||
@@ -66,6 +83,13 @@ const styles = StyleSheet.create({
|
||||
alignItems: 'center',
|
||||
marginBottom: 14,
|
||||
},
|
||||
iconWrapper: {
|
||||
width: 16,
|
||||
height: 16,
|
||||
marginRight: 6,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
titleIcon: {
|
||||
width: 16,
|
||||
height: 16,
|
||||
@@ -96,6 +120,12 @@ const styles = StyleSheet.create({
|
||||
fontWeight: '500',
|
||||
fontFamily: 'AliRegular',
|
||||
},
|
||||
subtitle: {
|
||||
marginTop: 6,
|
||||
fontSize: 12,
|
||||
color: '#8A8A8A',
|
||||
fontFamily: 'AliRegular',
|
||||
},
|
||||
});
|
||||
|
||||
export default HealthDataCard;
|
||||
|
||||
Reference in New Issue
Block a user