From f5b945c392684581f618d174a2b59facaf7f0486 Mon Sep 17 00:00:00 2001 From: BrightDV <92821484+BrightDV@users.noreply.github.com> Date: Sun, 11 Feb 2024 19:20:57 +0100 Subject: [PATCH] [ui] md3 migration | part 2 --- lib/Screens/FormulaYou/home.dart | 6 +- lib/Screens/FormulaYou/settings.dart | 45 +- lib/Screens/LivetimingArchive/races_list.dart | 2 + lib/Screens/MixedNews/edit_order.dart | 6 +- lib/Screens/MixedNews/mixed_news.dart | 62 +-- lib/Screens/MixedNews/rss_feed.dart | 21 +- lib/Screens/MixedNews/rss_feed_article.dart | 7 +- lib/Screens/MixedNews/wordpress.dart | 20 +- lib/Screens/about.dart | 10 +- lib/Screens/article.dart | 8 +- lib/Screens/circuit.dart | 527 +++++++----------- lib/Screens/circuit_map_screen.dart | 16 +- lib/Screens/custom_home_feed_settings.dart | 484 +++++++--------- lib/Screens/driver_details.dart | 7 +- lib/Screens/free_practice_screen.dart | 2 + lib/Screens/grand_prix_running_details.dart | 2 + lib/Screens/hall_of_fame.dart | 29 +- lib/Screens/history.dart | 10 +- lib/Screens/links.dart | 16 +- lib/Screens/race_details.dart | 410 ++++++-------- lib/Screens/schedule.dart | 11 +- lib/Screens/search.dart | 2 + lib/Screens/server_settings.dart | 46 +- lib/Screens/session_screen.dart | 2 + lib/Screens/settings.dart | 106 +--- lib/Screens/standings.dart | 2 + lib/Screens/team_details.dart | 34 +- lib/Screens/test.dart | 2 + lib/Screens/video.dart | 7 +- lib/Screens/videos.dart | 2 +- lib/api/article_parts.dart | 17 +- lib/api/ergast.dart | 2 +- lib/api/race_components.dart | 5 +- lib/helpers/bottom_navigation_bar.dart | 10 +- .../convert_ergast_and_formula_one.dart | 2 +- lib/helpers/drawer.dart | 3 +- lib/helpers/driver_result_item.dart | 2 + .../live_session_status_indicator.dart | 2 + lib/helpers/loading_indicator_util.dart | 2 +- lib/helpers/news.dart | 33 +- lib/helpers/request_error.dart | 2 + lib/helpers/route_handler.dart | 2 + lib/helpers/team_background_color.dart | 2 + lib/helpers/team_car_image.dart | 2 + lib/theme/teams_themes.dart | 2 + 45 files changed, 770 insertions(+), 1222 deletions(-) diff --git a/lib/Screens/FormulaYou/home.dart b/lib/Screens/FormulaYou/home.dart index a297d7ef..3a2bd3f6 100644 --- a/lib/Screens/FormulaYou/home.dart +++ b/lib/Screens/FormulaYou/home.dart @@ -43,8 +43,6 @@ class _PersonalizedHomeScreenState extends State { Widget build(BuildContext context) { List selectedTags = Hive.box('settings').get('selectedTags', defaultValue: []) as List; - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; Map availableTags = FormulaYouTags().unifiedTags(); List selectedTagsIds = []; for (String tagName in selectedTags) { @@ -75,10 +73,8 @@ class _PersonalizedHomeScreenState extends State { ), ), ], + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: NewsFeed( tagId: selectedTagsIds.join(','), ), diff --git a/lib/Screens/FormulaYou/settings.dart b/lib/Screens/FormulaYou/settings.dart index f027e40e..271af7dc 100644 --- a/lib/Screens/FormulaYou/settings.dart +++ b/lib/Screens/FormulaYou/settings.dart @@ -34,17 +34,12 @@ class FormulaYouSettingsScreen extends StatefulWidget { class _FormulaYouSettingsScreenState extends State { @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; List selectedTags = Hive.box('settings').get('selectedTags', defaultValue: []) as List; List availableTags = FormulaYouTags().tags(); int i = 0; return Scaffold( - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, appBar: AppBar( title: Text( AppLocalizations.of(context)!.formulaYouSettings, @@ -53,6 +48,7 @@ class _FormulaYouSettingsScreenState extends State { fontSize: 18, ), ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), body: ListView( shrinkWrap: true, @@ -68,33 +64,22 @@ class _FormulaYouSettingsScreenState extends State { ? AppLocalizations.of(context)!.topics.capitalize() : AppLocalizations.of(context)!.other.capitalize(), ), - collapsedIconColor: useDarkMode ? Colors.white : Colors.black, - collapsedTextColor: useDarkMode ? Colors.white : Colors.black, children: [ for (String key in availableTags[i].keys.toList()..sort()) - Theme( - data: Theme.of(context).copyWith( - unselectedWidgetColor: - useDarkMode ? Colors.white : Colors.black, - ), - child: CheckboxListTile( - value: selectedTags.contains(key) ? true : false, - onChanged: (value) { - selectedTags.contains(key) - ? selectedTags.remove(key) - : selectedTags.add(key); - Hive.box('settings').put('selectedTags', selectedTags); - if (widget.update != null) { - widget.update!(); - } - setState(() {}); - }, - title: Text( - key, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), - ), + CheckboxListTile( + value: selectedTags.contains(key) ? true : false, + onChanged: (value) { + selectedTags.contains(key) + ? selectedTags.remove(key) + : selectedTags.add(key); + Hive.box('settings').put('selectedTags', selectedTags); + if (widget.update != null) { + widget.update!(); + } + setState(() {}); + }, + title: Text( + key, ), ), ], diff --git a/lib/Screens/LivetimingArchive/races_list.dart b/lib/Screens/LivetimingArchive/races_list.dart index 528fb3a3..443ab3e8 100644 --- a/lib/Screens/LivetimingArchive/races_list.dart +++ b/lib/Screens/LivetimingArchive/races_list.dart @@ -17,6 +17,8 @@ * Copyright (c) 2022-2024, BrightDV */ +// TODO: md3 + import 'package:boxbox/Screens/LivetimingArchive/live_timing.dart'; import 'package:boxbox/Screens/schedule.dart'; import 'package:boxbox/api/ergast.dart'; diff --git a/lib/Screens/MixedNews/edit_order.dart b/lib/Screens/MixedNews/edit_order.dart index 81cdf04d..2d7d0c45 100644 --- a/lib/Screens/MixedNews/edit_order.dart +++ b/lib/Screens/MixedNews/edit_order.dart @@ -47,7 +47,7 @@ class _EditOrderScreenState extends State { 'Thecheckeredflag.co.uk', 'Motorsportweek.com', 'Crash.net', - 'Pitpass.com', + //'Pitpass.com', // TODO: fix Pitpass ], ) as List; return Scaffold( @@ -55,10 +55,8 @@ class _EditOrderScreenState extends State { title: Text( AppLocalizations.of(context)!.edit, ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: Theme( data: ThemeData( canvasColor: Colors.transparent, diff --git a/lib/Screens/MixedNews/mixed_news.dart b/lib/Screens/MixedNews/mixed_news.dart index 21d62f80..f184aa84 100644 --- a/lib/Screens/MixedNews/mixed_news.dart +++ b/lib/Screens/MixedNews/mixed_news.dart @@ -84,13 +84,11 @@ class _MixedNewsScreenState extends State { 'https://www.pitpass.com/fes_php/fes_usr_sit_newsfeed.php?fes_prepend_aty_sht_name=1', }; return Scaffold( - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, appBar: AppBar( title: Text( AppLocalizations.of(context)!.newsMix, ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, actions: [ IconButton( onPressed: () { @@ -103,7 +101,6 @@ class _MixedNewsScreenState extends State { }, icon: Icon( useMergedFeeds ? Icons.splitscreen : Icons.merge, - color: Colors.white, ), ), useMergedFeeds @@ -119,7 +116,6 @@ class _MixedNewsScreenState extends State { ), icon: const Icon( Icons.edit, - color: Colors.white, ), ), ], @@ -142,9 +138,6 @@ class _MixedNewsScreenState extends State { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15.0), ), - color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.white, child: InkWell( onTap: () => Navigator.push( context, @@ -230,14 +223,11 @@ class _MixedNewsScreenState extends State { .replaceAll('“', '"') .replaceAll('”', '"'), style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 18, fontWeight: FontWeight.w500, ), overflow: TextOverflow.ellipsis, - maxLines: 5, + maxLines: 4, textAlign: TextAlign.justify, ), subtitle: newsLayout != 'big' && @@ -276,11 +266,6 @@ class _MixedNewsScreenState extends State { styleSheet: MarkdownStyleSheet( textAlign: WrapAlignment.spaceBetween, - p: TextStyle( - color: useDarkMode - ? Colors.grey[400] - : Colors.grey[800], - ), ), ), ), @@ -311,9 +296,6 @@ class _MixedNewsScreenState extends State { ) .split('.')[0], style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.grey[900], fontWeight: FontWeight.w500, ), ), @@ -375,9 +357,6 @@ class _MixedNewsScreenState extends State { Text( feed, style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 16, fontWeight: FontWeight.w500, ), @@ -397,9 +376,6 @@ class _MixedNewsScreenState extends State { child: Text( AppLocalizations.of(context)!.viewMore, style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 12, fontWeight: FontWeight.w500, decoration: TextDecoration.underline, @@ -409,9 +385,6 @@ class _MixedNewsScreenState extends State { ), Icon( Icons.arrow_forward, - color: useDarkMode - ? Colors.white - : Colors.black, ), ], ), @@ -472,10 +445,6 @@ class _MixedNewsScreenState extends State { ), child: Card( elevation: 5.0, - color: useDarkMode - ? const Color( - 0xff1d1d28) - : Colors.white, child: Column( children: [ FutureBuilder< @@ -525,11 +494,6 @@ class _MixedNewsScreenState extends State { '"'), style: TextStyle( - color: useDarkMode - ? Colors - .white - : Colors - .black, fontSize: 14, ), @@ -539,7 +503,7 @@ class _MixedNewsScreenState extends State { textAlign: TextAlign .justify, - maxLines: 5, + maxLines: 4, ), ), ], @@ -567,9 +531,6 @@ class _MixedNewsScreenState extends State { Text( feed, style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 16, fontWeight: FontWeight.w500, ), @@ -589,9 +550,6 @@ class _MixedNewsScreenState extends State { child: Text( AppLocalizations.of(context)!.viewMore, style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 12, fontWeight: FontWeight.w500, decoration: TextDecoration.underline, @@ -601,9 +559,6 @@ class _MixedNewsScreenState extends State { ), Icon( Icons.arrow_forward, - color: useDarkMode - ? Colors.white - : Colors.black, ), ], ), @@ -674,10 +629,6 @@ class _MixedNewsScreenState extends State { ), child: Card( elevation: 5.0, - color: useDarkMode - ? const Color( - 0xff1d1d28) - : Colors.white, child: Column( children: [ feedItem.enclosure != @@ -714,11 +665,6 @@ class _MixedNewsScreenState extends State { .title!, style: TextStyle( - color: useDarkMode - ? Colors - .white - : Colors - .black, fontSize: 14, ), @@ -728,7 +674,7 @@ class _MixedNewsScreenState extends State { textAlign: TextAlign .justify, - maxLines: 5, + maxLines: 4, ), ), ], diff --git a/lib/Screens/MixedNews/rss_feed.dart b/lib/Screens/MixedNews/rss_feed.dart index 5d20b63f..22ea5e65 100644 --- a/lib/Screens/MixedNews/rss_feed.dart +++ b/lib/Screens/MixedNews/rss_feed.dart @@ -44,17 +44,12 @@ class RssFeedScreen extends StatefulWidget { class _RssFeedScreenState extends State { @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; - return Scaffold( - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, appBar: AppBar( title: Text( widget.feedTitle, ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), body: FutureBuilder>( future: RssFeeds().getFeedArticles( @@ -95,7 +90,7 @@ class RssFeedItemsList extends StatelessWidget { showMenu( context: context, - color: useDarkMode ? const Color(0xff1d1d28) : Colors.white, + //color: useDarkMode ? const Color(0xff1d1d28) : Colors.white, items: >[ PopupMenuItem( value: 0, @@ -103,7 +98,6 @@ class RssFeedItemsList extends StatelessWidget { children: [ Icon( Icons.language_outlined, - color: useDarkMode ? Colors.white : Colors.black, ), const Padding( padding: EdgeInsets.all(5), @@ -111,7 +105,6 @@ class RssFeedItemsList extends StatelessWidget { Text( AppLocalizations.of(context)!.openInBrowser, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 14, ), ), @@ -124,7 +117,6 @@ class RssFeedItemsList extends StatelessWidget { children: [ Icon( Icons.share_outlined, - color: useDarkMode ? Colors.white : Colors.black, ), const Padding( padding: EdgeInsets.all(5), @@ -132,7 +124,6 @@ class RssFeedItemsList extends StatelessWidget { Text( AppLocalizations.of(context)!.share, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 14, ), ), @@ -140,8 +131,10 @@ class RssFeedItemsList extends StatelessWidget { ), ), ], - position: RelativeRect.fromRect(tapPosition & const Size(40, 40), - Offset.zero & overlay.semanticBounds.size), + position: RelativeRect.fromRect( + tapPosition & const Size(40, 40), + Offset.zero & overlay.semanticBounds.size, + ), ).then( (int? delta) { if (delta == null) return; @@ -167,7 +160,6 @@ class RssFeedItemsList extends StatelessWidget { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15.0), ), - color: useDarkMode ? const Color(0xff1d1d28) : Colors.white, child: InkWell( onTap: () => Navigator.push( context, @@ -260,7 +252,6 @@ class RssFeedItemsList extends StatelessWidget { title: Text( snapshot.data!['feedArticles'][index].title!, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 18, fontWeight: FontWeight.w500, ), diff --git a/lib/Screens/MixedNews/rss_feed_article.dart b/lib/Screens/MixedNews/rss_feed_article.dart index 14622a84..05ac27cf 100644 --- a/lib/Screens/MixedNews/rss_feed_article.dart +++ b/lib/Screens/MixedNews/rss_feed_article.dart @@ -21,7 +21,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; -import 'package:hive_flutter/hive_flutter.dart'; import 'package:share_plus/share_plus.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -104,10 +103,9 @@ class _RssFeedArticleScreenState extends State { @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; return Scaffold( appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.onPrimary, actions: [ IconButton( onPressed: () => launchUrl( @@ -136,9 +134,6 @@ class _RssFeedArticleScreenState extends State { ), ], ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: InAppWebView( initialUrlRequest: URLRequest( url: WebUri( diff --git a/lib/Screens/MixedNews/wordpress.dart b/lib/Screens/MixedNews/wordpress.dart index cd33cf74..8f0cdbb0 100644 --- a/lib/Screens/MixedNews/wordpress.dart +++ b/lib/Screens/MixedNews/wordpress.dart @@ -44,17 +44,13 @@ class WordpressScreen extends StatefulWidget { class _WordpressScreenState extends State { @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; return Scaffold( appBar: AppBar( title: Text( widget.feedName, ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: WordpressNewsList(widget.feedUrl), ); } @@ -86,7 +82,7 @@ class WordspressNewsItem extends StatelessWidget { showMenu( context: context, - color: useDarkMode ? const Color(0xff1d1d28) : Colors.white, + //color: useDarkMode ? const Color(0xff1d1d28) : Colors.white, items: >[ PopupMenuItem( value: 0, @@ -94,7 +90,6 @@ class WordspressNewsItem extends StatelessWidget { children: [ Icon( Icons.language_outlined, - color: useDarkMode ? Colors.white : Colors.black, ), const Padding( padding: EdgeInsets.all(5), @@ -102,7 +97,6 @@ class WordspressNewsItem extends StatelessWidget { Text( AppLocalizations.of(context)!.openInBrowser, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 14, ), ), @@ -115,7 +109,6 @@ class WordspressNewsItem extends StatelessWidget { children: [ Icon( Icons.share_outlined, - color: useDarkMode ? Colors.white : Colors.black, ), const Padding( padding: EdgeInsets.all(5), @@ -123,7 +116,6 @@ class WordspressNewsItem extends StatelessWidget { Text( AppLocalizations.of(context)!.share, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 14, ), ), @@ -131,8 +123,10 @@ class WordspressNewsItem extends StatelessWidget { ), ), ], - position: RelativeRect.fromRect(tapPosition & const Size(40, 40), - Offset.zero & overlay.semanticBounds.size), + position: RelativeRect.fromRect( + tapPosition & const Size(40, 40), + Offset.zero & overlay.semanticBounds.size, + ), ).then( (int? delta) { if (delta == null) return; @@ -157,7 +151,6 @@ class WordspressNewsItem extends StatelessWidget { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15.0), ), - color: useDarkMode ? const Color(0xff1d1d28) : Colors.white, child: InkWell( onTap: () { Navigator.push( @@ -217,7 +210,6 @@ class WordspressNewsItem extends StatelessWidget { .replaceAll('“', '"') .replaceAll('”', '"'), style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 18, fontWeight: FontWeight.w500, ), diff --git a/lib/Screens/about.dart b/lib/Screens/about.dart index 3a17176c..91687e2f 100644 --- a/lib/Screens/about.dart +++ b/lib/Screens/about.dart @@ -40,10 +40,8 @@ class AboutScreen extends StatelessWidget { fontWeight: FontWeight.w600, ), ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.center, @@ -64,7 +62,7 @@ class AboutScreen extends StatelessWidget { child: Text( 'Box, Box!', style: TextStyle( - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.onPrimary, fontSize: 40, fontWeight: FontWeight.w700, ), @@ -91,9 +89,7 @@ class AboutScreen extends StatelessWidget { child: Container( width: 150, decoration: BoxDecoration( - color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.grey.shade400, + color: Theme.of(context).colorScheme.onSecondary, borderRadius: BorderRadius.circular(5), ), child: Padding( diff --git a/lib/Screens/article.dart b/lib/Screens/article.dart index f1737d17..fd91d746 100644 --- a/lib/Screens/article.dart +++ b/lib/Screens/article.dart @@ -22,7 +22,6 @@ import 'package:boxbox/api/formula1.dart'; import 'package:boxbox/helpers/loading_indicator_util.dart'; import 'package:boxbox/helpers/request_error.dart'; import 'package:flutter/material.dart'; -import 'package:hive_flutter/hive_flutter.dart'; import 'package:marquee/marquee.dart'; class ArticleScreen extends StatefulWidget { @@ -50,11 +49,10 @@ class _ArticleScreenState extends State { @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; double width = MediaQuery.of(context).size.width; return Scaffold( appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.onPrimary, title: SizedBox( height: AppBar().preferredSize.height, width: AppBar().preferredSize.width, @@ -75,7 +73,7 @@ class _ArticleScreenState extends State { : Marquee( text: value.toString(), style: const TextStyle( - fontWeight: FontWeight.w600, + fontWeight: FontWeight.w500, ), pauseAfterRound: const Duration(seconds: 1), startAfter: const Duration(seconds: 1), @@ -92,7 +90,7 @@ class _ArticleScreenState extends State { : Marquee( text: widget.articleName, style: const TextStyle( - fontWeight: FontWeight.w600, + fontWeight: FontWeight.w500, ), pauseAfterRound: const Duration(seconds: 1), startAfter: const Duration(seconds: 1), diff --git a/lib/Screens/circuit.dart b/lib/Screens/circuit.dart index 00370831..9f751f91 100644 --- a/lib/Screens/circuit.dart +++ b/lib/Screens/circuit.dart @@ -56,9 +56,6 @@ class CircuitScreen extends StatelessWidget { bool useDataSaverMode = Hive.box('settings') .get('useDataSaverMode', defaultValue: false) as bool; return Scaffold( - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: isFetched ?? true ? NestedScrollView( headerSliverBuilder: @@ -75,6 +72,7 @@ class CircuitScreen extends StatelessWidget { race.raceName, ), ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), ]; }, @@ -94,9 +92,6 @@ class CircuitScreen extends StatelessWidget { child: Text( snapshot.data!['headline'], style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 20, fontWeight: FontWeight.w500, ), @@ -105,14 +100,17 @@ class CircuitScreen extends StatelessWidget { ) : Container(), Padding( - padding: const EdgeInsets.all(5), + padding: const EdgeInsets.symmetric( + vertical: 3, + horizontal: 10, + ), child: GestureDetector( child: Container( width: double.infinity, decoration: BoxDecoration( - color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.grey.shade400, + color: Theme.of(context) + .colorScheme + .onSecondary, borderRadius: BorderRadius.circular(5), ), child: Padding( @@ -127,18 +125,10 @@ class CircuitScreen extends StatelessWidget { Text( AppLocalizations.of(context)! .viewResults, - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), ), const Spacer(), Icon( Icons.arrow_forward_rounded, - color: useDarkMode - ? Colors.white - : Colors.black, ), ], ), @@ -159,14 +149,17 @@ class CircuitScreen extends StatelessWidget { ), snapshot.data!['links'].isNotEmpty ? Padding( - padding: const EdgeInsets.all(5), + padding: const EdgeInsets.symmetric( + vertical: 3, + horizontal: 10, + ), child: GestureDetector( child: Container( width: double.infinity, decoration: BoxDecoration( - color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.grey.shade400, + color: Theme.of(context) + .colorScheme + .onSecondary, borderRadius: BorderRadius.circular(5), ), @@ -178,18 +171,10 @@ class CircuitScreen extends StatelessWidget { Text( AppLocalizations.of(context)! .viewHighlights, - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), ), const Spacer(), Icon( Icons.arrow_forward_rounded, - color: useDarkMode - ? Colors.white - : Colors.black, ), ], ), @@ -210,14 +195,17 @@ class CircuitScreen extends StatelessWidget { ) : Container(), Padding( - padding: const EdgeInsets.all(5), + padding: const EdgeInsets.symmetric( + vertical: 3, + horizontal: 10, + ), child: GestureDetector( child: Container( width: double.infinity, decoration: BoxDecoration( - color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.grey.shade400, + color: Theme.of(context) + .colorScheme + .onSecondary, borderRadius: BorderRadius.circular(5), ), child: Padding( @@ -232,18 +220,10 @@ class CircuitScreen extends StatelessWidget { Text( AppLocalizations.of(context)! .grandPrixMap, - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), ), const Spacer(), Icon( Icons.map_outlined, - color: useDarkMode - ? Colors.white - : Colors.black, ), ], ), @@ -264,12 +244,12 @@ class CircuitScreen extends StatelessWidget { 10, ), child: Container( - height: 210, + height: 240, decoration: BoxDecoration( border: Border.all( - color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.grey.shade50, + color: Theme.of(context) + .colorScheme + .onSecondary, ), borderRadius: BorderRadius.circular(15.0), @@ -284,9 +264,6 @@ class CircuitScreen extends StatelessWidget { snapshot.data!['race'] ['meetingCountryName'], style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 16, fontWeight: FontWeight.w500, ), @@ -295,9 +272,6 @@ class CircuitScreen extends StatelessWidget { Text( AppLocalizations.of(context)!.race, style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 14, ), ), @@ -314,11 +288,6 @@ class CircuitScreen extends StatelessWidget { AppLocalizations.of( context)! .positionAbbreviation, - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), ), ), const Spacer(), @@ -328,11 +297,6 @@ class CircuitScreen extends StatelessWidget { AppLocalizations.of( context)! .time, - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), ), ), ], @@ -356,9 +320,6 @@ class CircuitScreen extends StatelessWidget { : driverResults[ 'positionNumber'], style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontWeight: FontWeight.w500, ), @@ -387,11 +348,6 @@ class CircuitScreen extends StatelessWidget { child: Text( driverResults['driverTLA'] .toString(), - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), ), ), const Spacer(), @@ -404,11 +360,6 @@ class CircuitScreen extends StatelessWidget { ? '+${driverResults['gapToLeader']}' : driverResults[ 'raceTime'], - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), ), ), ], @@ -461,9 +412,6 @@ class CircuitScreen extends StatelessWidget { AppLocalizations.of( context)! .viewResults, - style: const TextStyle( - color: Colors.white, - ), ), ), ), @@ -476,39 +424,46 @@ class CircuitScreen extends StatelessWidget { ) : Container(), snapshot.data!['curatedSection'] != null - ? SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - for (Map article in snapshot - .data!['curatedSection']['items']) - NewsItem( - News( - article['id'], - article['articleType'], - article['slug'], - article['title'], - article['metaDescription'] ?? ' ', - DateTime.parse( - article['updatedAt']), - useDataSaverMode - ? article['thumbnail'] - ['image'] - ['renditions'] != - null - ? article['thumbnail'] - ['image'] - ['renditions']['2col'] - : article['thumbnail'] - ['image']['url'] + - '.transform/2col-retina/image.jpg' - : article['thumbnail'] - ['image']['url'], + ? Padding( + padding: EdgeInsets.only(left: 10), + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + for (Map article in snapshot + .data!['curatedSection']['items']) + NewsItem( + News( + article['id'], + article['articleType'], + article['slug'], + article['title'], + article['metaDescription'] ?? + ' ', + DateTime.parse( + article['updatedAt']), + useDataSaverMode + ? article['thumbnail'] + ['image'][ + 'renditions'] != + null + ? article['thumbnail'] + ['image'] + ['renditions'] + ['2col'] + : article['thumbnail'] + ['image'] + ['url'] + + '.transform/2col-retina/image.jpg' + : article['thumbnail'] + ['image']['url'], + ), + true, ), - true, - ), - ], + SizedBox(width: 5), + ], + ), ), ) : Container(), @@ -537,20 +492,12 @@ class CircuitScreen extends StatelessWidget { Text( snapshot.data!.keys .elementAt(index), - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), textAlign: TextAlign.center, ), Text( snapshot.data![snapshot.data!.keys .elementAt(index)], style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 25, fontWeight: FontWeight.w500, ), @@ -586,36 +533,52 @@ class CircuitScreen extends StatelessWidget { styleSheet: MarkdownStyleSheet( textAlign: WrapAlignment.spaceBetween, strong: TextStyle( - color: - Theme.of(context).primaryColor, + color: useDarkMode + ? HSLColor.fromColor( + Theme.of(context) + .colorScheme + .onPrimary, + ) + .withLightness(0.35) + .toColor() + : Theme.of(context) + .colorScheme + .onPrimary, fontSize: 20, fontWeight: FontWeight.w500, ), p: TextStyle( fontSize: 14, - color: useDarkMode - ? Colors.white - : Colors.black, ), pPadding: const EdgeInsets.only( top: 10, bottom: 10, ), - h1: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), - h2: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), a: TextStyle( - color: - Theme.of(context).primaryColor, + color: useDarkMode + ? HSLColor.fromColor( + Theme.of(context) + .colorScheme + .onPrimary, + ) + .withLightness(0.35) + .toColor() + : Theme.of(context) + .colorScheme + .onPrimary, decoration: TextDecoration.underline, + decorationColor: useDarkMode + ? HSLColor.fromColor( + Theme.of(context) + .colorScheme + .onPrimary, + ) + .withLightness(0.35) + .toColor() + : Theme.of(context) + .colorScheme + .onPrimary, fontWeight: FontWeight.normal, ), ), @@ -634,9 +597,8 @@ class CircuitScreen extends StatelessWidget { child: Container( width: double.infinity, decoration: BoxDecoration( - color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.grey.shade400, + color: + Theme.of(context).colorScheme.onSecondary, borderRadius: BorderRadius.circular(5), ), child: Padding( @@ -646,18 +608,10 @@ class CircuitScreen extends StatelessWidget { children: [ Text( AppLocalizations.of(context)!.viewResults, - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), ), const Spacer(), Icon( Icons.arrow_forward_rounded, - color: useDarkMode - ? Colors.white - : Colors.black, ), ], ), @@ -724,9 +678,6 @@ class CircuitScreen extends StatelessWidget { child: Text( snapshot.data!['headline'], style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 20, fontWeight: FontWeight.w500, ), @@ -740,9 +691,9 @@ class CircuitScreen extends StatelessWidget { child: Container( width: double.infinity, decoration: BoxDecoration( - color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.grey.shade400, + color: Theme.of(context) + .colorScheme + .onSecondary, borderRadius: BorderRadius.circular(5), ), @@ -760,19 +711,11 @@ class CircuitScreen extends StatelessWidget { AppLocalizations.of( context)! .viewResults, - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), ), const Spacer(), Icon( Icons .arrow_forward_rounded, - color: useDarkMode - ? Colors.white - : Colors.black, ), ], ), @@ -801,11 +744,9 @@ class CircuitScreen extends StatelessWidget { child: Container( width: double.infinity, decoration: BoxDecoration( - color: useDarkMode - ? const Color( - 0xff1d1d28) - : Colors - .grey.shade400, + color: Theme.of(context) + .colorScheme + .onSecondary, borderRadius: BorderRadius.circular( 5, @@ -825,20 +766,11 @@ class CircuitScreen extends StatelessWidget { AppLocalizations.of( context)! .viewHighlights, - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors - .black, - ), ), const Spacer(), Icon( Icons .arrow_forward_rounded, - color: useDarkMode - ? Colors.white - : Colors.black, ), ], ), @@ -866,9 +798,9 @@ class CircuitScreen extends StatelessWidget { child: Container( width: double.infinity, decoration: BoxDecoration( - color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.grey.shade400, + color: Theme.of(context) + .colorScheme + .onSecondary, borderRadius: BorderRadius.circular(5), ), @@ -886,18 +818,10 @@ class CircuitScreen extends StatelessWidget { AppLocalizations.of( context)! .grandPrixMap, - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), ), const Spacer(), Icon( Icons.map_outlined, - color: useDarkMode - ? Colors.white - : Colors.black, ), ], ), @@ -918,13 +842,12 @@ class CircuitScreen extends StatelessWidget { 10, ), child: Container( - height: 210, + height: 240, decoration: BoxDecoration( border: Border.all( - color: useDarkMode - ? const Color( - 0xff1d1d28) - : Colors.grey.shade50, + color: Theme.of(context) + .colorScheme + .onSecondary, ), borderRadius: BorderRadius.circular( @@ -943,9 +866,6 @@ class CircuitScreen extends StatelessWidget { [ 'meetingCountryName'], style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 16, fontWeight: FontWeight.w500, @@ -957,9 +877,6 @@ class CircuitScreen extends StatelessWidget { context)! .race, style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 14, ), ), @@ -978,14 +895,6 @@ class CircuitScreen extends StatelessWidget { AppLocalizations.of( context)! .positionAbbreviation, - style: - TextStyle( - color: useDarkMode - ? Colors - .white - : Colors - .black, - ), ), ), const Spacer(), @@ -995,14 +904,6 @@ class CircuitScreen extends StatelessWidget { AppLocalizations.of( context)! .time, - style: - TextStyle( - color: useDarkMode - ? Colors - .white - : Colors - .black, - ), ), ), ], @@ -1030,11 +931,6 @@ class CircuitScreen extends StatelessWidget { 'positionNumber'], style: TextStyle( - color: useDarkMode - ? Colors - .white - : Colors - .black, fontWeight: FontWeight .w500, @@ -1069,14 +965,6 @@ class CircuitScreen extends StatelessWidget { driverResults[ 'driverTLA'] .toString(), - style: - TextStyle( - color: useDarkMode - ? Colors - .white - : Colors - .black, - ), ), ), const Spacer(), @@ -1089,14 +977,6 @@ class CircuitScreen extends StatelessWidget { ? '+${driverResults['gapToLeader']}' : driverResults[ 'raceTime'], - style: - TextStyle( - color: useDarkMode - ? Colors - .white - : Colors - .black, - ), ), ), ], @@ -1161,11 +1041,6 @@ class CircuitScreen extends StatelessWidget { AppLocalizations.of( context)! .viewResults, - style: - const TextStyle( - color: Colors - .white, - ), ), ), ), @@ -1178,54 +1053,58 @@ class CircuitScreen extends StatelessWidget { ) : Container(), snapshot.data!['curatedSection'] != null - ? SingleChildScrollView( - scrollDirection: - Axis.horizontal, - child: Row( - mainAxisSize: - MainAxisSize.min, - children: [ - for (Map article in snapshot - .data![ - 'curatedSection'] - ['items']) - NewsItem( - News( - article['id'], - article[ - 'articleType'], - article['slug'], - article['title'], - article['metaDescription'] ?? - ' ', - DateTime.parse( - article[ - 'updatedAt']), - useDataSaverMode - ? article['thumbnail'] - ['image'] - [ - 'renditions'] != - null - ? article['thumbnail'] - [ - 'image'] - [ - 'renditions'] - ['2col'] - : article['thumbnail'] - [ - 'image'] - [ - 'url'] + - '.transform/2col-retina/image.jpg' - : article['thumbnail'] - ['image'] - ['url'], + ? Padding( + padding: const EdgeInsets.only( + left: 10, + ), + child: SingleChildScrollView( + scrollDirection: + Axis.horizontal, + child: Row( + mainAxisSize: + MainAxisSize.min, + children: [ + for (Map article in snapshot + .data![ + 'curatedSection'] + ['items']) + NewsItem( + News( + article['id'], + article[ + 'articleType'], + article['slug'], + article['title'], + article['metaDescription'] ?? + ' ', + DateTime.parse( + article[ + 'updatedAt']), + useDataSaverMode + ? article['thumbnail']['image'] + [ + 'renditions'] != + null + ? article['thumbnail'] + ['image'] + [ + 'renditions'] + ['2col'] + : article['thumbnail'] + ['image'] + [ + 'url'] + + '.transform/2col-retina/image.jpg' + : article['thumbnail'] + [ + 'image'] + ['url'], + ), + true, ), - true, - ), - ], + SizedBox(width: 5), + ], + ), ), ) : Container(), @@ -1263,13 +1142,6 @@ class CircuitScreen extends StatelessWidget { .data!.keys .elementAt( index), - style: TextStyle( - color: useDarkMode - ? Colors - .white - : Colors - .black, - ), textAlign: TextAlign .center, @@ -1281,11 +1153,6 @@ class CircuitScreen extends StatelessWidget { .elementAt( index)], style: TextStyle( - color: useDarkMode - ? Colors - .white - : Colors - .black, fontSize: 25, fontWeight: FontWeight @@ -1340,9 +1207,6 @@ class CircuitScreen extends StatelessWidget { ), p: TextStyle( fontSize: 14, - color: useDarkMode - ? Colors.white - : Colors.black, ), pPadding: const EdgeInsets @@ -1350,23 +1214,40 @@ class CircuitScreen extends StatelessWidget { top: 10, bottom: 10, ), - h1: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), - h2: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), a: TextStyle( - color: Theme.of( - context) - .primaryColor, + color: useDarkMode + ? HSLColor + .fromColor( + Theme.of( + context) + .colorScheme + .onPrimary, + ) + .withLightness( + 0.35) + .toColor() + : Theme.of( + context) + .colorScheme + .onPrimary, decoration: TextDecoration .underline, + decorationColor: + useDarkMode + ? HSLColor + .fromColor( + Theme.of(context) + .colorScheme + .onPrimary, + ) + .withLightness( + 0.35) + .toColor() + : Theme.of( + context) + .colorScheme + .onPrimary, fontWeight: FontWeight .normal, @@ -1388,9 +1269,9 @@ class CircuitScreen extends StatelessWidget { child: Container( width: double.infinity, decoration: BoxDecoration( - color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.grey.shade400, + color: Theme.of(context) + .colorScheme + .onSecondary, borderRadius: BorderRadius.circular(5), ), @@ -1406,18 +1287,10 @@ class CircuitScreen extends StatelessWidget { Text( AppLocalizations.of(context)! .viewResults, - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), ), const Spacer(), Icon( Icons.arrow_forward_rounded, - color: useDarkMode - ? Colors.white - : Colors.black, ), ], ), @@ -1563,8 +1436,10 @@ class TrackLayoutImage extends StatelessWidget { alignment: Alignment.topRight, child: IconButton( onPressed: () => Navigator.pop(context), - icon: const Icon(Icons.close_rounded, - color: Colors.white), + icon: const Icon( + Icons.close_rounded, + color: Colors.white, + ), ), ), ], diff --git a/lib/Screens/circuit_map_screen.dart b/lib/Screens/circuit_map_screen.dart index 0f436374..75aa6951 100644 --- a/lib/Screens/circuit_map_screen.dart +++ b/lib/Screens/circuit_map_screen.dart @@ -24,7 +24,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:hive_flutter/hive_flutter.dart'; import 'package:latlong2/latlong.dart'; import 'package:map_controller_plus/map_controller_plus.dart'; import 'package:boxbox/helpers/circuit_points.dart'; @@ -36,18 +35,10 @@ class CircuitMapScreen extends StatelessWidget { const CircuitMapScreen(this.circuitId, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; return AlertDialog( title: Text( AppLocalizations.of(context)!.grandPrixMap, - style: TextStyle( - color: Theme.of(context).primaryColor, - ), ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, content: Builder( builder: (context) { var height = MediaQuery.of(context).size.height; @@ -70,11 +61,6 @@ class CircuitMapScreen extends StatelessWidget { onPressed: () { Navigator.of(context).pop(); }, - style: ButtonStyle( - foregroundColor: MaterialStateProperty.all( - Theme.of(context).primaryColor, - ), - ), child: Text( AppLocalizations.of(context)!.close, ), @@ -130,7 +116,7 @@ class _MarkersPageState extends State { secondPoint[0], ), ], - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.onPrimary, ); } } diff --git a/lib/Screens/custom_home_feed_settings.dart b/lib/Screens/custom_home_feed_settings.dart index 78960dba..b12167a6 100644 --- a/lib/Screens/custom_home_feed_settings.dart +++ b/lib/Screens/custom_home_feed_settings.dart @@ -39,8 +39,6 @@ class _CustomeHomeFeedSettingsScreenState .get('homeFeed', defaultValue: [officialFeed, "api"]) as List; List customFeeds = Hive.box('settings').get('customFeeds', defaultValue: []) as List; - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; Map customFeedUrls = { 'France': 'https://fr.motorsport.com', @@ -70,200 +68,74 @@ class _CustomeHomeFeedSettingsScreenState appBar: AppBar( title: Text( AppLocalizations.of(context)!.news, + style: const TextStyle( + fontWeight: FontWeight.w600, + ), ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: SingleChildScrollView( - child: Theme( - data: ThemeData( - unselectedWidgetColor: useDarkMode ? Colors.white : Colors.black, - fontFamily: 'Formula1', - ), - child: Column( - children: [ - Padding( - padding: const EdgeInsets.only( - top: 20, - left: 10, - right: 10, - ), - child: Text( - AppLocalizations.of(context)!.customHomeFeed, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - fontSize: 22, - fontWeight: FontWeight.w500, - ), - textAlign: TextAlign.center, - ), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only( + top: 20, + left: 10, + right: 10, ), - RadioListTile( - value: officialFeed, - title: Text( - AppLocalizations.of(context)!.official, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), - ), - groupValue: savedFeedUrl[0], - activeColor: Theme.of(context).primaryColor, - onChanged: (value) => setState( - () { - savedFeedUrl = [value, "api"]; - Hive.box('settings').put('homeFeed', savedFeedUrl); - widget.updateParent(); - }, + child: Text( + AppLocalizations.of(context)!.customHomeFeed, + style: TextStyle( + fontSize: 22, + fontWeight: FontWeight.w500, ), + textAlign: TextAlign.center, ), - ExpansionTile( - title: Text( - AppLocalizations.of(context)!.motorsportLocalizeFeeds, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), - ), - iconColor: useDarkMode ? Colors.white : Colors.black, - children: [ - for (var feed in customFeedUrls.entries) - RadioListTile( - value: feed.value, - title: Text( - feed.key, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), - ), - groupValue: savedFeedUrl[0], - activeColor: Theme.of(context).primaryColor, - onChanged: (value) => setState( - () { - savedFeedUrl = [feed.value, "rss"]; - Hive.box('settings').put('homeFeed', savedFeedUrl); - widget.updateParent(); - }, - ), - ), - ], + ), + RadioListTile( + value: officialFeed, + title: Text( + AppLocalizations.of(context)!.official, ), - for (var feed in customFeeds) - GestureDetector( - onLongPress: () => showDialog( - context: context, - builder: (context) { - return AlertDialog( - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all( - Radius.circular( - 20.0, - ), - ), - ), - contentPadding: const EdgeInsets.all( - 50.0, - ), - title: Text( - AppLocalizations.of(context)!.deleteCustomFeed, - style: TextStyle( - fontSize: 24.0, - color: useDarkMode ? Colors.white : Colors.black, - ), // here - textAlign: TextAlign.center, - ), - content: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - AppLocalizations.of(context)!.deleteUrl, - style: TextStyle( - color: - useDarkMode ? Colors.white : Colors.black, - ), - ), - ], - ), - actions: [ - ElevatedButton( - onPressed: () { - Navigator.of(context).pop(); - }, - child: Text( - AppLocalizations.of(context)!.cancel, - ), - ), - ElevatedButton( - onPressed: () { - customFeeds.remove(feed); - Hive.box('settings').put( - 'customFeeds', - customFeeds, - ); - if (savedFeedUrl[0] == feed[0]) { - savedFeedUrl = [officialFeed, "api"]; - Hive.box('settings').put( - 'homeFeed', - savedFeedUrl, - ); - } - Navigator.of(context).pop(); - _setState(); - widget.updateParent(); - }, - child: Text( - AppLocalizations.of(context)!.yes, - ), - ), - ], - ); - }), - child: InkWell( - child: RadioListTile( - value: feed[0], - title: Text( - feed[0], - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), - ), - groupValue: savedFeedUrl[0], - activeColor: Theme.of(context).primaryColor, - onChanged: (value) => setState( - () { - Hive.box('settings').put('homeFeed', feed); - widget.updateParent(); - }, - ), + groupValue: savedFeedUrl[0], + activeColor: Theme.of(context).colorScheme.onPrimary, + onChanged: (value) => setState( + () { + savedFeedUrl = [value, "api"]; + Hive.box('settings').put('homeFeed', savedFeedUrl); + widget.updateParent(); + }, + ), + ), + ExpansionTile( + title: Text( + AppLocalizations.of(context)!.motorsportLocalizeFeeds, + ), + children: [ + for (var feed in customFeedUrls.entries) + RadioListTile( + value: feed.value, + title: Text( + feed.key, + ), + groupValue: savedFeedUrl[0], + activeColor: Theme.of(context).colorScheme.onPrimary, + onChanged: (value) => setState( + () { + savedFeedUrl = [feed.value, "rss"]; + Hive.box('settings').put('homeFeed', savedFeedUrl); + widget.updateParent(); + }, ), ), - ), - ListTile( - title: Text( - AppLocalizations.of(context)!.addCustomFeed, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), - ), - trailing: Icon( - Icons.add_outlined, - color: useDarkMode ? Colors.white : Colors.black, - ), - onTap: () => showDialog( - context: context, - builder: (context) { - final TextEditingController controller = - TextEditingController(); - String type = "rss"; - return StatefulBuilder( - builder: (context, setState) => AlertDialog( - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, + ], + ), + for (var feed in customFeeds) + GestureDetector( + onLongPress: () => showDialog( + context: context, + builder: (context) { + return AlertDialog( shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all( Radius.circular( @@ -272,13 +144,12 @@ class _CustomeHomeFeedSettingsScreenState ), ), contentPadding: const EdgeInsets.all( - 30.0, + 50.0, ), title: Text( - AppLocalizations.of(context)!.customFeed, + AppLocalizations.of(context)!.deleteCustomFeed, style: TextStyle( fontSize: 24.0, - color: useDarkMode ? Colors.white : Colors.black, ), // here textAlign: TextAlign.center, ), @@ -287,112 +158,177 @@ class _CustomeHomeFeedSettingsScreenState crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - TextField( - controller: controller, - decoration: InputDecoration( - hintText: 'https://example.com', - hintStyle: TextStyle( - color: useDarkMode - ? Colors.grey.shade400 - : Colors.grey.shade600, - ), - ), - cursorColor: - useDarkMode ? Colors.white : Colors.black, - style: TextStyle( - color: - useDarkMode ? Colors.white : Colors.black, - ), - ), - Theme( - data: ThemeData( - unselectedWidgetColor: - useDarkMode ? Colors.white : Colors.black, - fontFamily: 'Formula1', - ), - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Radio( - value: "rss", - groupValue: type, - activeColor: - Theme.of(context).primaryColor, - onChanged: (String? value) => - setState(() { - type = value!; - }), - ), - Text( - 'RSS', - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), - ), - Radio( - value: "wp", - groupValue: type, - activeColor: - Theme.of(context).primaryColor, - onChanged: (String? value) => - setState(() { - type = value!; - }), - ), - Text( - 'WordPress', - style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, - ), - ), - ], - ), - ), + Text( + AppLocalizations.of(context)!.deleteUrl, ), ], ), actions: [ ElevatedButton( onPressed: () { - Hive.box('settings').put( - 'homeFeed', - [controller.text, type], - ); - customFeeds.add([controller.text, type]); + Navigator.of(context).pop(); + }, + child: Text( + AppLocalizations.of(context)!.cancel, + ), + ), + ElevatedButton( + onPressed: () { + customFeeds.remove(feed); Hive.box('settings').put( 'customFeeds', customFeeds, ); + if (savedFeedUrl[0] == feed[0]) { + savedFeedUrl = [officialFeed, "api"]; + Hive.box('settings').put( + 'homeFeed', + savedFeedUrl, + ); + } Navigator.of(context).pop(); _setState(); widget.updateParent(); }, child: Text( - AppLocalizations.of(context)!.save, + AppLocalizations.of(context)!.yes, ), ), - ElevatedButton( - onPressed: () { - Navigator.of(context).pop(); - }, - child: Text( - AppLocalizations.of(context)!.close, + ], + ); + }), + child: InkWell( + child: RadioListTile( + value: feed[0], + title: Text( + feed[0], + ), + groupValue: savedFeedUrl[0], + activeColor: Theme.of(context).colorScheme.onPrimary, + onChanged: (value) => setState( + () { + Hive.box('settings').put('homeFeed', feed); + widget.updateParent(); + }, + ), + ), + ), + ), + ListTile( + title: Text( + AppLocalizations.of(context)!.addCustomFeed, + ), + trailing: Icon( + Icons.add_outlined, + ), + onTap: () => showDialog( + context: context, + builder: (context) { + final TextEditingController controller = + TextEditingController(); + String type = "rss"; + return StatefulBuilder( + builder: (context, setState) => AlertDialog( + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular( + 20.0, + ), + ), + ), + contentPadding: const EdgeInsets.all( + 30.0, + ), + title: Text( + AppLocalizations.of(context)!.customFeed, + style: TextStyle( + fontSize: 24.0, + ), + textAlign: TextAlign.center, + ), + content: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + controller: controller, + decoration: InputDecoration( + hintText: 'https://example.com', + hintStyle: TextStyle( + fontWeight: FontWeight.w100, + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Radio( + value: "rss", + groupValue: type, + activeColor: + Theme.of(context).colorScheme.onPrimary, + onChanged: (String? value) => setState(() { + type = value!; + }), + ), + Text( + 'RSS', + ), + Radio( + value: "wp", + groupValue: type, + activeColor: + Theme.of(context).colorScheme.onPrimary, + onChanged: (String? value) => setState(() { + type = value!; + }), + ), + Text( + 'WordPress', + ), + ], ), ), ], ), - ); - }, - ), + actions: [ + ElevatedButton( + onPressed: () { + Hive.box('settings').put( + 'homeFeed', + [controller.text, type], + ); + customFeeds.add([controller.text, type]); + Hive.box('settings').put( + 'customFeeds', + customFeeds, + ); + Navigator.of(context).pop(); + _setState(); + widget.updateParent(); + }, + child: Text( + AppLocalizations.of(context)!.save, + ), + ), + ElevatedButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text( + AppLocalizations.of(context)!.close, + ), + ), + ], + ), + ); + }, ), - ], - ), + ), + ], ), ), ); diff --git a/lib/Screens/driver_details.dart b/lib/Screens/driver_details.dart index 448941d9..ce912492 100644 --- a/lib/Screens/driver_details.dart +++ b/lib/Screens/driver_details.dart @@ -48,8 +48,6 @@ class DriverDetailsScreen extends StatelessWidget { @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; return DefaultTabController( length: 2, child: Scaffold( @@ -61,7 +59,6 @@ class DriverDetailsScreen extends StatelessWidget { ), ), bottom: TabBar( - indicatorColor: Colors.white, tabs: [ Tab( child: Text( @@ -81,10 +78,8 @@ class DriverDetailsScreen extends StatelessWidget { ), ], ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: TabBarView( children: [ DriverInfo(driverId), diff --git a/lib/Screens/free_practice_screen.dart b/lib/Screens/free_practice_screen.dart index 96dab38d..f4dfe5ee 100644 --- a/lib/Screens/free_practice_screen.dart +++ b/lib/Screens/free_practice_screen.dart @@ -17,6 +17,8 @@ * Copyright (c) 2022-2024, BrightDV */ +// TODO: md3 + import 'package:boxbox/api/driver_components.dart'; import 'package:boxbox/helpers/request_error.dart'; import 'package:boxbox/helpers/loading_indicator_util.dart'; diff --git a/lib/Screens/grand_prix_running_details.dart b/lib/Screens/grand_prix_running_details.dart index 6deadd98..0fe70811 100644 --- a/lib/Screens/grand_prix_running_details.dart +++ b/lib/Screens/grand_prix_running_details.dart @@ -17,6 +17,8 @@ * Copyright (c) 2022-2024, BrightDV */ +// TODO: md3 + import 'package:boxbox/Screens/circuit.dart'; import 'package:boxbox/api/event_tracker.dart'; import 'package:boxbox/api/race_components.dart'; diff --git a/lib/Screens/hall_of_fame.dart b/lib/Screens/hall_of_fame.dart index 0f7dd107..f221677d 100644 --- a/lib/Screens/hall_of_fame.dart +++ b/lib/Screens/hall_of_fame.dart @@ -22,22 +22,17 @@ import 'package:boxbox/helpers/request_error.dart'; import 'package:boxbox/scraping/formula_one.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -import 'package:hive_flutter/hive_flutter.dart'; class HallOfFameScreen extends StatelessWidget { const HallOfFameScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.hallOfFame), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: FutureBuilder>( future: FormulaOneScraper().scrapeHallOfFame(), builder: (context, snapshot) => snapshot.hasError @@ -62,9 +57,6 @@ class HallOfFameScreen extends StatelessWidget { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15.0), ), - color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.white, child: Column( children: [ ClipRRect( @@ -81,17 +73,9 @@ class HallOfFameScreen extends StatelessWidget { ListTile( title: Text( snapshot.data![index].driverName, - style: TextStyle( - color: - useDarkMode ? Colors.white : Colors.black, - ), ), subtitle: Text( snapshot.data![index].years, - style: TextStyle( - color: - useDarkMode ? Colors.white : Colors.black, - ), ), ), ], @@ -113,15 +97,11 @@ class HallOfFameDriverDetailsScreen extends StatelessWidget { @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; return Scaffold( appBar: AppBar( title: Text(driverName), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: FutureBuilder( future: FormulaOneScraper().scrapeHallOfFameDriverDetails(pageUrl), builder: (context, snapshot) => snapshot.hasError @@ -138,7 +118,6 @@ class HallOfFameDriverDetailsScreen extends StatelessWidget { driverName, textAlign: TextAlign.center, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 22, fontWeight: FontWeight.w500, ), @@ -149,8 +128,6 @@ class HallOfFameDriverDetailsScreen extends StatelessWidget { snapshot.data!['metaDescription'], textAlign: TextAlign.justify, style: TextStyle( - color: - useDarkMode ? Colors.white : Colors.black, fontSize: 16, fontWeight: FontWeight.w500, ), @@ -163,8 +140,6 @@ class HallOfFameDriverDetailsScreen extends StatelessWidget { textParagraph, textAlign: TextAlign.justify, style: TextStyle( - color: - useDarkMode ? Colors.white : Colors.black, fontSize: 14, ), ), diff --git a/lib/Screens/history.dart b/lib/Screens/history.dart index d7af33b1..121cf09b 100644 --- a/lib/Screens/history.dart +++ b/lib/Screens/history.dart @@ -44,6 +44,7 @@ class _HistoryScreenState extends State { title: Text( AppLocalizations.of(context)!.history, ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, actions: [ IconButton( onPressed: () => setState(() { @@ -55,15 +56,11 @@ class _HistoryScreenState extends State { ), ], ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: articlesHistory.isEmpty ? Center( child: Text( '¯\\_(ツ)_/¯', style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 40, ), ), @@ -86,7 +83,6 @@ class _HistoryScreenState extends State { }, child: Card( elevation: 5.0, - color: useDarkMode ? const Color(0xff1d1d28) : Colors.white, child: Row( children: [ Expanded( @@ -106,10 +102,6 @@ class _HistoryScreenState extends State { children: [ Text( articlesHistory[index]['articleTitle'], - style: TextStyle( - color: - useDarkMode ? Colors.white : Colors.black, - ), maxLines: 3, textAlign: TextAlign.justify, ), diff --git a/lib/Screens/links.dart b/lib/Screens/links.dart index fb3d525c..49928828 100644 --- a/lib/Screens/links.dart +++ b/lib/Screens/links.dart @@ -35,10 +35,8 @@ class LinksScreen extends StatelessWidget { title: Text( AppLocalizations.of(context)!.links, ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: Padding( padding: const EdgeInsets.only( left: 15, @@ -53,9 +51,6 @@ class LinksScreen extends StatelessWidget { child: ListTile( title: Text( 'Formula 1', - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), subtitle: Text( 'https://www.formula1.com/', @@ -67,7 +62,6 @@ class LinksScreen extends StatelessWidget { ), trailing: Icon( Icons.open_in_new_outlined, - color: useDarkMode ? Colors.white : Colors.black, ), ), ), @@ -78,9 +72,6 @@ class LinksScreen extends StatelessWidget { child: ListTile( title: Text( AppLocalizations.of(context)!.fiaRegulations, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), subtitle: Text( 'https://www.fia.com/regulation/category/110', @@ -92,7 +83,6 @@ class LinksScreen extends StatelessWidget { ), trailing: Icon( Icons.open_in_new_outlined, - color: useDarkMode ? Colors.white : Colors.black, ), ), ), @@ -103,9 +93,6 @@ class LinksScreen extends StatelessWidget { child: ListTile( title: Text( AppLocalizations.of(context)!.statistics, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), subtitle: Text( 'https://www.statsf1.com/', @@ -117,7 +104,6 @@ class LinksScreen extends StatelessWidget { ), trailing: Icon( Icons.open_in_new_outlined, - color: useDarkMode ? Colors.white : Colors.black, ), ), ), diff --git a/lib/Screens/race_details.dart b/lib/Screens/race_details.dart index fe93b642..ffb2fb14 100644 --- a/lib/Screens/race_details.dart +++ b/lib/Screens/race_details.dart @@ -52,222 +52,205 @@ class RaceDetailsScreen extends StatelessWidget { @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; - return Scaffold( - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: DefaultTabController( - length: 3, - initialIndex: tab != null - ? tab == 10 - ? 2 - : tab! - : 0, - child: Builder( - builder: (BuildContext context) { - return NestedScrollView( - headerSliverBuilder: - (BuildContext context, bool innerBoxIsScrolled) { - return [ - SliverAppBar( - expandedHeight: 200.0, - floating: false, - pinned: true, - centerTitle: true, - flexibleSpace: FlexibleSpaceBar( - background: RaceImageProvider(race), - title: Text( - race.country, - ), - ), + length: 3, + initialIndex: tab != null + ? tab == 10 + ? 2 + : tab! + : 0, + child: Builder( + builder: (BuildContext context) { + return NestedScrollView( + headerSliverBuilder: + (BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverAppBar( + expandedHeight: 200.0, + floating: false, + pinned: true, + centerTitle: true, + flexibleSpace: FlexibleSpaceBar( + background: RaceImageProvider(race), + title: Text( + race.country, ), - SliverPersistentHeader( - delegate: _SliverAppBarDelegate( - TabBar( - tabs: hasSprint - ? [ - Tab( - text: AppLocalizations.of(context)! - .freePracticeShort, - ), - Tab( - text: AppLocalizations.of(context)! - .sprint - .toUpperCase(), - ), - Tab( - text: AppLocalizations.of(context)! - .race - .toUpperCase(), - ), - ] - : [ - Tab( - text: AppLocalizations.of(context)! - .freePracticeShort, - ), - Tab( - text: AppLocalizations.of(context)! - .qualifyingsShort, - ), - Tab( - text: AppLocalizations.of(context)! - .race - .toUpperCase(), - ), - ], - labelColor: useDarkMode - ? Colors.white - : Theme.of(context).scaffoldBackgroundColor, - ), - ), - pinned: true, + ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, + ), + SliverPersistentHeader( + delegate: _SliverAppBarDelegate( + TabBar( + tabs: hasSprint + ? [ + Tab( + text: AppLocalizations.of(context)! + .freePracticeShort, + ), + Tab( + text: AppLocalizations.of(context)! + .sprint + .toUpperCase(), + ), + Tab( + text: AppLocalizations.of(context)! + .race + .toUpperCase(), + ), + ] + : [ + Tab( + text: AppLocalizations.of(context)! + .freePracticeShort, + ), + Tab( + text: AppLocalizations.of(context)! + .qualifyingsShort, + ), + Tab( + text: AppLocalizations.of(context)! + .race + .toUpperCase(), + ), + ], ), - ]; - }, - body: hasSprint - ? TabBarView( - children: [ - FreePracticesResultsProvider(race, hasSprint), - DefaultTabController( - length: 2, - initialIndex: tab == 10 ? 1 : 0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - TabBar( - tabs: [ - const Tab( - text: 'SHOOTOUT', - ), - Tab( - text: AppLocalizations.of(context)! - .results - .toUpperCase(), - ), - ], - labelColor: useDarkMode - ? Colors.white - : Theme.of(context) - .scaffoldBackgroundColor, + ), + pinned: true, + ), + ]; + }, + body: hasSprint + ? TabBarView( + children: [ + FreePracticesResultsProvider(race, hasSprint), + DefaultTabController( + length: 2, + initialIndex: tab == 10 ? 1 : 0, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + TabBar( + tabs: [ + const Tab( + text: 'SHOOTOUT', + ), + Tab( + text: AppLocalizations.of(context)! + .results + .toUpperCase(), ), - Expanded( - child: TabBarView( - children: [ - MediaQuery.removePadding( - context: context, - removeTop: true, - child: SafeArea( - child: SingleChildScrollView( - child: QualificationResultsProvider( - raceUrl: - 'https://www.formula1.com/en/results.html/${DateTime.now().year}/races/${Convert().circuitIdFromErgastToFormulaOne(race.circuitId)}/${Convert().circuitNameFromErgastToFormulaOne(race.circuitId)}/sprint-shootout.html', - hasSprint: hasSprint, - ), - ), - ), - ), - MediaQuery.removePadding( - context: context, - removeTop: true, - child: SafeArea( - child: SprintResultsProvider( - race: race, - ), - ), - ), - ], - ), - ) ], ), - ), - DefaultTabController( - length: 2, - initialIndex: tab == 10 ? 1 : 0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - TabBar( - tabs: [ - Tab( - text: AppLocalizations.of(context)! - .qualifyings - .toUpperCase(), - ), - Tab( - text: AppLocalizations.of(context)! - .results - .toUpperCase(), - ), - ], - labelColor: useDarkMode - ? Colors.white - : Theme.of(context) - .scaffoldBackgroundColor, - ), - Expanded( - child: TabBarView( - children: [ - MediaQuery.removePadding( - context: context, - removeTop: true, - child: SafeArea( - child: SingleChildScrollView( - child: QualificationResultsProvider( - race: race, - hasSprint: hasSprint, - ), - ), + Expanded( + child: TabBarView( + children: [ + MediaQuery.removePadding( + context: context, + removeTop: true, + child: SafeArea( + child: SingleChildScrollView( + child: QualificationResultsProvider( + raceUrl: + 'https://www.formula1.com/en/results.html/${DateTime.now().year}/races/${Convert().circuitIdFromErgastToFormulaOne(race.circuitId)}/${Convert().circuitNameFromErgastToFormulaOne(race.circuitId)}/sprint-shootout.html', + hasSprint: hasSprint, ), ), - MediaQuery.removePadding( - context: context, - removeTop: true, - child: SafeArea( - child: - RaceResultsProvider(race: race), - ), + ), + ), + MediaQuery.removePadding( + context: context, + removeTop: true, + child: SafeArea( + child: SprintResultsProvider( + race: race, ), - ], + ), ), + ], + ), + ) + ], + ), + ), + DefaultTabController( + length: 2, + initialIndex: tab == 10 ? 1 : 0, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + TabBar( + tabs: [ + Tab( + text: AppLocalizations.of(context)! + .qualifyings + .toUpperCase(), + ), + Tab( + text: AppLocalizations.of(context)! + .results + .toUpperCase(), ), ], ), - ), - ], - ) - : TabBarView( - children: [ - FreePracticesResultsProvider(race, hasSprint), - MediaQuery.removePadding( - context: context, - removeTop: true, - child: SafeArea( - child: SingleChildScrollView( - child: QualificationResultsProvider( - race: race, - hasSprint: hasSprint, - ), + Expanded( + child: TabBarView( + children: [ + MediaQuery.removePadding( + context: context, + removeTop: true, + child: SafeArea( + child: SingleChildScrollView( + child: QualificationResultsProvider( + race: race, + hasSprint: hasSprint, + ), + ), + ), + ), + MediaQuery.removePadding( + context: context, + removeTop: true, + child: SafeArea( + child: RaceResultsProvider(race: race), + ), + ), + ], ), ), - ), - MediaQuery.removePadding( - context: context, - removeTop: true, - child: SafeArea( - child: RaceResultsProvider(race: race), + ], + ), + ), + ], + ) + : TabBarView( + children: [ + FreePracticesResultsProvider(race, hasSprint), + MediaQuery.removePadding( + context: context, + removeTop: true, + child: SafeArea( + child: SingleChildScrollView( + child: QualificationResultsProvider( + race: race, + hasSprint: hasSprint, ), ), - ], + ), ), - ); - }, - ), - )); + MediaQuery.removePadding( + context: context, + removeTop: true, + child: SafeArea( + child: RaceResultsProvider(race: race), + ), + ), + ], + ), + ); + }, + ), + )); } } @@ -284,14 +267,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { @override Widget build( BuildContext context, double shrinkOffset, bool overlapsContent) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; - return Container( - color: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, - child: _tabBar, - ); + return _tabBar; } @override @@ -321,8 +297,7 @@ class _FreePracticesResultsProviderState Widget build(BuildContext context) { final Race race = widget.race; final bool hasSprint = widget.hasSprint; - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; + final List sessionsTitle = [ AppLocalizations.of(context)!.freePracticeOne, AppLocalizations.of(context)!.freePracticeTwo, @@ -345,9 +320,6 @@ class _FreePracticesResultsProviderState child: Text( AppLocalizations.of(context)!.dataNotAvailable, textAlign: TextAlign.center, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), ), ) @@ -357,10 +329,6 @@ class _FreePracticesResultsProviderState ? ListTile( title: Text( sessionsTitle[index], - style: TextStyle( - color: - useDarkMode ? Colors.white : Colors.black, - ), textAlign: TextAlign.center, ), onTap: () => Navigator.push( @@ -386,9 +354,6 @@ class _FreePracticesResultsProviderState Text( sessionsTitle[index], style: TextStyle( - color: useDarkMode - ? Colors.white - : Colors.black, fontSize: 20, fontWeight: FontWeight.w500, ), @@ -403,11 +368,7 @@ class _FreePracticesResultsProviderState padding: const EdgeInsets.only( top: 25, ), - child: Divider( - color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.grey.shade400, - ), + child: Divider(), ), ], ), @@ -473,7 +434,7 @@ class _RaceResultsProviderState extends State { raceFullDateParsed, ); } - if (timeToRace > 0) { + if (timeToRace < 0) { return SessionCountdownTimer( race, 4, @@ -492,9 +453,6 @@ class _RaceResultsProviderState extends State { child: Text( AppLocalizations.of(context)!.dataNotAvailable, textAlign: TextAlign.center, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), ), ); diff --git a/lib/Screens/schedule.dart b/lib/Screens/schedule.dart index e7e5da7c..eccd096e 100644 --- a/lib/Screens/schedule.dart +++ b/lib/Screens/schedule.dart @@ -33,15 +33,11 @@ class ScheduleScreen extends StatelessWidget { @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; return DefaultTabController( length: 2, initialIndex: 1, child: Scaffold( - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, + extendBodyBehindAppBar: true, body: TabBarView( children: [ ScheduleWidget( @@ -60,8 +56,8 @@ class ScheduleScreen extends StatelessWidget { height: 50, child: Card( elevation: 3, - color: Theme.of(context).primaryColor, child: TabBar( + dividerColor: Colors.transparent, tabs: [ Text( AppLocalizations.of(context)!.previous, @@ -152,13 +148,10 @@ class EmptySchedule extends StatelessWidget { @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; return Center( child: Text( AppLocalizations.of(context)!.nothingHere, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontWeight: FontWeight.w500, fontSize: 30, ), diff --git a/lib/Screens/search.dart b/lib/Screens/search.dart index 014557c3..48a3af3b 100644 --- a/lib/Screens/search.dart +++ b/lib/Screens/search.dart @@ -17,6 +17,8 @@ * Copyright (c) 2022-2024, BrightDV */ +// TODO: md3 + import 'package:boxbox/Screens/article.dart'; import 'package:boxbox/api/searx.dart'; import 'package:flutter/material.dart'; diff --git a/lib/Screens/server_settings.dart b/lib/Screens/server_settings.dart index dfff1788..cbf74ae1 100644 --- a/lib/Screens/server_settings.dart +++ b/lib/Screens/server_settings.dart @@ -33,8 +33,6 @@ class _ServerSettingsScreenState extends State { @override Widget build(BuildContext context) { const String officialServer = "https://api.formula1.com"; - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; List customServers = Hive.box('settings').get('customServers', defaultValue: []) as List; String savedServer = Hive.box('settings') @@ -46,11 +44,14 @@ class _ServerSettingsScreenState extends State { return Scaffold( appBar: AppBar( - title: Text(AppLocalizations.of(context)!.server), + title: Text( + AppLocalizations.of(context)!.server, + style: const TextStyle( + fontWeight: FontWeight.w600, + ), + ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: SingleChildScrollView( child: Column( children: [ @@ -58,12 +59,8 @@ class _ServerSettingsScreenState extends State { value: officialServer, title: Text( AppLocalizations.of(context)!.official, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), groupValue: savedServer, - activeColor: Theme.of(context).primaryColor, onChanged: (value) => setState( () { savedServer = value!; @@ -78,9 +75,6 @@ class _ServerSettingsScreenState extends State { context: context, builder: (context) { return AlertDialog( - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all( Radius.circular( @@ -95,7 +89,6 @@ class _ServerSettingsScreenState extends State { AppLocalizations.of(context)!.deleteCustomFeed, style: TextStyle( fontSize: 24.0, - color: useDarkMode ? Colors.white : Colors.black, ), // here textAlign: TextAlign.center, ), @@ -106,10 +99,6 @@ class _ServerSettingsScreenState extends State { children: [ Text( AppLocalizations.of(context)!.deleteUrl, - style: TextStyle( - color: - useDarkMode ? Colors.white : Colors.black, - ), ), ], ), @@ -151,12 +140,8 @@ class _ServerSettingsScreenState extends State { value: server, title: Text( server, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), groupValue: savedServer, - activeColor: Theme.of(context).primaryColor, onChanged: (value) => setState( () { Hive.box('settings').put('server', server); @@ -169,13 +154,9 @@ class _ServerSettingsScreenState extends State { ListTile( title: Text( AppLocalizations.of(context)!.addCustomServer, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), trailing: Icon( Icons.add_outlined, - color: useDarkMode ? Colors.white : Colors.black, ), onTap: () => showDialog( context: context, @@ -184,9 +165,6 @@ class _ServerSettingsScreenState extends State { TextEditingController(); return StatefulBuilder( builder: (context, setState) => AlertDialog( - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all( Radius.circular( @@ -201,7 +179,6 @@ class _ServerSettingsScreenState extends State { AppLocalizations.of(context)!.customServer, style: TextStyle( fontSize: 24.0, - color: useDarkMode ? Colors.white : Colors.black, ), // here textAlign: TextAlign.center, ), @@ -215,16 +192,9 @@ class _ServerSettingsScreenState extends State { decoration: InputDecoration( hintText: 'https://example.com', hintStyle: TextStyle( - color: useDarkMode - ? Colors.grey.shade400 - : Colors.grey.shade600, + fontWeight: FontWeight.w100, ), ), - cursorColor: - useDarkMode ? Colors.white : Colors.black, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), ], ), diff --git a/lib/Screens/session_screen.dart b/lib/Screens/session_screen.dart index 4ea11b0b..a9f8541b 100644 --- a/lib/Screens/session_screen.dart +++ b/lib/Screens/session_screen.dart @@ -17,6 +17,8 @@ * Copyright (c) 2022-2024, BrightDV */ +// TODO: md3 + import 'dart:async'; import 'package:boxbox/Screens/free_practice_screen.dart'; diff --git a/lib/Screens/settings.dart b/lib/Screens/settings.dart index 71b68a72..ba29af43 100644 --- a/lib/Screens/settings.dart +++ b/lib/Screens/settings.dart @@ -45,9 +45,6 @@ class _SettingsScreenState extends State { bool useDarkMode = Hive.box('settings').get('darkMode', defaultValue: true) as bool; return Scaffold( - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, appBar: AppBar( title: Text( AppLocalizations.of(context)!.settings, @@ -55,6 +52,7 @@ class _SettingsScreenState extends State { fontWeight: FontWeight.w600, ), ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), body: SingleChildScrollView( child: Stack( @@ -62,7 +60,7 @@ class _SettingsScreenState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - AppearanceCard(_settingsSetState), + AppearanceCard(), PlayerCard(useDarkMode), OtherCard(_settingsSetState), ], @@ -75,8 +73,7 @@ class _SettingsScreenState extends State { } class AppearanceCard extends StatefulWidget { - final Function update; - const AppearanceCard(this.update, {Key? key}) : super(key: key); + const AppearanceCard({Key? key}) : super(key: key); @override State createState() => _AppearanceCardState(); @@ -155,7 +152,6 @@ class _AppearanceCardState extends State { child: Text( AppLocalizations.of(context)!.appearance, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontWeight: FontWeight.w500, fontSize: 20, ), @@ -164,16 +160,10 @@ class _AppearanceCardState extends State { ListTile( title: Text( AppLocalizations.of(context)!.theme, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), onTap: () {}, trailing: DropdownButton( value: themeMode, - dropdownColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, onChanged: (int? newThemeMode) { if (newThemeMode != null) { setState( @@ -198,7 +188,6 @@ class _AppearanceCardState extends State { themeMode = newThemeMode; useDarkMode = newValue; }); - widget.update(); }, ); } @@ -211,7 +200,6 @@ class _AppearanceCardState extends State { themeOptions[value], style: TextStyle( fontSize: 12, - color: useDarkMode ? Colors.white : Colors.black, ), ), ); @@ -222,23 +210,16 @@ class _AppearanceCardState extends State { ListTile( title: Text( AppLocalizations.of(context)!.teamColors, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), subtitle: Text( AppLocalizations.of(context)!.needsRestart, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 13, ), ), onTap: () {}, trailing: DropdownButton( value: teamTheme, - dropdownColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, onChanged: (String? newTeamTheme) { if (newTeamTheme != null) { setState( @@ -270,13 +251,23 @@ class _AppearanceCardState extends State { light: ThemeData( useMaterial3: true, brightness: Brightness.light, - colorSchemeSeed: color, + colorScheme: ColorScheme.fromSeed( + seedColor: color, + onPrimary: color, + brightness: Brightness.light, + ), fontFamily: 'Formula1', ), dark: ThemeData( useMaterial3: true, brightness: Brightness.dark, - colorSchemeSeed: color, + colorScheme: ColorScheme.fromSeed( + seedColor: color, + onPrimary: HSLColor.fromColor(color) + .withLightness(0.4) + .toColor(), + brightness: Brightness.dark, + ), fontFamily: 'Formula1', ), ); @@ -293,7 +284,6 @@ class _AppearanceCardState extends State { value!, style: TextStyle( fontSize: 12, - color: useDarkMode ? Colors.white : Colors.black, ), ), ); @@ -304,16 +294,10 @@ class _AppearanceCardState extends State { ListTile( title: Text( AppLocalizations.of(context)!.newsLayout, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), onTap: () {}, trailing: DropdownButton( value: newsLayoutFormated, - dropdownColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, onChanged: (newValue) { if (newValue != null) { setState( @@ -330,7 +314,6 @@ class _AppearanceCardState extends State { Hive.box('settings').put('newsLayout', newsLayout); }, ); - widget.update(); } }, items: [ @@ -357,22 +340,15 @@ class _AppearanceCardState extends State { ListTile( title: Text( AppLocalizations.of(context)!.font, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), subtitle: Text( AppLocalizations.of(context)!.fontDescription, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 13, ), ), trailing: DropdownButton( value: fontUsedInArticles, - dropdownColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, onChanged: (newValue) { if (newValue != null) { setState( @@ -387,7 +363,6 @@ class _AppearanceCardState extends State { .put('fontUsedInArticles', fontUsedInArticles); }, ); - widget.update(); } }, items: [ @@ -402,7 +377,6 @@ class _AppearanceCardState extends State { value, style: TextStyle( fontSize: 12, - color: useDarkMode ? Colors.white : Colors.black, ), ), ); @@ -440,7 +414,6 @@ class _PlayerCardState extends State { child: Text( AppLocalizations.of(context)!.player, style: TextStyle( - color: widget.useDarkMode ? Colors.white : Colors.black, fontWeight: FontWeight.w500, fontSize: 20, ), @@ -449,23 +422,17 @@ class _PlayerCardState extends State { ListTile( title: Text( AppLocalizations.of(context)!.playerQuality, - style: TextStyle( - color: widget.useDarkMode ? Colors.white : Colors.black, - ), + style: TextStyle(), ), subtitle: Text( AppLocalizations.of(context)!.playerQualitySub, style: TextStyle( - color: widget.useDarkMode ? Colors.white : Colors.black, fontSize: 13, ), ), onTap: () {}, trailing: DropdownButton( value: playerQuality, - dropdownColor: widget.useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, onChanged: (int? newValue) { if (newValue != null) { setState( @@ -488,7 +455,6 @@ class _PlayerCardState extends State { '${value}p', style: TextStyle( fontSize: 12, - color: widget.useDarkMode ? Colors.white : Colors.black, ), ), ); @@ -499,23 +465,16 @@ class _PlayerCardState extends State { ListTile( title: Text( 'Piped Proxy URL', - style: TextStyle( - color: widget.useDarkMode ? Colors.white : Colors.black, - ), ), subtitle: Text( AppLocalizations.of(context)!.pipedApiUrlSub, style: TextStyle( - color: widget.useDarkMode ? Colors.white : Colors.black, fontSize: 13, ), ), onTap: () {}, trailing: DropdownButton( value: pipedApiUrl, - dropdownColor: widget.useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, onChanged: (String? newValue) { if (newValue != null) { setState( @@ -540,7 +499,6 @@ class _PlayerCardState extends State { value, style: TextStyle( fontSize: 12, - color: widget.useDarkMode ? Colors.white : Colors.black, ), ), ); @@ -563,8 +521,6 @@ class OtherCard extends StatefulWidget { class _OtherCardstate extends State { @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; bool useDataSaverMode = Hive.box('settings') .get('useDataSaverMode', defaultValue: false) as bool; bool enableExperimentalFeatures = Hive.box('settings') @@ -580,7 +536,6 @@ class _OtherCardstate extends State { child: Text( AppLocalizations.of(context)!.other, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontWeight: FontWeight.w500, fontSize: 20, ), @@ -589,13 +544,9 @@ class _OtherCardstate extends State { ListTile( title: Text( AppLocalizations.of(context)!.formulaYouSettings, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), trailing: Icon( Icons.arrow_forward_rounded, - color: useDarkMode ? Colors.white : Colors.black, ), onTap: () => Navigator.push( context, @@ -607,9 +558,6 @@ class _OtherCardstate extends State { ListTile( title: Text( AppLocalizations.of(context)!.news, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), onTap: () => Navigator.push( context, @@ -621,15 +569,11 @@ class _OtherCardstate extends State { ), trailing: Icon( Icons.arrow_forward_rounded, - color: useDarkMode ? Colors.white : Colors.black, ), ), ListTile( title: Text( AppLocalizations.of(context)!.server, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), onTap: () => Navigator.push( context, @@ -641,20 +585,15 @@ class _OtherCardstate extends State { ), trailing: Icon( Icons.arrow_forward_rounded, - color: useDarkMode ? Colors.white : Colors.black, ), ), SwitchListTile( title: Text( AppLocalizations.of(context)!.dataSaverMode, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), subtitle: Text( AppLocalizations.of(context)!.dataSaverModeSub, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 13, ), ), @@ -674,16 +613,15 @@ class _OtherCardstate extends State { SwitchListTile( title: Text( AppLocalizations.of(context)!.experimentalFeatures, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), ), value: enableExperimentalFeatures, onChanged: (bool value) { - setState(() { - enableExperimentalFeatures = value; - Hive.box('settings').put('enableExperimentalFeatures', value); - }); + setState( + () { + enableExperimentalFeatures = value; + Hive.box('settings').put('enableExperimentalFeatures', value); + }, + ); }, ), ], diff --git a/lib/Screens/standings.dart b/lib/Screens/standings.dart index 402a9e5e..21cb0ce5 100644 --- a/lib/Screens/standings.dart +++ b/lib/Screens/standings.dart @@ -43,6 +43,7 @@ class StandingsScreen extends StatelessWidget { length: 2, initialIndex: switchToTeamStandings != null ? 1 : 0, child: Scaffold( + extendBodyBehindAppBar: true, body: TabBarView( children: [ DriversStandingsWidget(scrollController: scrollController), @@ -56,6 +57,7 @@ class StandingsScreen extends StatelessWidget { child: Card( elevation: 3, child: TabBar( + dividerColor: Colors.transparent, tabs: [ Text( AppLocalizations.of(context)!.drivers, diff --git a/lib/Screens/team_details.dart b/lib/Screens/team_details.dart index 20fa43e6..2f097231 100644 --- a/lib/Screens/team_details.dart +++ b/lib/Screens/team_details.dart @@ -41,8 +41,6 @@ class TeamDetailsScreen extends StatelessWidget { @override Widget build(BuildContext context) { - bool useDarkMode = - Hive.box('settings').get('darkMode', defaultValue: true) as bool; return DefaultTabController( length: 2, child: Scaffold( @@ -54,7 +52,6 @@ class TeamDetailsScreen extends StatelessWidget { ), ), bottom: TabBar( - indicatorColor: Colors.white, tabs: [ Tab( child: Text( @@ -74,10 +71,8 @@ class TeamDetailsScreen extends StatelessWidget { ), ], ), + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: TabBarView( children: [ Padding( @@ -138,7 +133,6 @@ class TeamDetailsFragment extends StatelessWidget { textAlign: TextAlign.center, style: TextStyle( fontWeight: FontWeight.w600, - color: useDarkMode ? Colors.white : Colors.black, ), ), ), @@ -158,7 +152,6 @@ class TeamDetailsFragment extends StatelessWidget { textAlign: TextAlign.center, style: TextStyle( fontWeight: FontWeight.w600, - color: useDarkMode ? Colors.white : Colors.black, ), ), ), @@ -188,7 +181,6 @@ class TeamDetailsFragment extends StatelessWidget { teamDetails["teamStats"]["attributes"][i], textAlign: TextAlign.start, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 14, ), ), @@ -198,9 +190,7 @@ class TeamDetailsFragment extends StatelessWidget { child: Text( teamDetails["teamStats"]["values"][i], textAlign: TextAlign.start, - style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), + style: TextStyle(), ), ), ], @@ -214,7 +204,6 @@ class TeamDetailsFragment extends StatelessWidget { Text( AppLocalizations.of(context)!.news, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 18, ), ), @@ -269,27 +258,30 @@ class TeamDetailsFragment extends StatelessWidget { ], ), Padding( - padding: const EdgeInsets.only(top: 15), + padding: const EdgeInsets.only(top: 15, left: 5, right: 5), child: MarkdownBody( data: teamDetails["information"].join("\n"), + fitContent: false, styleSheet: MarkdownStyleSheet( - p: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, - ), + p: TextStyle(), pPadding: const EdgeInsets.only( top: 10, bottom: 10, ), a: const TextStyle(fontSize: 0), h1: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontWeight: FontWeight.w500, ), h3: TextStyle( - color: Theme.of(context).primaryColor, + color: useDarkMode + ? HSLColor.fromColor( + Theme.of(context).colorScheme.onPrimary, + ).withLightness(0.35).toColor() + : Theme.of(context).colorScheme.onPrimary, fontWeight: FontWeight.w500, fontSize: 16, ), + textAlign: WrapAlignment.spaceEvenly, ), ), ), @@ -302,7 +294,6 @@ class TeamDetailsFragment extends StatelessWidget { child: Text( AppLocalizations.of(context)!.gallery, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 18, ), ), @@ -322,7 +313,6 @@ class TeamDetailsFragment extends StatelessWidget { child: Text( teamDetails["medias"]["captions"][i].toString(), style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontSize: 12, ), textAlign: TextAlign.justify, @@ -332,7 +322,7 @@ class TeamDetailsFragment extends StatelessWidget { ), ], options: CarouselOptions( - height: 350, + height: 351, autoPlay: true, viewportFraction: 0.85, autoPlayInterval: const Duration(seconds: 7), diff --git a/lib/Screens/test.dart b/lib/Screens/test.dart index d5e2316a..fe5825ba 100644 --- a/lib/Screens/test.dart +++ b/lib/Screens/test.dart @@ -17,6 +17,8 @@ * Copyright (c) 2022-2024, BrightDV */ +// TODO: md3 + import 'package:flutter/material.dart'; import 'package:boxbox/Screens/article.dart'; diff --git a/lib/Screens/video.dart b/lib/Screens/video.dart index 2a598776..bd23a471 100644 --- a/lib/Screens/video.dart +++ b/lib/Screens/video.dart @@ -78,10 +78,8 @@ class _VideoScreenState extends State { ), ), ], + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), - backgroundColor: useDarkMode - ? Theme.of(context).scaffoldBackgroundColor - : Colors.white, body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -128,7 +126,6 @@ class _VideoScreenState extends State { child: Text( video.caption, style: TextStyle( - color: useDarkMode ? Colors.white : Colors.black, fontFamily: fontUsedInArticles, fontSize: 22, fontWeight: FontWeight.w500, @@ -140,8 +137,6 @@ class _VideoScreenState extends State { child: Text( video.description, style: TextStyle( - color: - useDarkMode ? Colors.grey.shade400 : Colors.grey.shade600, fontFamily: fontUsedInArticles, fontSize: 17, ), diff --git a/lib/Screens/videos.dart b/lib/Screens/videos.dart index 351f28c9..4b72d097 100644 --- a/lib/Screens/videos.dart +++ b/lib/Screens/videos.dart @@ -363,7 +363,7 @@ class VideoItem extends StatelessWidget { itemCount: videos.length, scrollDirection: Axis.vertical, control: SwiperControl( - disableColor: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.onPrimary, ), index: index, loop: false, diff --git a/lib/api/article_parts.dart b/lib/api/article_parts.dart index f8a52ded..df1fc531 100644 --- a/lib/api/article_parts.dart +++ b/lib/api/article_parts.dart @@ -260,7 +260,6 @@ class WidgetsList extends StatelessWidget { padding: const EdgeInsets.all(7), child: Text( tag['fields']['tagName'], - ), ), ), @@ -1437,8 +1436,14 @@ class WidgetsList extends StatelessWidget { width: double.infinity, decoration: BoxDecoration( color: useDarkMode - ? const Color(0xff1d1d28) - : Colors.grey.shade400, + ? HSLColor.fromColor( + Theme.of(context).colorScheme.background, + ).withLightness(0.2).toColor() + : HSLColor.fromColor( + Theme.of(context) + .colorScheme + .background, // TODO: update light mode + ).withLightness(0.2).toColor(), borderRadius: BorderRadius.circular(5), ), child: Padding( @@ -1467,7 +1472,11 @@ class WidgetsList extends StatelessWidget { Text( article.authorDetails["fullName"], style: TextStyle( - color: Theme.of(context).primaryColor, + color: useDarkMode + ? HSLColor.fromColor( + Theme.of(context).colorScheme.onPrimary, + ).withLightness(0.35).toColor() + : Theme.of(context).colorScheme.onPrimary, fontWeight: FontWeight.w500, fontSize: 14, ), diff --git a/lib/api/ergast.dart b/lib/api/ergast.dart index 3cefdfd9..e6e4ee0f 100644 --- a/lib/api/ergast.dart +++ b/lib/api/ergast.dart @@ -89,7 +89,7 @@ class _ErgastApiCalls { return formatRaceStandings(results); } else { var url = Uri.parse( - 'https://ergast.com/api/f1/${DateTime.now().year}/$round/results.json', + 'https://ergast.com/api/f1/2023/$round/results.json', // TODO: revert ); var response = await http.get(url); Map responseAsJson = jsonDecode(response.body); diff --git a/lib/api/race_components.dart b/lib/api/race_components.dart index 7ee760ce..313e0474 100644 --- a/lib/api/race_components.dart +++ b/lib/api/race_components.dart @@ -141,9 +141,8 @@ class RaceListItem extends StatelessWidget { color: useDarkMode ? index % 2 == 0 ? HSLColor.fromColor( - Theme.of(context).colorScheme.background) - .withLightness(0.2) - .toColor() + Theme.of(context).colorScheme.background, + ).withLightness(0.2).toColor() : Theme.of(context).colorScheme.secondaryContainer : const Color.fromARGB(255, 136, 135, 135), ), diff --git a/lib/helpers/bottom_navigation_bar.dart b/lib/helpers/bottom_navigation_bar.dart index 4d4e520c..6dfb6883 100644 --- a/lib/helpers/bottom_navigation_bar.dart +++ b/lib/helpers/bottom_navigation_bar.dart @@ -197,7 +197,7 @@ class _MainBottomNavigationBarState extends State { filterItems.indexOf(filterItem) ? Theme.of(context) .colorScheme - .onSecondary + .onPrimary : Colors.transparent, ), child: Padding( @@ -244,6 +244,8 @@ class _MainBottomNavigationBarState extends State { title: Text( filterItems[pressed], ), + backgroundColor: + Theme.of(context).colorScheme.onPrimary, ), backgroundColor: useDarkMode ? Theme.of(context).scaffoldBackgroundColor @@ -280,6 +282,7 @@ class _MainBottomNavigationBarState extends State { ), ), actions: actions, + backgroundColor: Theme.of(context).colorScheme.onPrimary, ), drawer: MainDrawer(_homeSetState), drawerEdgeDragWidth: MediaQuery.of(context).size.width / 4, @@ -341,6 +344,11 @@ class _MainBottomNavigationBarState extends State { type: BottomNavigationBarType.fixed, unselectedItemColor: useDarkMode ? Colors.white : Colors.grey[600], + selectedItemColor: useDarkMode + ? HSLColor.fromColor( + Theme.of(context).colorScheme.onPrimary, + ).withLightness(0.4).toColor() + : Theme.of(context).colorScheme.onPrimary, currentIndex: _selectedIndex, elevation: 10.0, items: [ diff --git a/lib/helpers/convert_ergast_and_formula_one.dart b/lib/helpers/convert_ergast_and_formula_one.dart index e5513463..2727f3db 100644 --- a/lib/helpers/convert_ergast_and_formula_one.dart +++ b/lib/helpers/convert_ergast_and_formula_one.dart @@ -52,7 +52,7 @@ class Convert { String circuitIdFromErgastToFormulaOne(String circuitId) { Map ergastToFormulaOne = { - 'bahrain': '1229', + 'bahrain': '1141', // TODO: revert 'jeddah': '1230', 'albert_park': '1231', 'suzuka': '1232', diff --git a/lib/helpers/drawer.dart b/lib/helpers/drawer.dart index 07055824..5b12255d 100644 --- a/lib/helpers/drawer.dart +++ b/lib/helpers/drawer.dart @@ -44,12 +44,11 @@ class MainDrawer extends StatelessWidget { .get('enableExperimentalFeatures', defaultValue: false) as bool; return Drawer( - backgroundColor: Theme.of(context).scaffoldBackgroundColor, child: Column( children: [ DrawerHeader( decoration: BoxDecoration( - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.onPrimary, ), child: const Center( child: Text( diff --git a/lib/helpers/driver_result_item.dart b/lib/helpers/driver_result_item.dart index ccacf491..97ea0e20 100644 --- a/lib/helpers/driver_result_item.dart +++ b/lib/helpers/driver_result_item.dart @@ -24,6 +24,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:fluttertoast/fluttertoast.dart'; +// TODO: md3 + class DriverResultItem extends StatelessWidget { final DriverResult item; final int index; diff --git a/lib/helpers/live_session_status_indicator.dart b/lib/helpers/live_session_status_indicator.dart index 01d2121e..b42463ec 100644 --- a/lib/helpers/live_session_status_indicator.dart +++ b/lib/helpers/live_session_status_indicator.dart @@ -19,6 +19,8 @@ * Copyright (c) 2022-2024, BrightDV */ +// TODO: md3 + import 'package:boxbox/api/event_tracker.dart'; import 'package:boxbox/Screens/grand_prix_running_details.dart'; import 'package:flutter/material.dart'; diff --git a/lib/helpers/loading_indicator_util.dart b/lib/helpers/loading_indicator_util.dart index 7cc4821b..7c18651c 100644 --- a/lib/helpers/loading_indicator_util.dart +++ b/lib/helpers/loading_indicator_util.dart @@ -47,7 +47,7 @@ class LoadingIndicatorUtil extends StatelessWidget { child: LoadingIndicator( indicatorType: Indicator.values[15], colors: [ - Theme.of(context).primaryColor, + Theme.of(context).colorScheme.onPrimary, // TODO: HSL ], strokeWidth: 2.0, ), diff --git a/lib/helpers/news.dart b/lib/helpers/news.dart index 7c1d3ab1..ac1e2a3c 100644 --- a/lib/helpers/news.dart +++ b/lib/helpers/news.dart @@ -457,7 +457,8 @@ class NewsItem extends StatelessWidget { ), ], color: Theme.of(context) - .primaryColorDark, + .colorScheme + .onPrimary, ), child: Row( mainAxisSize: @@ -1177,6 +1178,7 @@ class TextParagraphRenderer extends StatelessWidget { child: MarkdownBody( data: text, selectable: true, + fitContent: false, onTapLink: (text, url, title) { if (url!.startsWith('https://www.formula1.com/en/latest/article.')) { String articleId = url.substring(43, url.length - 5).split('.')[1]; @@ -1295,6 +1297,11 @@ class TextParagraphRenderer extends StatelessWidget { strong: TextStyle( fontSize: fontUsedInArticles == 'Formula1' ? 16 : 20, fontWeight: FontWeight.w500, + color: useDarkMode + ? HSLColor.fromColor( + Theme.of(context).colorScheme.onPrimary, + ).withLightness(0.35).toColor() + : Theme.of(context).colorScheme.onPrimary, ), p: TextStyle( fontSize: fontUsedInArticles == 'Formula1' ? 14 : 18, @@ -1306,9 +1313,17 @@ class TextParagraphRenderer extends StatelessWidget { bottom: fontUsedInArticles == 'Formula1' ? 10 : 7, ), a: TextStyle( - color: Theme.of(context).colorScheme.outline, + color: useDarkMode + ? HSLColor.fromColor( + Theme.of(context).colorScheme.onPrimary, + ).withLightness(0.35).toColor() + : Theme.of(context).colorScheme.onPrimary, decoration: TextDecoration.underline, - decorationColor: Theme.of(context).colorScheme.outline, + decorationColor: useDarkMode + ? HSLColor.fromColor( + Theme.of(context).colorScheme.onPrimary, + ).withLightness(0.35).toColor() + : Theme.of(context).colorScheme.onPrimary, fontWeight: FontWeight.normal, fontFamily: fontUsedInArticles, ), @@ -1332,6 +1347,7 @@ class TextParagraphRenderer extends StatelessWidget { color: useDarkMode ? Colors.white : Colors.black, fontFamily: fontUsedInArticles, ), + textAlign: WrapAlignment.spaceEvenly, ), ), ); @@ -1885,6 +1901,7 @@ class VideoRenderer extends StatelessWidget { snapshot.data!, autoplay == null ? false : autoplay!, heroTag ?? '', + Theme.of(context).primaryColor, ), if (caption != null) Padding( @@ -1920,11 +1937,13 @@ class BetterPlayerVideoPlayer extends StatefulWidget { final Map videoUrls; final bool autoplay; final String heroTag; + final Color primaryColor; const BetterPlayerVideoPlayer( this.videoUrls, this.autoplay, - this.heroTag, { + this.heroTag, + this.primaryColor, { Key? key, }) : super(key: key); @@ -1979,9 +1998,9 @@ class _BetterPlayerVideoPlayerState extends State { controlsConfiguration: BetterPlayerControlsConfiguration( enableAudioTracks: false, enableSubtitles: false, - overflowModalColor: - useDarkMode ? const Color(0xff1d1d28) : Colors.white, - overflowMenuIconsColor: useDarkMode ? Colors.white : Colors.black, + overflowModalColor: widget.primaryColor, + overflowMenuIconsColor: + useDarkMode ? Colors.white : Colors.black, // TODO: check light mode overflowModalTextColor: useDarkMode ? Colors.white : Colors.black, showControlsOnInitialize: false, ), diff --git a/lib/helpers/request_error.dart b/lib/helpers/request_error.dart index e824061e..31286027 100644 --- a/lib/helpers/request_error.dart +++ b/lib/helpers/request_error.dart @@ -17,6 +17,8 @@ * Copyright (c) 2022-2024, BrightDV */ +// TODO: md3 + import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:hive_flutter/hive_flutter.dart'; diff --git a/lib/helpers/route_handler.dart b/lib/helpers/route_handler.dart index 2074f9c4..50be4c3c 100644 --- a/lib/helpers/route_handler.dart +++ b/lib/helpers/route_handler.dart @@ -27,6 +27,8 @@ import 'package:boxbox/helpers/request_error.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +// TODO: open *only* formula1.com links + class HandleRoute { static Route? handleRoute(String? url) { if (url == null) return null; diff --git a/lib/helpers/team_background_color.dart b/lib/helpers/team_background_color.dart index 4facdb01..5f235549 100644 --- a/lib/helpers/team_background_color.dart +++ b/lib/helpers/team_background_color.dart @@ -19,6 +19,8 @@ import 'package:flutter/material.dart'; +// TODO: update colors + class TeamBackgroundColor { final Map> teamsGradientColors = { "mercedes": [ diff --git a/lib/helpers/team_car_image.dart b/lib/helpers/team_car_image.dart index 4c497ffe..6cf8e1a7 100644 --- a/lib/helpers/team_car_image.dart +++ b/lib/helpers/team_car_image.dart @@ -17,6 +17,8 @@ * Copyright (c) 2022-${DateTime.now().year}, BrightDV */ +// TODO: update urls (kick & rb) + class TeamCarImage { Map teamCarDecoder = { "ferrari": diff --git a/lib/theme/teams_themes.dart b/lib/theme/teams_themes.dart index 95d40b34..566e1177 100644 --- a/lib/theme/teams_themes.dart +++ b/lib/theme/teams_themes.dart @@ -17,6 +17,8 @@ * Copyright (c) 2022-2024, BrightDV */ +// TODO: update colors + import 'package:flutter/material.dart'; class TeamsThemes {