M3 compatibility: AppBar (header), ListTile in accounts, trailing simplifications
This commit is contained in:
parent
e677e7897e
commit
1353194122
106
lib/app.dart
106
lib/app.dart
|
|
@ -137,6 +137,44 @@ class _YnabAppState extends ConsumerState<YnabApp> {
|
|||
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<YnabApp> {
|
|||
);
|
||||
}).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],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue