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;
|
final colorScheme = theme.colorScheme;
|
||||||
|
|
||||||
return Scaffold(
|
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(
|
bottomNavigationBar: NavigationBar(
|
||||||
selectedIndex: selectedIndex,
|
selectedIndex: selectedIndex,
|
||||||
onDestinationSelected: (int index) {
|
onDestinationSelected: (int index) {
|
||||||
|
|
@ -155,74 +193,6 @@ class _YnabAppState extends ConsumerState<YnabApp> {
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).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) {
|
Widget build(BuildContext context) {
|
||||||
return Card(
|
return Card(
|
||||||
margin: const EdgeInsets.only(bottom: 8),
|
margin: const EdgeInsets.only(bottom: 8),
|
||||||
child: Padding(
|
child: ListTile(
|
||||||
padding: const EdgeInsets.all(16),
|
leading: CircleAvatar(
|
||||||
child: Row(
|
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
||||||
children: [
|
child: Icon(_icon(), color: Theme.of(context).colorScheme.onSurfaceVariant, size: 22),
|
||||||
Container(
|
),
|
||||||
width: 44,
|
title: Text(account.name, style: Theme.of(context).textTheme.bodyMedium?.copyWith(fontWeight: FontWeight.w600)),
|
||||||
height: 44,
|
subtitle: Text(_label(), style: Theme.of(context).textTheme.bodySmall),
|
||||||
decoration: BoxDecoration(
|
trailing: Text(
|
||||||
color: Theme.of(context).colorScheme.primaryContainer,
|
formatCurrency(account.balance),
|
||||||
borderRadius: BorderRadius.circular(12),
|
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),
|
DateFormat('dd/MM/yy').format(t.date),
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
),
|
),
|
||||||
trailing: Column(
|
trailing: Text(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
formatCurrency(t.amount),
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
children: [
|
fontWeight: FontWeight.w600,
|
||||||
Text(
|
color: t.amount >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error,
|
||||||
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