style: fix dark mode theme support by resolving colors from BuildContext
This commit is contained in:
parent
644da80c4e
commit
a207302193
15
lib/app.dart
15
lib/app.dart
|
|
@ -39,9 +39,10 @@ class _YnabAppState extends ConsumerState<YnabApp> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final selectedIndex = ref.watch(_selectedIndexProvider);
|
final selectedIndex = ref.watch(_selectedIndexProvider);
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final colorScheme = theme.colorScheme;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: kSurfaceBg,
|
|
||||||
bottomNavigationBar: NavigationBar(
|
bottomNavigationBar: NavigationBar(
|
||||||
selectedIndex: selectedIndex,
|
selectedIndex: selectedIndex,
|
||||||
onDestinationSelected: (int index) {
|
onDestinationSelected: (int index) {
|
||||||
|
|
@ -62,29 +63,29 @@ class _YnabAppState extends ConsumerState<YnabApp> {
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: kSurfaceBg,
|
color: colorScheme.surface,
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(color: kDivider, width: 0.5),
|
bottom: BorderSide(color: colorScheme.outlineVariant, width: 0.5),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
_navItems[selectedIndex].label,
|
_navItems[selectedIndex].label,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
color: kTextPrimary,
|
color: colorScheme.onSurface,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.add, color: kGreenAccent),
|
icon: Icon(Icons.add, color: colorScheme.primary),
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
tooltip: 'Ajouter une transaction',
|
tooltip: 'Ajouter une transaction',
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.search, color: kTextSecondary),
|
icon: Icon(Icons.search, color: colorScheme.onSurfaceVariant),
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
tooltip: 'Rechercher',
|
tooltip: 'Rechercher',
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,10 @@ class _AccountCard extends StatelessWidget {
|
||||||
width: 44,
|
width: 44,
|
||||||
height: 44,
|
height: 44,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: kSurfaceElevated,
|
color: Theme.of(context).colorScheme.primaryContainer,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
child: Icon(_icon(), color: kTextSecondary, size: 22),
|
child: Icon(_icon(), color: Theme.of(context).colorScheme.onSurfaceVariant, size: 22),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 14),
|
const SizedBox(width: 14),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|
@ -78,7 +78,7 @@ class _AccountCard extends StatelessWidget {
|
||||||
formatCurrency(account.balance),
|
formatCurrency(account.balance),
|
||||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
color: account.balance >= 0 ? kGreenAccent : kRedAccent,
|
color: account.balance >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ class _CategoryGroupTile extends ConsumerWidget {
|
||||||
Icon(
|
Icon(
|
||||||
expanded ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_right,
|
expanded ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_right,
|
||||||
size: 18,
|
size: 18,
|
||||||
color: kTextSecondary,
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(group.name,
|
Text(group.name,
|
||||||
|
|
@ -124,7 +124,7 @@ class _CategoryRow extends ConsumerWidget {
|
||||||
formatCurrency(remaining),
|
formatCurrency(remaining),
|
||||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: remaining >= 0 ? kGreenAccent : kRedAccent,
|
color: remaining >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
@ -134,9 +134,9 @@ class _CategoryRow extends ConsumerWidget {
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
child: LinearProgressIndicator(
|
child: LinearProgressIndicator(
|
||||||
value: pct,
|
value: pct,
|
||||||
backgroundColor: kDivider,
|
backgroundColor: Theme.of(context).colorScheme.outlineVariant,
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
remaining >= 0 ? kGreenAccent : kRedAccent,
|
remaining >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error,
|
||||||
),
|
),
|
||||||
minHeight: 4,
|
minHeight: 4,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class _BalanceCard extends StatelessWidget {
|
||||||
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
||||||
fontSize: 36,
|
fontSize: 36,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
color: balance >= 0 ? kGreenAccent : kRedAccent,
|
color: balance >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
@ -101,13 +101,13 @@ class _AccountMiniCard extends StatelessWidget {
|
||||||
margin: const EdgeInsets.only(bottom: 6),
|
margin: const EdgeInsets.only(bottom: 6),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
leading: Icon(_icon(), color: kTextSecondary),
|
leading: Icon(_icon(), color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||||
title: Text(account.name, style: Theme.of(context).textTheme.bodyMedium),
|
title: Text(account.name, style: Theme.of(context).textTheme.bodyMedium),
|
||||||
trailing: Text(
|
trailing: Text(
|
||||||
formatCurrency(account.balance),
|
formatCurrency(account.balance),
|
||||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: account.balance >= 0 ? kGreenAccent : kRedAccent,
|
color: account.balance >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -127,11 +127,11 @@ class _TxItem extends StatelessWidget {
|
||||||
dense: true,
|
dense: true,
|
||||||
leading: CircleAvatar(
|
leading: CircleAvatar(
|
||||||
radius: 18,
|
radius: 18,
|
||||||
backgroundColor: kSurfaceElevated,
|
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
transaction.amount >= 0 ? Icons.arrow_downward : Icons.arrow_upward,
|
transaction.amount >= 0 ? Icons.arrow_downward : Icons.arrow_upward,
|
||||||
size: 16,
|
size: 16,
|
||||||
color: transaction.amount >= 0 ? kGreenAccent : kRedAccent,
|
color: transaction.amount >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
title: Text(transaction.payee, style: Theme.of(context).textTheme.bodyMedium),
|
title: Text(transaction.payee, style: Theme.of(context).textTheme.bodyMedium),
|
||||||
|
|
@ -143,7 +143,7 @@ class _TxItem extends StatelessWidget {
|
||||||
formatCurrency(transaction.amount),
|
formatCurrency(transaction.amount),
|
||||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: transaction.amount >= 0 ? kGreenAccent : kRedAccent,
|
color: transaction.amount >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@ class TransactionsScreen extends ConsumerWidget {
|
||||||
dense: true,
|
dense: true,
|
||||||
leading: CircleAvatar(
|
leading: CircleAvatar(
|
||||||
radius: 18,
|
radius: 18,
|
||||||
backgroundColor: kSurfaceElevated,
|
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
t.amount >= 0 ? Icons.arrow_downward : Icons.arrow_upward,
|
t.amount >= 0 ? Icons.arrow_downward : Icons.arrow_upward,
|
||||||
size: 16,
|
size: 16,
|
||||||
color: t.amount >= 0 ? kGreenAccent : kRedAccent,
|
color: t.amount >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
title: Text(t.payee, style: Theme.of(context).textTheme.bodyMedium),
|
title: Text(t.payee, style: Theme.of(context).textTheme.bodyMedium),
|
||||||
|
|
@ -42,7 +42,7 @@ class TransactionsScreen extends ConsumerWidget {
|
||||||
formatCurrency(t.amount),
|
formatCurrency(t.amount),
|
||||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: t.amount >= 0 ? kGreenAccent : kRedAccent,
|
color: t.amount >= 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,14 @@ final ThemeData ynabDarkTheme = ThemeData(
|
||||||
seedColor: const Color(0xFFCAD8C3),
|
seedColor: const Color(0xFFCAD8C3),
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
),
|
),
|
||||||
|
cardTheme: CardThemeData(
|
||||||
|
elevation: 0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
side: const BorderSide(color: Color(0xFF43493E), width: 1),
|
||||||
|
),
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue