Fix: Resolve category display and form reset issues
- Fix infinite loading: properly reset loading state in both success and error cases - Fix form not resetting: clear all fields including selectedCategory after submission - Improve category display: smaller icons (24px), better sizing, no movement on selection - Remove colorful borders: use neutral colors for better readability - Remove scale/shadow effects that caused layout shifts - Use consistent styling: minHeight instead of aspectRatio for stable layout - Apply fixes to both TransactionScreen and SubscriptionScreen
This commit is contained in:
@@ -112,15 +112,16 @@ export const SubscriptionScreen = () => {
|
|||||||
// Réinitialiser le formulaire
|
// Réinitialiser le formulaire
|
||||||
setName('');
|
setName('');
|
||||||
setAmount('');
|
setAmount('');
|
||||||
|
setSelectedCategory('');
|
||||||
setDayOfMonth('1');
|
setDayOfMonth('1');
|
||||||
setFrequency('monthly');
|
setFrequency('monthly');
|
||||||
|
setLoading(false);
|
||||||
setModalVisible(false);
|
setModalVisible(false);
|
||||||
|
|
||||||
Alert.alert('Succès', 'Abonnement ajouté avec succès');
|
Alert.alert('Succès', 'Abonnement ajouté avec succès');
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
Alert.alert('Erreur', error.message);
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
Alert.alert('Erreur', error.message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -276,8 +277,7 @@ export const SubscriptionScreen = () => {
|
|||||||
key={category.id}
|
key={category.id}
|
||||||
style={[
|
style={[
|
||||||
styles.categoryItem,
|
styles.categoryItem,
|
||||||
selectedCategory === category.name && styles.categoryItemActive,
|
selectedCategory === category.name && styles.categoryItemActive
|
||||||
{ borderColor: category.color }
|
|
||||||
]}
|
]}
|
||||||
onPress={() => setSelectedCategory(category.name)}
|
onPress={() => setSelectedCategory(category.name)}
|
||||||
>
|
>
|
||||||
@@ -420,30 +420,33 @@ const styles = StyleSheet.create({
|
|||||||
categoryGrid: {
|
categoryGrid: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
gap: 12,
|
gap: 8,
|
||||||
marginBottom: 24
|
marginBottom: 24
|
||||||
},
|
},
|
||||||
categoryItem: {
|
categoryItem: {
|
||||||
width: '30%',
|
width: '31%',
|
||||||
aspectRatio: 1,
|
paddingVertical: 12,
|
||||||
borderRadius: 12,
|
borderRadius: 8,
|
||||||
borderWidth: 2,
|
borderWidth: 1.5,
|
||||||
borderColor: '#E0E0E0',
|
borderColor: '#E0E0E0',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
backgroundColor: '#F8F9FA'
|
backgroundColor: '#FFF',
|
||||||
|
minHeight: 70
|
||||||
},
|
},
|
||||||
categoryItemActive: {
|
categoryItemActive: {
|
||||||
backgroundColor: '#FFF',
|
backgroundColor: '#F0F7FF',
|
||||||
borderWidth: 2
|
borderWidth: 2,
|
||||||
|
borderColor: '#4A90E2'
|
||||||
},
|
},
|
||||||
categoryIcon: {
|
categoryIcon: {
|
||||||
fontSize: 28,
|
fontSize: 24,
|
||||||
marginBottom: 4
|
marginBottom: 4
|
||||||
},
|
},
|
||||||
categoryName: {
|
categoryName: {
|
||||||
fontSize: 11,
|
fontSize: 10,
|
||||||
color: '#666',
|
color: '#666',
|
||||||
|
fontWeight: '500',
|
||||||
textAlign: 'center'
|
textAlign: 'center'
|
||||||
},
|
},
|
||||||
submitButton: {
|
submitButton: {
|
||||||
|
|||||||
@@ -110,15 +110,16 @@ export const TransactionScreen = ({ route, navigation }: any) => {
|
|||||||
|
|
||||||
// Réinitialiser le formulaire
|
// Réinitialiser le formulaire
|
||||||
setAmount('');
|
setAmount('');
|
||||||
|
setSelectedCategory('');
|
||||||
setNote('');
|
setNote('');
|
||||||
setDate(new Date());
|
setDate(new Date());
|
||||||
|
setLoading(false);
|
||||||
setModalVisible(false);
|
setModalVisible(false);
|
||||||
|
|
||||||
Alert.alert('Succès', 'Transaction ajoutée avec succès');
|
Alert.alert('Succès', 'Transaction ajoutée avec succès');
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
Alert.alert('Erreur', error.message);
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
Alert.alert('Erreur', error.message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -250,8 +251,7 @@ export const TransactionScreen = ({ route, navigation }: any) => {
|
|||||||
key={category.id}
|
key={category.id}
|
||||||
style={[
|
style={[
|
||||||
styles.categoryItem,
|
styles.categoryItem,
|
||||||
selectedCategory === category.name && styles.categoryItemActive,
|
selectedCategory === category.name && styles.categoryItemActive
|
||||||
{ borderColor: category.color }
|
|
||||||
]}
|
]}
|
||||||
onPress={() => setSelectedCategory(category.name)}
|
onPress={() => setSelectedCategory(category.name)}
|
||||||
>
|
>
|
||||||
@@ -404,37 +404,33 @@ const styles = StyleSheet.create({
|
|||||||
categoryGrid: {
|
categoryGrid: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
gap: 12,
|
gap: 8,
|
||||||
marginBottom: 24
|
marginBottom: 24
|
||||||
},
|
},
|
||||||
categoryItem: {
|
categoryItem: {
|
||||||
width: '30%',
|
width: '31%',
|
||||||
aspectRatio: 1,
|
paddingVertical: 12,
|
||||||
borderRadius: 12,
|
borderRadius: 8,
|
||||||
borderWidth: 2,
|
borderWidth: 1.5,
|
||||||
borderColor: '#E0E0E0',
|
borderColor: '#E0E0E0',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
backgroundColor: '#F8F9FA'
|
backgroundColor: '#FFF',
|
||||||
|
minHeight: 70
|
||||||
},
|
},
|
||||||
categoryItemActive: {
|
categoryItemActive: {
|
||||||
backgroundColor: '#FFF',
|
backgroundColor: '#F0F7FF',
|
||||||
borderWidth: 3,
|
borderWidth: 2,
|
||||||
transform: [{ scale: 1.05 }],
|
borderColor: '#4A90E2'
|
||||||
shadowColor: '#000',
|
|
||||||
shadowOffset: { width: 0, height: 2 },
|
|
||||||
shadowOpacity: 0.2,
|
|
||||||
shadowRadius: 4,
|
|
||||||
elevation: 4
|
|
||||||
},
|
},
|
||||||
categoryIcon: {
|
categoryIcon: {
|
||||||
fontSize: 28,
|
fontSize: 24,
|
||||||
marginBottom: 4
|
marginBottom: 4
|
||||||
},
|
},
|
||||||
categoryName: {
|
categoryName: {
|
||||||
fontSize: 11,
|
fontSize: 10,
|
||||||
color: '#666',
|
color: '#666',
|
||||||
fontWeight: '600',
|
fontWeight: '500',
|
||||||
textAlign: 'center'
|
textAlign: 'center'
|
||||||
},
|
},
|
||||||
submitButton: {
|
submitButton: {
|
||||||
|
|||||||
Reference in New Issue
Block a user