From 1353194122bf255996d5551894c84076e72dbad8 Mon Sep 17 00:00:00 2001 From: alexis Date: Sat, 11 Jul 2026 22:41:16 +0200 Subject: [PATCH] M3 compatibility: AppBar (header), ListTile in accounts, trailing simplifications --- lib/app.dart | 106 ++++++++++----------------- lib/screens/accounts_screen.dart | 47 +++--------- lib/screens/transactions_screen.dart | 20 ++--- 3 files changed, 57 insertions(+), 116 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index 3a0df12..0ca07f7 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -137,6 +137,44 @@ class _YnabAppState extends ConsumerState { final colorScheme = theme.colorScheme; return Scaffold( + appBar: AppBar( + title: _searchActive + ? TextField( + controller: _searchController, + autofocus: true, + decoration: const InputDecoration( + hintText: 'Rechercher…', + border: InputBorder.none, + isDense: true, + ), + onChanged: (v) => ref.read(searchQueryProvider.notifier).state = v, + ) + : Text(_navItems[selectedIndex].label), + actions: [ + if (_searchActive) + IconButton( + icon: const Icon(Icons.close), + onPressed: _toggleSearch, + tooltip: 'Fermer la recherche', + ) + else ...[ + IconButton( + icon: Icon(Icons.add, color: colorScheme.primary), + onPressed: _addTransaction, + tooltip: 'Ajouter une transaction', + ), + IconButton( + icon: Icon(Icons.search, color: colorScheme.onSurfaceVariant), + onPressed: _toggleSearch, + tooltip: 'Rechercher', + ), + ], + ], + ), + body: AnimatedSwitcher( + duration: const Duration(milliseconds: 200), + child: _screens[selectedIndex], + ), bottomNavigationBar: NavigationBar( selectedIndex: selectedIndex, onDestinationSelected: (int index) { @@ -155,74 +193,6 @@ class _YnabAppState extends ConsumerState { ); }).toList(), ), - body: SafeArea( - child: Column( - children: [ - // Header - Container( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12), - decoration: BoxDecoration( - color: colorScheme.surface, - border: Border( - bottom: BorderSide(color: colorScheme.outlineVariant, width: 0.5), - ), - ), - child: Row( - children: [ - if (_searchActive) - Expanded( - child: TextField( - controller: _searchController, - autofocus: true, - decoration: const InputDecoration( - hintText: 'Rechercher…', - border: InputBorder.none, - isDense: true, - ), - onChanged: (v) => ref.read(searchQueryProvider.notifier).state = v, - ), - ) - else - Text( - _navItems[selectedIndex].label, - style: TextStyle( - color: colorScheme.onSurface, - fontSize: 18, - fontWeight: FontWeight.w600, - ), - ), - const Spacer(), - if (_searchActive) - IconButton( - icon: const Icon(Icons.close), - onPressed: _toggleSearch, - tooltip: 'Fermer la recherche', - ) - else ...[ - IconButton( - icon: Icon(Icons.add, color: colorScheme.primary), - onPressed: _addTransaction, - tooltip: 'Ajouter une transaction', - ), - IconButton( - icon: Icon(Icons.search, color: colorScheme.onSurfaceVariant), - onPressed: _toggleSearch, - tooltip: 'Rechercher', - ), - ], - ], - ), - ), - // Content - Expanded( - child: AnimatedSwitcher( - duration: const Duration(milliseconds: 200), - child: _screens[selectedIndex], - ), - ), - ], - ), - ), ); } } diff --git a/lib/screens/accounts_screen.dart b/lib/screens/accounts_screen.dart index ce8d461..9f860be 100644 --- a/lib/screens/accounts_screen.dart +++ b/lib/screens/accounts_screen.dart @@ -50,42 +50,19 @@ class _AccountCard extends StatelessWidget { Widget build(BuildContext context) { return Card( margin: const EdgeInsets.only(bottom: 8), - child: Padding( - padding: const EdgeInsets.all(16), - child: Row( - children: [ - Container( - width: 44, - height: 44, - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primaryContainer, - borderRadius: BorderRadius.circular(12), + child: ListTile( + leading: CircleAvatar( + backgroundColor: Theme.of(context).colorScheme.primaryContainer, + child: Icon(_icon(), color: Theme.of(context).colorScheme.onSurfaceVariant, size: 22), + ), + title: Text(account.name, style: Theme.of(context).textTheme.bodyMedium?.copyWith(fontWeight: FontWeight.w600)), + subtitle: Text(_label(), style: Theme.of(context).textTheme.bodySmall), + trailing: Text( + formatCurrency(account.balance), + style: Theme.of(context).textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.w700, + color: account.balance >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error, ), - child: Icon(_icon(), color: Theme.of(context).colorScheme.onSurfaceVariant, size: 22), - ), - const SizedBox(width: 14), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(account.name, - style: Theme.of(context) - .textTheme - .bodyMedium - ?.copyWith(fontWeight: FontWeight.w600)), - const SizedBox(height: 2), - Text(_label(), style: Theme.of(context).textTheme.bodySmall), - ], - ), - ), - Text( - formatCurrency(account.balance), - style: Theme.of(context).textTheme.titleMedium?.copyWith( - fontWeight: FontWeight.w700, - color: account.balance >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error, - ), - ), - ], ), ), ); diff --git a/lib/screens/transactions_screen.dart b/lib/screens/transactions_screen.dart index 2876912..45d5d5e 100644 --- a/lib/screens/transactions_screen.dart +++ b/lib/screens/transactions_screen.dart @@ -36,20 +36,14 @@ class TransactionsScreen extends ConsumerWidget { DateFormat('dd/MM/yy').format(t.date), style: Theme.of(context).textTheme.bodySmall, ), - trailing: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - formatCurrency(t.amount), - style: Theme.of(context).textTheme.bodyMedium?.copyWith( - fontWeight: FontWeight.w600, - color: t.amount >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error, - ), - ), - ], + trailing: Text( + formatCurrency(t.amount), + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + color: t.amount >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error, + ), ), - ), + ), // ListTile ); }, );