feat: Implement account management features
- Added ExpenseDetailDialog for displaying expense details and actions. - Created ExpensesTab to list expenses for a group. - Developed GroupExpensesPage to manage group expenses with tabs for expenses, balances, and settlements. - Introduced SettlementsTab to show optimized repayment plans. - Refactored create_trip_content.dart to remove CountBloc and related logic. - Added Account model to manage user accounts and group members. - Replaced CountRepository with AccountRepository for account-related operations. - Removed CountService and CountRepository as part of the refactor. - Updated main.dart and home.dart to integrate new account management components.
This commit is contained in:
124
lib/components/account/balances_tab.dart
Normal file
124
lib/components/account/balances_tab.dart
Normal file
@@ -0,0 +1,124 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../data/models/balance.dart';
|
||||
|
||||
class BalancesTab extends StatelessWidget {
|
||||
final List<Balance> balances;
|
||||
|
||||
const BalancesTab({
|
||||
super.key,
|
||||
required this.balances,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (balances.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('Aucune balance à afficher'),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: balances.length,
|
||||
itemBuilder: (context, index) {
|
||||
final balance = balances[index];
|
||||
return _buildBalanceCard(context, balance);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBalanceCard(BuildContext context, Balance balance) {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
Color balanceColor;
|
||||
IconData balanceIcon;
|
||||
String balanceText;
|
||||
|
||||
if (balance.shouldReceive) {
|
||||
balanceColor = Colors.green;
|
||||
balanceIcon = Icons.arrow_downward;
|
||||
balanceText = 'À recevoir';
|
||||
} else if (balance.shouldPay) {
|
||||
balanceColor = Colors.red;
|
||||
balanceIcon = Icons.arrow_upward;
|
||||
balanceText = 'À payer';
|
||||
} else {
|
||||
balanceColor = Colors.grey;
|
||||
balanceIcon = Icons.check_circle;
|
||||
balanceText = 'Équilibré';
|
||||
}
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: isDark ? Colors.grey[800] : Colors.grey[200],
|
||||
child: Text(
|
||||
balance.userName.isNotEmpty
|
||||
? balance.userName[0].toUpperCase()
|
||||
: '?',
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
balance.userName,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'Payé: ${balance.totalPaid.toStringAsFixed(2)} € • Doit: ${balance.totalOwed.toStringAsFixed(2)} €',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(balanceIcon, size: 16, color: balanceColor),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'${balance.absoluteBalance.toStringAsFixed(2)} €',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: balanceColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
balanceText,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: balanceColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user