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, useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.green), colorScheme: ColorScheme.fromSeed(seedColor: Colors.green),
), ),
darkTheme: ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
colorSchemeSeed: Colors.green,
),
themeMode: ThemeMode.system,
home: HomePage(), home: HomePage(),
); );
} }

View File

@ -23,9 +23,12 @@ class _ExpensePageState extends State<ExpensePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context);
expenses.sort( expenses.sort(
(a, b) => (b.calcComparableCost() - a.calcComparableCost()).toInt(), (a, b) => (b.calcComparableCost() - a.calcComparableCost()).toInt(),
); );
return expenses.isEmpty return expenses.isEmpty
? Text("Add expenses to get started!") ? Text("Add expenses to get started!")
: ListView.builder( : ListView.builder(
@ -53,7 +56,7 @@ class _ExpensePageState extends State<ExpensePage> {
), ),
), ),
secondaryBackground: Container( secondaryBackground: Container(
color: Colors.yellow, color: Colors.orange,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
@ -90,7 +93,7 @@ class _ExpensePageState extends State<ExpensePage> {
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
color: Colors.greenAccent, color: theme.colorScheme.onPrimary,
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.all(4.0), padding: const EdgeInsets.all(4.0),
@ -184,9 +187,10 @@ class _ExpenseInputDialogState extends State<ExpenseInputDialog> {
), ),
AlertDialog( AlertDialog(
insetPadding: EdgeInsets.all(0), insetPadding: EdgeInsets.all(0),
title: widget.expense == null title: Center(
? Text("New Expense") child: widget.expense == null
: Text("Edit Expense"), ? Text("New Expense")
: Text("Edit Expense")),
content: Form( content: Form(
key: _expenseFormKey, key: _expenseFormKey,
child: Column( child: Column(