Add a dark theme.

This commit is contained in:
Hyperling 2025-02-07 04:54:59 -07:00
parent 0f65166123
commit 631555af59
2 changed files with 15 additions and 5 deletions

View File

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

View File

@ -23,9 +23,12 @@ class _ExpensePageState extends State<ExpensePage> {
@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<ExpensePage> {
),
),
secondaryBackground: Container(
color: Colors.yellow,
color: Colors.orange,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
@ -90,7 +93,7 @@ class _ExpensePageState extends State<ExpensePage> {
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<ExpenseInputDialog> {
),
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(