Refactor components and enhance background task management

- Updated font sizes and weights in BasalMetabolismCard, MoodCard, HealthDataCard, and NutritionRadarCard for improved readability.
- Removed loading state from MoodCard to simplify the component.
- Adjusted styles in WeightHistoryCard for better layout and spacing.
- Integrated expo-background-fetch for improved background task handling.
- Updated Info.plist to include background fetch capability.
- Enhanced background task registration and execution logic in backgroundTaskManager.
- Added debug function to manually trigger background task execution for testing purposes.
This commit is contained in:
richarjiang
2025-09-03 16:17:29 +08:00
parent 16b4fc8816
commit 8b9689b269
17 changed files with 163 additions and 85 deletions

View File

@@ -133,14 +133,13 @@ const styles = StyleSheet.create({
zIndex: 1,
},
value: {
fontSize: 24,
fontWeight: '800',
fontSize: 16,
fontWeight: '600',
color: '#0F172A',
lineHeight: 28,
},
unit: {
fontSize: 14,
fontWeight: '500',
fontSize: 12,
color: '#64748B',
marginLeft: 6,
},

View File

@@ -182,7 +182,7 @@ export const DateSelector: React.FC<DateSelectorProps> = ({
const styles = StyleSheet.create({
container: {
paddingVertical: 8,
},
monthTitle: {
fontSize: 18,

View File

@@ -10,7 +10,7 @@ interface MoodCardProps {
isLoading?: boolean;
}
export function MoodCard({ moodCheckin, onPress, isLoading = false }: MoodCardProps) {
export function MoodCard({ moodCheckin, onPress }: MoodCardProps) {
const moodConfig = moodCheckin ? getMoodConfig(moodCheckin.moodType) : null;
const animationRef = useRef<LottieView>(null);
@@ -21,7 +21,7 @@ export function MoodCard({ moodCheckin, onPress, isLoading = false }: MoodCardPr
}, []);
return (
<TouchableOpacity onPress={onPress} style={styles.moodCardContent} disabled={isLoading}>
<TouchableOpacity onPress={onPress} style={styles.moodCardContent} >
<View style={styles.moodCardHeader}>
<Text style={styles.cardTitle}></Text>
<LottieView
@@ -32,11 +32,7 @@ export function MoodCard({ moodCheckin, onPress, isLoading = false }: MoodCardPr
style={styles.lottieAnimation}
/>
</View>
{isLoading ? (
<View style={styles.moodPreview}>
<Text style={styles.moodLoadingText}>...</Text>
</View>
) : moodCheckin ? (
{moodCheckin ? (
<View style={styles.moodPreview}>
<Text style={styles.moodPreviewText}>
{moodConfig?.label || moodCheckin.moodType}
@@ -69,8 +65,8 @@ const styles = StyleSheet.create({
},
lottieAnimation: {
width: 40,
height: 40,
width: 30,
height: 30,
},
moodPreview: {

View File

@@ -210,6 +210,7 @@ const styles = StyleSheet.create({
shadowOpacity: 0.1,
shadowRadius: 3.84,
elevation: 5,
marginTop: 12
},
cardHeader: {
flexDirection: 'row',
@@ -300,7 +301,7 @@ const styles = StyleSheet.create({
gap: 4,
},
mainValue: {
fontSize: 12,
fontSize: 14,
fontWeight: '600',
color: '#192126',
},
@@ -320,7 +321,7 @@ const styles = StyleSheet.create({
fontWeight: '500',
},
calculationValue: {
fontSize: 9,
fontSize: 11,
fontWeight: '700',
color: '#192126',
},

View File

@@ -61,12 +61,12 @@ const styles = StyleSheet.create({
alignItems: 'flex-end',
},
value: {
fontSize: 20,
fontSize: 16,
fontWeight: '600',
color: '#192126',
},
unit: {
fontSize: 14,
fontSize: 12,
color: '#666',
marginLeft: 4,
marginBottom: 2,

View File

@@ -195,19 +195,6 @@ export function WeightHistoryCard() {
};
});
// 如果正在加载,显示加载状态
if (isLoading) {
return (
<TouchableOpacity style={styles.card} onPress={navigateToWeightRecords} activeOpacity={0.8}>
<View style={styles.cardHeader}>
<Text style={styles.cardTitle}></Text>
</View>
<View style={styles.emptyContent}>
<Text style={styles.emptyDescription}>...</Text>
</View>
</TouchableOpacity>
);
}
// 如果没有体重数据,显示引导卡片
if (!hasWeight) {
@@ -574,6 +561,7 @@ const styles = StyleSheet.create({
shadowOpacity: 0.1,
shadowRadius: 8,
elevation: 3,
marginTop: 16
},
cardHeader: {
flexDirection: 'row',
@@ -649,6 +637,7 @@ const styles = StyleSheet.create({
summaryInfo: {
position: 'absolute',
width: '100%',
marginTop: 10,
},
chartContainer: {
position: 'absolute',