Implement message deletion functionality: add isDeleted flag to Message model, update deleteMessage method in MessageRepository, and adjust chat display for deleted messages.
This commit is contained in:
@@ -28,8 +28,9 @@ import '../../blocs/account/account_state.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:travel_mate/components/error/error_content.dart';
|
||||
import '../../blocs/user/user_state.dart' as user_state;
|
||||
import '../../repositories/group_repository.dart'; // Ajouter cet import
|
||||
import 'group_expenses_page.dart'; // Ajouter cet import
|
||||
import '../../repositories/group_repository.dart';
|
||||
import '../widgets/user_state_widget.dart';
|
||||
import 'group_expenses_page.dart';
|
||||
|
||||
/// Widget that displays the account content page with account management functionality.
|
||||
class AccountContent extends StatefulWidget {
|
||||
@@ -132,33 +133,13 @@ class _AccountContentState extends State<AccountContent> {
|
||||
/// Widget representing the complete account page UI
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<UserBloc, user_state.UserState>(
|
||||
builder: (context, userState) {
|
||||
if (userState is user_state.UserLoading) {
|
||||
return const Scaffold(
|
||||
body: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
|
||||
if (userState is user_state.UserError) {
|
||||
return ErrorContent(
|
||||
message: 'User error: ${userState.message}',
|
||||
onRetry: () {},
|
||||
);
|
||||
}
|
||||
|
||||
if (userState is! user_state.UserLoaded) {
|
||||
return const Scaffold(
|
||||
body: Center(child: Text('User not connected')),
|
||||
);
|
||||
}
|
||||
final user = userState.user;
|
||||
|
||||
return UserStateWrapper(
|
||||
builder: (context, user) {
|
||||
return BlocConsumer<AccountBloc, AccountState>(
|
||||
listener: (context, accountState) {
|
||||
if (accountState is AccountError) {
|
||||
ErrorContent(
|
||||
message: 'Account loading error: ${accountState.message}',
|
||||
message: 'Erreur de chargement des comptes : ${accountState.message}',
|
||||
onRetry: () {
|
||||
context.read<AccountBloc>().add(LoadAccountsByUserId(user.id));
|
||||
},
|
||||
@@ -167,11 +148,21 @@ class _AccountContentState extends State<AccountContent> {
|
||||
},
|
||||
builder: (context, accountState) {
|
||||
return Scaffold(
|
||||
body: SafeArea(child: _buildContent(accountState, user.id))
|
||||
);
|
||||
body: SafeArea(child: _buildContent(accountState, user.id)),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
},
|
||||
loadingWidget: const Scaffold(
|
||||
body: Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
errorWidget: ErrorContent(
|
||||
message: 'User error',
|
||||
onRetry: () {},
|
||||
),
|
||||
noUserWidget: const Scaffold(
|
||||
body: Center(child: Text('Utilisateur non connecté')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -196,7 +187,7 @@ class _AccountContentState extends State<AccountContent> {
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(height: 16),
|
||||
Text('Loading accounts...'),
|
||||
Text('Chargement des comptes...'),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -204,7 +195,7 @@ class _AccountContentState extends State<AccountContent> {
|
||||
|
||||
if (accountState is AccountError) {
|
||||
return ErrorContent(
|
||||
message: 'Account loading error...',
|
||||
message: 'Erreur de chargement des comptes...',
|
||||
onRetry: () {
|
||||
context.read<AccountBloc>().add(LoadAccountsByUserId(userId));
|
||||
},
|
||||
@@ -222,13 +213,13 @@ class _AccountContentState extends State<AccountContent> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text('Unknown state'),
|
||||
const Text('État inconnu'),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
context.read<AccountBloc>().add(LoadAccountsByUserId(userId));
|
||||
},
|
||||
child: const Text('Load accounts'),
|
||||
child: const Text('Charger les comptes'),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -258,7 +249,7 @@ class _AccountContentState extends State<AccountContent> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'Accounts are automatically created when you create a trip',
|
||||
'Les comptes sont créés automatiquement lorsque vous créez des voyages.',
|
||||
style: TextStyle(fontSize: 14, color: Colors.grey),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
@@ -289,18 +280,7 @@ class _AccountContentState extends State<AccountContent> {
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
const Text(
|
||||
'My accounts',
|
||||
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Manage your travel accounts',
|
||||
style: TextStyle(fontSize: 14, color: Colors.grey[600]),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
...accounts.map((account) {
|
||||
...accounts.map((account) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: _buildSimpleAccountCard(account),
|
||||
|
||||
Reference in New Issue
Block a user