Make dark theme

This commit is contained in:
2025-04-21 16:28:46 +02:00
parent 9b291ac68d
commit 6f9f320362

View File

@@ -37,14 +37,64 @@ void main() async {
class JournalerApp extends StatelessWidget {
const JournalerApp({super.key});
// Define the light theme
static final ThemeData lightTheme = ThemeData(
brightness: Brightness.light,
primarySwatch: Colors.blue, // Or use ColorScheme.fromSeed(seedColor: Colors.blue)
visualDensity: VisualDensity.adaptivePlatformDensity,
scaffoldBackgroundColor: Colors.grey[100], // Slightly off-white
appBarTheme: const AppBarTheme(
backgroundColor: Colors.blue,
foregroundColor: Colors.white, // Title and icons
),
inputDecorationTheme: InputDecorationTheme(
border: const OutlineInputBorder(),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.blue.shade600, width: 2.0),
),
labelStyle: TextStyle(color: Colors.grey[700]),
),
// Add other theme properties like textTheme if needed
);
// Define the dark theme
static final ThemeData darkTheme = ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.blue, // Keep blue, or choose a different shade
// Or use ColorScheme.fromSeed(seedColor: Colors.blue, brightness: Brightness.dark)
visualDensity: VisualDensity.adaptivePlatformDensity,
scaffoldBackgroundColor: Colors.grey[900], // Dark background
appBarTheme: AppBarTheme(
backgroundColor: Colors.grey[850], // Darker app bar
foregroundColor: Colors.white, // Title and icons
),
inputDecorationTheme: InputDecorationTheme(
border: const OutlineInputBorder(
borderSide: BorderSide(color: Colors.grey), // Lighter border for dark theme
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.blue.shade300, width: 2.0),
),
labelStyle: TextStyle(color: Colors.grey[400]), // Lighter label for dark theme
// Ensure content padding is applied if needed, or use default
// contentPadding: const EdgeInsets.all(8.0), // This was in TextField, maybe move to theme?
),
// Ensure text field text color is readable
textTheme: const TextTheme(
bodyMedium: TextStyle(color: Colors.white), // Default text style
// Define other text styles as needed
),
// Define icon theme for app bar if needed, though foregroundColor often handles it
// iconTheme: const IconThemeData(color: Colors.white),
);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Journaler',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
theme: lightTheme, // Use the light theme definition
darkTheme: darkTheme, // Use the dark theme definition
themeMode: ThemeMode.system, // Automatically switch based on system settings
home: const MainPage(),
debugShowCheckedModeBanner: false,
);
@@ -275,8 +325,8 @@ class _MainPageState extends State<MainPage> with WindowListener {
readOnly: true, // Make it non-editable
decoration: const InputDecoration(
labelText: 'Previous Entry',
border: OutlineInputBorder(),
contentPadding: EdgeInsets.all(8.0),
// border: OutlineInputBorder(), // Handled by theme
// contentPadding: EdgeInsets.all(8.0), // Handled by theme or default
),
),
),
@@ -290,8 +340,8 @@ class _MainPageState extends State<MainPage> with WindowListener {
autofocus: true, // Focus here when window appears
decoration: const InputDecoration(
labelText: 'Current Entry (What\'s on your mind?)',
border: OutlineInputBorder(),
contentPadding: EdgeInsets.all(8.0),
// border: OutlineInputBorder(), // Handled by theme
// contentPadding: EdgeInsets.all(8.0), // Handled by theme or default
),
onChanged: (text) {
// Optional: Add auto-save logic here if desired
@@ -311,8 +361,8 @@ class _MainPageState extends State<MainPage> with WindowListener {
expands: true,
decoration: const InputDecoration(
labelText: 'Todo List',
border: OutlineInputBorder(),
contentPadding: EdgeInsets.all(8.0),
// border: OutlineInputBorder(), // Handled by theme
// contentPadding: EdgeInsets.all(8.0), // Handled by theme or default
),
onChanged: (text) {
// Optional: Auto-save Todo list changes