M3 compatibility: AppBar (header), ListTile in accounts, trailing simplifications

This commit is contained in:
alexis 2026-07-11 22:41:16 +02:00
parent e677e7897e
commit 1353194122
3 changed files with 57 additions and 116 deletions

View file

@ -137,41 +137,9 @@ class _YnabAppState extends ConsumerState<YnabApp> {
final colorScheme = theme.colorScheme;
return Scaffold(
bottomNavigationBar: NavigationBar(
selectedIndex: selectedIndex,
onDestinationSelected: (int index) {
setState(() {
_searchActive = false;
_searchController.clear();
ref.read(searchQueryProvider.notifier).state = '';
});
ref.read(_selectedIndexProvider.notifier).state = index;
},
destinations: _navItems.map((item) {
return NavigationDestination(
icon: Icon(item.icon),
selectedIcon: Icon(item.selectedIcon),
label: item.label,
);
}).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(
appBar: AppBar(
title: _searchActive
? TextField(
controller: _searchController,
autofocus: true,
decoration: const InputDecoration(
@ -180,18 +148,9 @@ class _YnabAppState extends ConsumerState<YnabApp> {
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(),
: Text(_navItems[selectedIndex].label),
actions: [
if (_searchActive)
IconButton(
icon: const Icon(Icons.close),
@ -212,16 +171,27 @@ class _YnabAppState extends ConsumerState<YnabApp> {
],
],
),
),
// Content
Expanded(
child: AnimatedSwitcher(
body: AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
child: _screens[selectedIndex],
),
),
],
),
bottomNavigationBar: NavigationBar(
selectedIndex: selectedIndex,
onDestinationSelected: (int index) {
setState(() {
_searchActive = false;
_searchController.clear();
ref.read(searchQueryProvider.notifier).state = '';
});
ref.read(_selectedIndexProvider.notifier).state = index;
},
destinations: _navItems.map((item) {
return NavigationDestination(
icon: Icon(item.icon),
selectedIcon: Icon(item.selectedIcon),
label: item.label,
);
}).toList(),
),
);
}

View file

@ -50,43 +50,20 @@ 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),
),
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(
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,
),
),
],
),
),
);
}

View file

@ -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(
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
);
},
);