feat: 新增体重记录功能,优化用户资料更新及图片组件缓存
This commit is contained in:
@@ -59,8 +59,6 @@ const ActivityHeatMap = () => {
|
||||
return data;
|
||||
}, [activityData, weeksToShow]);
|
||||
|
||||
console.log('generateActivityData', generateActivityData);
|
||||
|
||||
|
||||
// 根据活跃度计算颜色 - 优化配色方案
|
||||
const getActivityColor = (level: number): string => {
|
||||
|
||||
@@ -54,13 +54,13 @@ export function WeightHistoryCard() {
|
||||
|
||||
const hasWeight = userProfile?.weight && parseFloat(userProfile.weight) > 0;
|
||||
const hasHeight = userProfile?.height && parseFloat(userProfile.height) > 0;
|
||||
|
||||
|
||||
// BMI 计算
|
||||
const canCalculate = canCalculateBMI(
|
||||
userProfile?.weight ? parseFloat(userProfile.weight) : undefined,
|
||||
userProfile?.height ? parseFloat(userProfile.height) : undefined
|
||||
);
|
||||
|
||||
|
||||
const bmiResult = canCalculate && userProfile?.weight && userProfile?.height
|
||||
? getBMIResult(parseFloat(userProfile.weight), parseFloat(userProfile.height))
|
||||
: null;
|
||||
@@ -95,6 +95,10 @@ export function WeightHistoryCard() {
|
||||
};
|
||||
|
||||
// 切换图表显示状态的动画函数
|
||||
const navigateToWeightRecords = () => {
|
||||
pushIfAuthedElseLogin(ROUTES.WEIGHT_RECORDS);
|
||||
};
|
||||
|
||||
const toggleChart = () => {
|
||||
if (isAnimating) return; // 防止动画期间重复触发
|
||||
|
||||
@@ -195,7 +199,7 @@ export function WeightHistoryCard() {
|
||||
// 如果正在加载,显示加载状态
|
||||
if (isLoading) {
|
||||
return (
|
||||
<View style={styles.card}>
|
||||
<TouchableOpacity style={styles.card} onPress={navigateToWeightRecords} activeOpacity={0.8}>
|
||||
<View style={styles.cardHeader}>
|
||||
<View style={styles.iconSquare}>
|
||||
<Image source={require('@/assets/images/icons/iconWeight.png')} style={{ width: 18, height: 18 }} />
|
||||
@@ -205,14 +209,14 @@ export function WeightHistoryCard() {
|
||||
<View style={styles.emptyContent}>
|
||||
<Text style={styles.emptyDescription}>加载中...</Text>
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
// 如果没有体重数据,显示引导卡片
|
||||
if (!hasWeight) {
|
||||
return (
|
||||
<View style={styles.card}>
|
||||
<TouchableOpacity style={styles.card} onPress={navigateToWeightRecords} activeOpacity={0.8}>
|
||||
<View style={styles.cardHeader}>
|
||||
<View style={styles.iconSquare}>
|
||||
<Image source={require('@/assets/images/icons/iconWeight.png')} style={{ width: 18, height: 18 }} />
|
||||
@@ -227,14 +231,17 @@ export function WeightHistoryCard() {
|
||||
</Text>
|
||||
<TouchableOpacity
|
||||
style={styles.recordButton}
|
||||
onPress={navigateToCoach}
|
||||
onPress={(e) => {
|
||||
e.stopPropagation();
|
||||
navigateToCoach();
|
||||
}}
|
||||
activeOpacity={0.8}
|
||||
>
|
||||
<Ionicons name="add" size={18} color="#192126" />
|
||||
<Text style={styles.recordButtonText}>记录</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -245,7 +252,7 @@ export function WeightHistoryCard() {
|
||||
|
||||
if (sortedHistory.length === 0) {
|
||||
return (
|
||||
<View style={styles.card}>
|
||||
<TouchableOpacity style={styles.card} onPress={navigateToWeightRecords} activeOpacity={0.8}>
|
||||
<View style={styles.cardHeader}>
|
||||
<View style={styles.iconSquare}>
|
||||
<Image source={require('@/assets/images/icons/iconWeight.png')} style={{ width: 18, height: 18 }} />
|
||||
@@ -259,14 +266,17 @@ export function WeightHistoryCard() {
|
||||
</Text>
|
||||
<TouchableOpacity
|
||||
style={styles.recordButton}
|
||||
onPress={navigateToCoach}
|
||||
onPress={(e) => {
|
||||
e.stopPropagation();
|
||||
navigateToCoach();
|
||||
}}
|
||||
activeOpacity={0.8}
|
||||
>
|
||||
<Ionicons name="add" size={18} color="#FFFFFF" />
|
||||
<Text style={styles.recordButtonText}>记录体重</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -296,7 +306,7 @@ export function WeightHistoryCard() {
|
||||
pathData;
|
||||
|
||||
return (
|
||||
<View style={styles.card}>
|
||||
<TouchableOpacity style={styles.card} onPress={navigateToWeightRecords} activeOpacity={0.8}>
|
||||
<View style={styles.cardHeader}>
|
||||
<View style={styles.iconSquare}>
|
||||
<Image source={require('@/assets/images/icons/iconWeight.png')} style={{ width: 18, height: 18 }} />
|
||||
@@ -305,7 +315,10 @@ export function WeightHistoryCard() {
|
||||
<View style={styles.headerButtons}>
|
||||
<TouchableOpacity
|
||||
style={styles.chartToggleButton}
|
||||
onPress={toggleChart}
|
||||
onPress={(e) => {
|
||||
e.stopPropagation();
|
||||
toggleChart();
|
||||
}}
|
||||
activeOpacity={0.8}
|
||||
>
|
||||
<Ionicons
|
||||
@@ -316,7 +329,10 @@ export function WeightHistoryCard() {
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
style={styles.addButton}
|
||||
onPress={navigateToCoach}
|
||||
onPress={(e) => {
|
||||
e.stopPropagation();
|
||||
navigateToCoach();
|
||||
}}
|
||||
activeOpacity={0.8}
|
||||
>
|
||||
<Ionicons name="add" size={16} color={Colors.light.primary} />
|
||||
@@ -352,7 +368,10 @@ export function WeightHistoryCard() {
|
||||
{bmiResult.value}
|
||||
</Text>
|
||||
<TouchableOpacity
|
||||
onPress={handleShowBMIModal}
|
||||
onPress={(e) => {
|
||||
e.stopPropagation();
|
||||
handleShowBMIModal();
|
||||
}}
|
||||
style={styles.bmiInfoButton}
|
||||
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
||||
>
|
||||
@@ -499,7 +518,7 @@ export function WeightHistoryCard() {
|
||||
{BMI_CATEGORIES.map((category, index) => {
|
||||
const colors = [
|
||||
{ bg: '#FEF3C7', text: '#B45309', border: '#F59E0B' }, // 偏瘦
|
||||
{ bg: '#E8F5E8', text: Colors.light.accentGreenDark, border: Colors.light.accentGreen }, // 正常
|
||||
{ bg: '#E8F5E8', text: Colors.light.accentGreen, border: Colors.light.accentGreen }, // 正常
|
||||
{ bg: '#FEF3C7', text: '#B45309', border: '#F59E0B' }, // 超重
|
||||
{ bg: '#FEE2E2', text: '#B91C1C', border: '#EF4444' } // 肥胖
|
||||
][index];
|
||||
@@ -563,7 +582,7 @@ export function WeightHistoryCard() {
|
||||
</View>
|
||||
</LinearGradient>
|
||||
</Modal>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -711,7 +730,7 @@ const styles = StyleSheet.create({
|
||||
fontWeight: '700',
|
||||
color: '#192126',
|
||||
},
|
||||
|
||||
|
||||
// BMI 相关样式
|
||||
bmiValueContainer: {
|
||||
flexDirection: 'row',
|
||||
@@ -734,7 +753,7 @@ const styles = StyleSheet.create({
|
||||
fontSize: 10,
|
||||
fontWeight: '700',
|
||||
},
|
||||
|
||||
|
||||
// BMI 弹窗样式
|
||||
bmiModalContainer: {
|
||||
flex: 1,
|
||||
Reference in New Issue
Block a user