diff --git a/lib/constants/themes.dart b/lib/constants/themes.dart new file mode 100644 index 0000000..c0c5fab --- /dev/null +++ b/lib/constants/themes.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; + +final LIGHT_THEME = ThemeData( + textTheme: ThemeData().textTheme.copyWith( + headline1: const TextStyle( + fontSize: 32, + fontWeight: FontWeight.w500, + ), + ), + inputDecorationTheme: InputDecorationTheme( + filled: true, + helperMaxLines: 10, + errorMaxLines: 10, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + ), + ), +); + +final DARK_THEME = ThemeData.dark().copyWith( + textTheme: ThemeData.dark().textTheme.copyWith( + headline1: const TextStyle( + fontSize: 32, + fontWeight: FontWeight.w500, + ), + ), + inputDecorationTheme: InputDecorationTheme( + filled: true, + helperMaxLines: 10, + errorMaxLines: 10, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + ), + ), +); diff --git a/lib/main.dart b/lib/main.dart index 4a6fa10..fc0f411 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,6 +2,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; +import 'package:quid_faciam_hodie/constants/themes.dart'; import 'package:quid_faciam_hodie/screens/calendar_screen.dart'; import 'package:quid_faciam_hodie/screens/grant_permission_screen.dart'; import 'package:quid_faciam_hodie/screens/login_screen.dart'; @@ -20,7 +21,7 @@ void main() async { DeviceOrientation.portraitDown, ]); - runApp(MyApp()); + runApp(const MyApp()); } class MyApp extends StatefulWidget { @@ -41,22 +42,9 @@ class _MyAppState extends State { value: memories, child: MaterialApp( title: 'Quid faciam hodie?', - theme: ThemeData.dark().copyWith( - textTheme: ThemeData.dark().textTheme.copyWith( - headline1: const TextStyle( - fontSize: 32, - fontWeight: FontWeight.w500, - ), - ), - inputDecorationTheme: InputDecorationTheme( - filled: true, - helperMaxLines: 10, - errorMaxLines: 10, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - ), - ), - ), + theme: LIGHT_THEME, + darkTheme: DARK_THEME, + themeMode: ThemeMode.system, routes: { WelcomeScreen.ID: (context) => const WelcomeScreen(), MainScreen.ID: (context) => const MainScreen(), diff --git a/lib/screens/server_loading_screen.dart b/lib/screens/server_loading_screen.dart index 5f9bfb5..cd576aa 100644 --- a/lib/screens/server_loading_screen.dart +++ b/lib/screens/server_loading_screen.dart @@ -25,6 +25,8 @@ class _ServerLoadingScreenState extends State { @override void initState() { super.initState(); + + load(); } Future load() async { diff --git a/lib/widgets/calendar_month.dart b/lib/widgets/calendar_month.dart index fb4b49d..3de192c 100644 --- a/lib/widgets/calendar_month.dart +++ b/lib/widgets/calendar_month.dart @@ -40,8 +40,8 @@ class MonthCalendarBuilder extends CalendarBuilder { }(); final delay = Duration( - microseconds: - Random().nextInt(CALENDAR_DATE_IN_MAX_DELAY.inMicroseconds)); + microseconds: Random().nextInt(CALENDAR_DATE_IN_MAX_DELAY.inMicroseconds), + ); return DelayRender( delay: delay, @@ -163,7 +163,7 @@ class CalendarMonth extends StatelessWidget { // Background color selectedDayTextColor: theme.textTheme.bodyText1!.color!, // Foreground color - focusedDayTextColor: theme.bottomAppBarColor, + focusedDayTextColor: theme.dialogBackgroundColor, ), ); } diff --git a/lib/widgets/memory.dart b/lib/widgets/memory.dart index 4e85013..8d0a93f 100644 --- a/lib/widgets/memory.dart +++ b/lib/widgets/memory.dart @@ -79,9 +79,16 @@ class _MemoryViewState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + if (status == MemoryFetchStatus.error) { - return const Center( - child: Text('Memory could not be loaded.'), + return Center( + child: Text( + 'Memory could not be loaded.', + style: theme.textTheme.bodyText2!.copyWith( + color: Colors.white, + ), + ), ); } @@ -122,7 +129,12 @@ class _MemoryViewState extends State { () { switch (status) { case MemoryFetchStatus.downloading: - return const Text('Downloading memory'); + return Text( + 'Downloading memory', + style: theme.textTheme.bodyText2!.copyWith( + color: Colors.white, + ), + ); default: return const SizedBox(); } diff --git a/lib/widgets/status.dart b/lib/widgets/status.dart index 301ffb0..9244dcf 100644 --- a/lib/widgets/status.dart +++ b/lib/widgets/status.dart @@ -74,47 +74,50 @@ class _StatusState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { - return Stack( - fit: StackFit.expand, - children: [ - widget.child, - Positioned( - left: 0, - bottom: SMALL_SPACE, - width: MediaQuery.of(context).size.width, - height: BAR_HEIGHT, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: SMALL_SPACE), - child: AnimatedOpacity( - duration: const Duration(milliseconds: 500), - curve: Curves.linearToEaseOut, - opacity: widget.hideProgressBar ? 0.0 : 1.0, - child: (widget.controller == null) - ? ClipRRect( - borderRadius: BorderRadius.circular(HUGE_SPACE), - child: LinearProgressIndicator( - value: null, - valueColor: AlwaysStoppedAnimation( - Colors.white.withOpacity(.3)), - backgroundColor: Colors.white.withOpacity(0.1), - ), - ) - : AnimatedBuilder( - animation: animation, - builder: (_, __) => ClipRRect( + return Container( + color: Colors.black, + child: Stack( + fit: StackFit.expand, + children: [ + widget.child, + Positioned( + left: 0, + bottom: SMALL_SPACE, + width: MediaQuery.of(context).size.width, + height: BAR_HEIGHT, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: SMALL_SPACE), + child: AnimatedOpacity( + duration: const Duration(milliseconds: 500), + curve: Curves.linearToEaseOut, + opacity: widget.hideProgressBar ? 0.0 : 1.0, + child: (widget.controller == null) + ? ClipRRect( borderRadius: BorderRadius.circular(HUGE_SPACE), child: LinearProgressIndicator( - value: animation.value, - valueColor: - const AlwaysStoppedAnimation(Colors.white), + value: null, + valueColor: AlwaysStoppedAnimation( + Colors.white.withOpacity(.3)), backgroundColor: Colors.white.withOpacity(0.1), ), + ) + : AnimatedBuilder( + animation: animation, + builder: (_, __) => ClipRRect( + borderRadius: BorderRadius.circular(HUGE_SPACE), + child: LinearProgressIndicator( + value: animation.value, + valueColor: + const AlwaysStoppedAnimation(Colors.white), + backgroundColor: Colors.white.withOpacity(0.1), + ), + ), ), - ), + ), ), ), - ), - ], + ], + ), ); } } diff --git a/lib/widgets/timeline_overlay.dart b/lib/widgets/timeline_overlay.dart index 6979a30..cc0bfba 100644 --- a/lib/widgets/timeline_overlay.dart +++ b/lib/widgets/timeline_overlay.dart @@ -36,7 +36,9 @@ class TimelineOverlay extends StatelessWidget { child: Text( DateFormat('dd. MMMM yyyy').format(date), textAlign: TextAlign.center, - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headline1!.copyWith( + color: Colors.white, + ), ), ), ), @@ -58,12 +60,15 @@ class TimelineOverlay extends StatelessWidget { child: Icon( Icons.public, size: theme.textTheme.titleSmall!.fontSize, + color: Colors.white, ), ), const SizedBox(width: SMALL_SPACE), Text( '$memoryIndex/$memoriesAmount', - style: Theme.of(context).textTheme.titleSmall, + style: Theme.of(context).textTheme.titleSmall!.copyWith( + color: Colors.white, + ), ) ], ),