From 631555af592ffa27889a39cc44f34bc73c5e915b Mon Sep 17 00:00:00 2001 From: Hyperling Date: Fri, 7 Feb 2025 04:54:59 -0700 Subject: [PATCH] Add a dark theme. --- lib/main.dart | 6 ++++++ lib/pages/expense.dart | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 339dbd5..7c4a150 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,6 +25,12 @@ class MainApp extends StatelessWidget { useMaterial3: true, colorScheme: ColorScheme.fromSeed(seedColor: Colors.green), ), + darkTheme: ThemeData( + useMaterial3: true, + brightness: Brightness.dark, + colorSchemeSeed: Colors.green, + ), + themeMode: ThemeMode.system, home: HomePage(), ); } diff --git a/lib/pages/expense.dart b/lib/pages/expense.dart index b22d02d..397ce8a 100644 --- a/lib/pages/expense.dart +++ b/lib/pages/expense.dart @@ -23,9 +23,12 @@ class _ExpensePageState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + expenses.sort( (a, b) => (b.calcComparableCost() - a.calcComparableCost()).toInt(), ); + return expenses.isEmpty ? Text("Add expenses to get started!") : ListView.builder( @@ -53,7 +56,7 @@ class _ExpensePageState extends State { ), ), secondaryBackground: Container( - color: Colors.yellow, + color: Colors.orange, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -90,7 +93,7 @@ class _ExpensePageState extends State { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), - color: Colors.greenAccent, + color: theme.colorScheme.onPrimary, ), child: Padding( padding: const EdgeInsets.all(4.0), @@ -184,9 +187,10 @@ class _ExpenseInputDialogState extends State { ), AlertDialog( insetPadding: EdgeInsets.all(0), - title: widget.expense == null - ? Text("New Expense") - : Text("Edit Expense"), + title: Center( + child: widget.expense == null + ? Text("New Expense") + : Text("Edit Expense")), content: Form( key: _expenseFormKey, child: Column(