diff --git a/lib/eval/model/document.dart b/lib/eval/model/document.dart index f8dd3a1a..f2d32053 100644 --- a/lib/eval/model/document.dart +++ b/lib/eval/model/document.dart @@ -1,6 +1,6 @@ import 'package:html/dom.dart'; import 'package:mangayomi/eval/model/element.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/dom_extensions.dart'; class MDocument { const MDocument(this._document); diff --git a/lib/eval/model/element.dart b/lib/eval/model/element.dart index 9e6a93f4..f4071ff7 100644 --- a/lib/eval/model/element.dart +++ b/lib/eval/model/element.dart @@ -1,5 +1,5 @@ import 'package:html/dom.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/dom_extensions.dart'; class MElement { MElement(this._element); diff --git a/lib/eval/model/m_bridge.dart b/lib/eval/model/m_bridge.dart index 147a70c3..07e94e0d 100644 --- a/lib/eval/model/m_bridge.dart +++ b/lib/eval/model/m_bridge.dart @@ -36,7 +36,7 @@ import 'package:mangayomi/services/cloudflare/cloudflare.dart'; import 'package:mangayomi/utils/constant.dart'; import 'package:mangayomi/utils/cryptoaes/crypto_aes.dart'; import 'package:mangayomi/utils/cryptoaes/deobfuscator.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:mangayomi/utils/reg_exp_matcher.dart'; import 'package:mangayomi/utils/xpath_selector.dart'; import 'package:xpath_selector_html_parser/xpath_selector_html_parser.dart'; diff --git a/lib/modules/anime/anime_player_view.dart b/lib/modules/anime/anime_player_view.dart index f97346ba..00e26326 100644 --- a/lib/modules/anime/anime_player_view.dart +++ b/lib/modules/anime/anime_player_view.dart @@ -16,7 +16,7 @@ import 'package:mangayomi/modules/more/settings/player/providers/player_state_pr import 'package:mangayomi/modules/widgets/progress_center.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; import 'package:mangayomi/services/get_video_list.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:media_kit/media_kit.dart'; import 'package:media_kit_video/media_kit_video.dart'; import 'package:media_kit_video/media_kit_video_controls/src/controls/extensions/duration.dart'; @@ -395,7 +395,7 @@ class _AnimeStreamPageState extends riv.ConsumerState { Container( color: Colors.white, width: 0.2, - height: mediaHeight(context, 1)), + height: context.mediaHeight(1)), Expanded( child: SingleChildScrollView( child: Column( @@ -429,7 +429,7 @@ class _AnimeStreamPageState extends riv.ConsumerState { Container( color: Colors.white, width: 0.2, - height: mediaHeight(context, 1)), + height: context.mediaHeight(1)), Expanded( child: SingleChildScrollView( child: Column( @@ -979,7 +979,7 @@ class _AnimeStreamPageState extends riv.ConsumerState { child: ListTile( dense: true, title: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: Text( widget.episode.manga.value!.name!, style: const TextStyle( @@ -988,7 +988,7 @@ class _AnimeStreamPageState extends riv.ConsumerState { ), ), subtitle: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: Text( widget.episode.name!, style: TextStyle( @@ -1009,8 +1009,8 @@ class _AnimeStreamPageState extends riv.ConsumerState { if (mounted) { _key.currentState?.update( fit: fit, - width: mediaWidth(context, 1), - height: mediaHeight(context, 1)); + width: context.mediaWidth(1), + height: context.mediaHeight(1)); } } @@ -1056,8 +1056,8 @@ class _AnimeStreamPageState extends riv.ConsumerState { streamController: _streamController, ), controller: _controller, - width: mediaWidth(context, 1), - height: mediaHeight(context, 1), + width: context.mediaWidth(1), + height: context.mediaHeight(1), resumeUponEnteringForegroundMode: true, ); } diff --git a/lib/modules/browse/extension/extension_detail.dart b/lib/modules/browse/extension/extension_detail.dart index 6d90229c..0aee05aa 100644 --- a/lib/modules/browse/extension/extension_detail.dart +++ b/lib/modules/browse/extension/extension_detail.dart @@ -8,9 +8,8 @@ import 'package:mangayomi/modules/browse/extension/providers/extension_preferenc import 'package:mangayomi/modules/browse/extension/widgets/source_preference_widget.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; import 'package:mangayomi/services/get_source_preference.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/language.dart'; -import 'package:mangayomi/utils/media_query.dart'; class ExtensionDetail extends ConsumerStatefulWidget { final Source source; @@ -67,7 +66,8 @@ class _ExtensionDetailState extends ConsumerState { padding: const EdgeInsets.all(12), child: Text( widget.source.name!, - style: const TextStyle(fontSize: 23, fontWeight: FontWeight.bold), + style: + const TextStyle(fontSize: 23, fontWeight: FontWeight.bold), textAlign: TextAlign.center, ), ), @@ -75,7 +75,7 @@ class _ExtensionDetailState extends ConsumerState { padding: const EdgeInsets.all(8.0), child: Container( decoration: BoxDecoration( - color: primaryColor(context).withOpacity(0.2), + color: context.primaryColor.withOpacity(0.2), borderRadius: BorderRadius.circular(10)), child: Padding( padding: const EdgeInsets.all(20), @@ -130,12 +130,12 @@ class _ExtensionDetailState extends ConsumerState { Padding( padding: const EdgeInsets.all(8.0), child: SizedBox( - width: mediaWidth(context, 1), + width: context.mediaWidth(1), child: ElevatedButton( style: ElevatedButton.styleFrom( padding: const EdgeInsets.all(0), side: - BorderSide(color: primaryColor(context), width: 0.3), + BorderSide(color: context.primaryColor, width: 0.3), backgroundColor: Colors.transparent, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5)), @@ -149,8 +149,8 @@ class _ExtensionDetailState extends ConsumerState { title: Text( widget.source.name!, ), - content: Text( - l10n.uninstall_extension(widget.source.name!)), + content: Text(l10n + .uninstall_extension(widget.source.name!)), actions: [ Row( mainAxisAlignment: MainAxisAlignment.end, diff --git a/lib/modules/browse/extension/widgets/source_preference_widget.dart b/lib/modules/browse/extension/widgets/source_preference_widget.dart index 1721fa35..142c46e5 100644 --- a/lib/modules/browse/extension/widgets/source_preference_widget.dart +++ b/lib/modules/browse/extension/widgets/source_preference_widget.dart @@ -4,8 +4,7 @@ import 'package:mangayomi/models/source.dart'; import 'package:mangayomi/modules/browse/extension/providers/extension_preferences_providers.dart'; import 'package:mangayomi/modules/manga/detail/widgets/chapter_filter_list_tile_widget.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class SourcePreferenceWidget extends StatefulWidget { final List sourcePreference; @@ -33,7 +32,7 @@ class _SourcePreferenceWidgetState extends State { title: Text(pref.title!), subtitle: Text(pref.summary!, style: TextStyle( - fontSize: 11, color: secondaryColor(context))), + fontSize: 11, color: context.secondaryColor)), onTap: () { showDialog( context: context, @@ -55,7 +54,7 @@ class _SourcePreferenceWidgetState extends State { title: Text(pref.title!), subtitle: Text(pref.summary!, style: TextStyle( - fontSize: 11, color: secondaryColor(context))), + fontSize: 11, color: context.secondaryColor)), value: pref.value, onChanged: (value) { setState(() { @@ -71,7 +70,7 @@ class _SourcePreferenceWidgetState extends State { title: Text(pref.title!), subtitle: Text(pref.summary!, style: TextStyle( - fontSize: 11, color: secondaryColor(context))), + fontSize: 11, color: context.secondaryColor)), value: pref.value!, onChanged: (value) { setState(() { @@ -87,14 +86,14 @@ class _SourcePreferenceWidgetState extends State { title: Text(pref.title!), subtitle: Text(pref.entries![pref.valueIndex!], style: TextStyle( - fontSize: 11, color: secondaryColor(context))), + fontSize: 11, color: context.secondaryColor)), onTap: () async { final res = await showDialog( context: context, builder: (context) => AlertDialog( title: Text(pref.title!), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: pref.entries!.length, @@ -124,7 +123,7 @@ class _SourcePreferenceWidgetState extends State { child: Text( context.l10n.cancel, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), ], ) @@ -144,7 +143,7 @@ class _SourcePreferenceWidgetState extends State { title: Text(pref.title!), subtitle: Text(pref.summary!, style: TextStyle( - fontSize: 11, color: secondaryColor(context))), + fontSize: 11, color: context.secondaryColor)), onTap: () { List indexList = []; indexList.addAll(pref.values!); @@ -156,7 +155,7 @@ class _SourcePreferenceWidgetState extends State { return AlertDialog( title: Text(pref.title!), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: pref.entries!.length, @@ -198,7 +197,7 @@ class _SourcePreferenceWidgetState extends State { child: Text( context.l10n.cancel, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), TextButton( onPressed: () async { @@ -207,7 +206,7 @@ class _SourcePreferenceWidgetState extends State { child: Text( context.l10n.ok, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), ], ) @@ -264,10 +263,10 @@ class _EditTextDialogWidgetState extends State { isDense: true, filled: false, enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: secondaryColor(context)), + borderSide: BorderSide(color: context.secondaryColor), ), focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor(context)), + borderSide: BorderSide(color: context.primaryColor), ), border: const OutlineInputBorder(borderSide: BorderSide()), ), diff --git a/lib/modules/browse/global_search/global_search_screen.dart b/lib/modules/browse/global_search/global_search_screen.dart index 0167f643..56c6156f 100644 --- a/lib/modules/browse/global_search/global_search_screen.dart +++ b/lib/modules/browse/global_search/global_search_screen.dart @@ -12,7 +12,7 @@ import 'package:mangayomi/router/router.dart'; import 'package:mangayomi/models/source.dart'; import 'package:mangayomi/services/search_.dart'; import 'package:mangayomi/utils/cached_network.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/constant.dart'; import 'package:mangayomi/utils/headers.dart'; import 'package:mangayomi/utils/language.dart'; @@ -308,7 +308,7 @@ class _MangaGlobalImageCardState extends ConsumerState child: Padding( padding: const EdgeInsets.all(4), child: Icon(Icons.collections_bookmark, - color: primaryColor(context)), + color: context.primaryColor), )) ], ), diff --git a/lib/modules/browse/sources/widgets/source_list_tile.dart b/lib/modules/browse/sources/widgets/source_list_tile.dart index 9263d078..bae998f1 100644 --- a/lib/modules/browse/sources/widgets/source_list_tile.dart +++ b/lib/modules/browse/sources/widgets/source_list_tile.dart @@ -6,7 +6,7 @@ import 'package:mangayomi/main.dart'; import 'package:mangayomi/models/source.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; import 'package:mangayomi/sources/source_test.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/language.dart'; import 'package:cached_network_image/cached_network_image.dart'; @@ -126,7 +126,7 @@ class SourceListTile extends StatelessWidget { }, icon: Icon( Icons.push_pin_outlined, - color: source.isPinned! ? primaryColor(context) : null, + color: source.isPinned! ? context.primaryColor : null, )), ], ), diff --git a/lib/modules/library/library_screen.dart b/lib/modules/library/library_screen.dart index a082347a..debaaa75 100644 --- a/lib/modules/library/library_screen.dart +++ b/lib/modules/library/library_screen.dart @@ -18,8 +18,7 @@ import 'package:mangayomi/modules/more/categories/providers/isar_providers.dart' import 'package:mangayomi/modules/widgets/manga_image_card_widget.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; import 'package:mangayomi/providers/storage_provider.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/modules/library/providers/isar_providers.dart'; import 'package:mangayomi/modules/library/providers/library_state_provider.dart'; import 'package:mangayomi/modules/library/widgets/search_text_form_field.dart'; @@ -455,13 +454,13 @@ class _LibraryScreenState extends ConsumerState return AnimatedContainer( curve: Curves.easeIn, decoration: BoxDecoration( - color: primaryColor(context).withOpacity(0.2), + color: context.primaryColor.withOpacity(0.2), borderRadius: const BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20))), duration: const Duration(milliseconds: 100), height: isLongPressed ? 70 : 0, - width: mediaWidth(context, 1), + width: context.mediaWidth(1), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ @@ -661,10 +660,8 @@ class _LibraryScreenState extends ConsumerState ) : LibraryGridViewWidget( entriesManga: entriesManga, - isCoverOnlyGrid: - displayType == DisplayType.compactGrid ? false : true, - isComfortableGrid: - displayType == DisplayType.comfortableGrid ? true : false, + isCoverOnlyGrid: !(displayType == DisplayType.compactGrid), + isComfortableGrid: displayType == DisplayType.comfortableGrid, continueReaderBtn: continueReaderBtn, downloadedChapter: downloadedChapter, language: language, @@ -730,10 +727,8 @@ class _LibraryScreenState extends ConsumerState ) : LibraryGridViewWidget( entriesManga: entriesManga, - isCoverOnlyGrid: - displayType == DisplayType.compactGrid ? false : true, - isComfortableGrid: - displayType == DisplayType.comfortableGrid ? true : false, + isCoverOnlyGrid: !(displayType == DisplayType.compactGrid), + isComfortableGrid: displayType == DisplayType.comfortableGrid, continueReaderBtn: continueReaderBtn, downloadedChapter: downloadedChapter, language: language, @@ -921,7 +916,7 @@ class _LibraryScreenState extends ConsumerState l10n.set_categories, ), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: Builder(builder: (context) { if (snapshot.hasData && snapshot.data!.isNotEmpty) { final entries = snapshot.data!; @@ -1057,7 +1052,7 @@ class _LibraryScreenState extends ConsumerState ), content: SizedBox( height: 100, - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: Column( children: [ ListTileChapterFilter( @@ -1381,6 +1376,8 @@ class _LibraryScreenState extends ConsumerState physics: const NeverScrollableScrollPhysics(), child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only( @@ -1391,37 +1388,84 @@ class _LibraryScreenState extends ConsumerState ], ), ), - Column( - children: DisplayType.values - .map( - (e) => RadioListTile< - DisplayType>( - dense: true, - title: Text( - displayV - .getLibraryDisplayTypeName( - e.name, context), - style: TextStyle( - color: - Theme.of(context) - .textTheme - .bodyLarge! - .color, - fontSize: 14), - ), - value: e, - groupValue: displayV - .getLibraryDisplayTypeValue( - display), - selected: true, - onChanged: (value) { - displayV - .setLibraryDisplayType( - value!); - }, - ), - ) - .toList()), + Padding( + padding: const EdgeInsets.symmetric( + vertical: 5, horizontal: 20), + child: Wrap( + children: DisplayType.values.map( + (e) { + final selected = e == + displayV + .getLibraryDisplayTypeValue( + display); + return Padding( + padding: const EdgeInsets.only( + right: 5), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + padding: + const EdgeInsets.symmetric( + horizontal: 15), + surfaceTintColor: + Colors.transparent, + shape: + RoundedRectangleBorder( + borderRadius: + BorderRadius + .circular( + 10)), + side: selected + ? null + : BorderSide( + color: context + .isLight + ? Colors.black + : Colors + .white, + width: 0.8), + shadowColor: + Colors.transparent, + elevation: 0, + backgroundColor: selected + ? context.primaryColor + .withOpacity(0.2) + : Colors.transparent), + onPressed: () { + displayV + .setLibraryDisplayType( + e); + }, + child: Text( + displayV + .getLibraryDisplayTypeName( + e.name, context), + style: TextStyle( + color: Theme.of(context) + .textTheme + .bodyLarge! + .color, + fontSize: 14), + )), + ); + } + + // RadioListTile< + // DisplayType>( + // dense: true, + // title: , + // value: e, + // groupValue: displayV + // .getLibraryDisplayTypeValue( + // display), + // selected: true, + // onChanged: (value) { + // displayV + // .setLibraryDisplayType( + // value!); + // }, + // ), + ).toList()), + ), Padding( padding: const EdgeInsets.only( left: 20, top: 10), @@ -1478,6 +1522,22 @@ class _LibraryScreenState extends ConsumerState .notifier) .set(!localSource); }), + ListTileChapterFilter( + label: l10n + .show_continue_reading_buttons, + type: + continueReaderBtn ? 1 : 0, + onTap: () { + ref + .read(libraryShowContinueReadingButtonStateProvider( + isManga: widget + .isManga, + settings: + settings) + .notifier) + .set( + !continueReaderBtn); + }), ], ), ), @@ -1528,39 +1588,6 @@ class _LibraryScreenState extends ConsumerState ], ), ), - Padding( - padding: const EdgeInsets.only( - left: 20, top: 10), - child: Row( - children: [ - Text(l10n.other), - ], - ), - ), - Padding( - padding: - const EdgeInsets.only(top: 5), - child: Column( - children: [ - ListTileChapterFilter( - label: l10n - .show_continue_reading_buttons, - type: - continueReaderBtn ? 1 : 0, - onTap: () { - ref - .read(libraryShowContinueReadingButtonStateProvider( - isManga: widget - .isManga, - settings: - settings) - .notifier) - .set( - !continueReaderBtn); - }), - ], - ), - ) ], ), ); @@ -1616,7 +1643,7 @@ class _LibraryScreenState extends ConsumerState color: Theme.of(context).scaffoldBackgroundColor, child: AppBar( title: Text(mangaIdsList.length.toString()), - backgroundColor: primaryColor(context).withOpacity(0.2), + backgroundColor: context.primaryColor.withOpacity(0.2), leading: IconButton( onPressed: () { ref.read(mangasListStateProvider.notifier).clear(); @@ -1832,8 +1859,8 @@ _importLocal(BuildContext context, bool isManga) { ), if (isLoading) Container( - width: mediaWidth(context, 1), - height: mediaHeight(context, 1), + width: context.mediaWidth(1), + height: context.mediaHeight(1), color: Colors.transparent, child: UnconstrainedBox( child: Container( diff --git a/lib/modules/library/widgets/library_gridview_widget.dart b/lib/modules/library/widgets/library_gridview_widget.dart index 217797fe..4bffb542 100644 --- a/lib/modules/library/widgets/library_gridview_widget.dart +++ b/lib/modules/library/widgets/library_gridview_widget.dart @@ -9,7 +9,7 @@ import 'package:mangayomi/modules/history/providers/isar_providers.dart'; import 'package:mangayomi/modules/library/providers/library_state_provider.dart'; import 'package:mangayomi/modules/manga/reader/providers/push_router.dart'; import 'package:mangayomi/models/manga.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/constant.dart'; import 'package:mangayomi/utils/headers.dart'; import 'package:mangayomi/modules/more/providers/incognito_mode_state_provider.dart'; @@ -102,7 +102,7 @@ class LibraryGridViewWidget extends StatelessWidget { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(3), - color: primaryColor(context), + color: context.primaryColor, ), child: Row( children: [ @@ -194,7 +194,7 @@ class LibraryGridViewWidget extends StatelessWidget { child: Padding( padding: const EdgeInsets.all(5), child: Container( - color: primaryColor(context), + color: context.primaryColor, child: Container( decoration: BoxDecoration( borderRadius: const BorderRadius.only( @@ -248,7 +248,7 @@ class LibraryGridViewWidget extends StatelessWidget { decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), - color: primaryColor(context) + color: context.primaryColor .withOpacity(0.9), ), child: const Padding( @@ -274,7 +274,7 @@ class LibraryGridViewWidget extends StatelessWidget { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), - color: primaryColor(context) + color: context.primaryColor .withOpacity(0.9), ), child: const Padding( diff --git a/lib/modules/library/widgets/library_listview_widget.dart b/lib/modules/library/widgets/library_listview_widget.dart index 0e5e5964..520a1672 100644 --- a/lib/modules/library/widgets/library_listview_widget.dart +++ b/lib/modules/library/widgets/library_listview_widget.dart @@ -9,7 +9,7 @@ import 'package:mangayomi/modules/history/providers/isar_providers.dart'; import 'package:mangayomi/modules/library/providers/library_state_provider.dart'; import 'package:mangayomi/modules/manga/reader/providers/push_router.dart'; import 'package:mangayomi/models/manga.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/constant.dart'; import 'package:mangayomi/utils/headers.dart'; import 'package:mangayomi/modules/more/providers/incognito_mode_state_provider.dart'; @@ -73,7 +73,7 @@ class LibraryListViewWidget extends StatelessWidget { }, child: Container( color: mangaIdsList.contains(entry.id) - ? primaryColor(context).withOpacity(0.4) + ? context.primaryColor.withOpacity(0.4) : Colors.transparent, child: Padding( padding: @@ -109,7 +109,7 @@ class LibraryListViewWidget extends StatelessWidget { child: InkWell( child: Container( color: mangaIdsList.contains(entry.id) - ? primaryColor(context) + ? context.primaryColor .withOpacity(0.4) : Colors.transparent, )), @@ -131,7 +131,7 @@ class LibraryListViewWidget extends StatelessWidget { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(3), - color: primaryColor(context)), + color: context.primaryColor), child: SizedBox( height: 22, child: Row( @@ -216,7 +216,7 @@ class LibraryListViewWidget extends StatelessWidget { ), if (language && entry.lang!.isNotEmpty) Container( - color: primaryColor(context), + color: context.primaryColor, child: Container( decoration: BoxDecoration( borderRadius: const BorderRadius.only( @@ -266,7 +266,7 @@ class LibraryListViewWidget extends StatelessWidget { decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), - color: primaryColor(context) + color: context.primaryColor .withOpacity(0.9), ), child: const Padding( @@ -292,7 +292,7 @@ class LibraryListViewWidget extends StatelessWidget { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), - color: primaryColor(context) + color: context.primaryColor .withOpacity(0.9), ), child: const Padding( diff --git a/lib/modules/main_view/main_screen.dart b/lib/modules/main_view/main_screen.dart index 3e632704..dec46215 100644 --- a/lib/modules/main_view/main_screen.dart +++ b/lib/modules/main_view/main_screen.dart @@ -14,8 +14,7 @@ import 'package:mangayomi/modules/more/backup_and_restore/providers/auto_backup. import 'package:mangayomi/modules/more/settings/browse/providers/browse_state_provider.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; import 'package:mangayomi/router/router.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/modules/library/providers/library_state_provider.dart'; import 'package:mangayomi/modules/more/providers/incognito_mode_state_provider.dart'; @@ -62,7 +61,7 @@ class MainScreen extends ConsumerWidget { : 0, curve: Curves.easeIn, duration: const Duration(milliseconds: 150), - color: primaryColor(context), + color: context.primaryColor, child: Row( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.center, @@ -83,7 +82,7 @@ class MainScreen extends ConsumerWidget { ), Flexible( child: Scaffold( - body: isTablet(context) + body: context.isTablet ? Row( children: [ AnimatedContainer( @@ -186,11 +185,11 @@ class MainScreen extends ConsumerWidget { ], ) : child, - bottomNavigationBar: isTablet(context) + bottomNavigationBar: context.isTablet ? null : AnimatedContainer( duration: const Duration(milliseconds: 0), - width: mediaWidth(context, 1), + width: context.mediaWidth(1), height: switch (isLongPressed) { true => 0, _ => switch (location) { diff --git a/lib/modules/manga/detail/manga_detail_view.dart b/lib/modules/manga/detail/manga_detail_view.dart index 5faebddc..ac2743a4 100644 --- a/lib/modules/manga/detail/manga_detail_view.dart +++ b/lib/modules/manga/detail/manga_detail_view.dart @@ -26,10 +26,8 @@ import 'package:mangayomi/modules/more/settings/track/widgets/track_listile.dart import 'package:mangayomi/providers/l10n_providers.dart'; import 'package:mangayomi/sources/utils/utils.dart'; import 'package:mangayomi/utils/cached_network.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/headers.dart'; -import 'package:mangayomi/utils/media_query.dart'; -import 'package:mangayomi/utils/utils.dart'; import 'package:mangayomi/modules/manga/detail/providers/isar_providers.dart'; import 'package:mangayomi/modules/manga/detail/providers/state_providers.dart'; import 'package:mangayomi/modules/manga/detail/widgets/readmore.dart'; @@ -227,7 +225,7 @@ class _MangaDetailViewState extends ConsumerState widget.manga!.customCoverImage != null ? Image.memory( widget.manga!.customCoverImage as Uint8List, - width: mediaWidth(context, 1), + width: context.mediaWidth(1), height: 300, fit: BoxFit.cover) : cachedNetworkImage( @@ -237,7 +235,7 @@ class _MangaDetailViewState extends ConsumerState imageUrl: toImgUrl( widget.manga!.customCoverFromTracker ?? widget.manga!.imageUrl!), - width: mediaWidth(context, 1), + width: context.mediaWidth(1), height: 300, fit: BoxFit.cover), Stack( @@ -245,9 +243,9 @@ class _MangaDetailViewState extends ConsumerState Column( children: [ Container( - width: mediaWidth(context, 1), + width: context.mediaWidth(1), height: AppBar().preferredSize.height, - color: isTablet(context) + color: context.isTablet ? Theme.of(context) .scaffoldBackgroundColor : Theme.of(context) @@ -255,9 +253,9 @@ class _MangaDetailViewState extends ConsumerState .withOpacity(0.9), ), Container( - width: mediaWidth(context, 1), + width: context.mediaWidth(1), height: 465, - color: isTablet(context) + color: context.isTablet ? Theme.of(context) .scaffoldBackgroundColor : Theme.of(context) @@ -269,7 +267,7 @@ class _MangaDetailViewState extends ConsumerState Positioned( bottom: 0, child: Container( - width: mediaWidth(context, 1), + width: context.mediaWidth(1), height: 100, color: Theme.of(context) .scaffoldBackgroundColor), @@ -299,7 +297,7 @@ class _MangaDetailViewState extends ConsumerState child: AppBar( title: Text(chapterList.length.toString()), backgroundColor: - primaryColor(context).withOpacity(0.2), + context.primaryColor.withOpacity(0.2), leading: IconButton( onPressed: () { ref @@ -420,10 +418,10 @@ class _MangaDetailViewState extends ConsumerState body: SafeArea( child: Row( children: [ - if (isTablet(context)) + if (context.isTablet) SizedBox( - width: mediaWidth(context, 0.5), - height: mediaHeight(context, 1), + width: context.mediaWidth(0.5), + height: context.mediaHeight(1), child: SingleChildScrollView( child: _bodyContainer( chapterLength: chapters.length))), @@ -431,7 +429,7 @@ class _MangaDetailViewState extends ConsumerState child: DraggableScrollbar( padding: const EdgeInsets.only(right: 7), heightScrollThumb: 48.0, - backgroundColor: primaryColor(context), + backgroundColor: context.primaryColor, scrollThumbBuilder: (backgroundColor, thumbAnimation, labelAnimation, height, {labelConstraints, labelText}) { @@ -456,7 +454,7 @@ class _MangaDetailViewState extends ConsumerState final l10n = l10nLocalizations(context)!; int finalIndex = index - 1; if (index == 0) { - return isTablet(context) + return context.isTablet ? Column( children: [ Padding( @@ -469,7 +467,7 @@ class _MangaDetailViewState extends ConsumerState children: [ Container( height: chapters.isEmpty - ? mediaHeight(context, 1) + ? context.mediaHeight(1) : null, color: Theme.of(context) .scaffoldBackgroundColor, @@ -501,8 +499,8 @@ class _MangaDetailViewState extends ConsumerState .circular( 5))), icon: Icon(Icons.add, - color: secondaryColor( - context)), + color: context + .secondaryColor), label: Text( widget.manga!.isManga! ? l10n.add_chapters @@ -510,8 +508,8 @@ class _MangaDetailViewState extends ConsumerState style: TextStyle( fontWeight: FontWeight.bold, - color: secondaryColor( - context)), + color: context + .secondaryColor), ), onPressed: () async { await ref.watch( @@ -559,13 +557,13 @@ class _MangaDetailViewState extends ConsumerState return AnimatedContainer( curve: Curves.easeIn, decoration: BoxDecoration( - color: primaryColor(context).withOpacity(0.2), + color: context.primaryColor.withOpacity(0.2), borderRadius: const BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20))), duration: const Duration(milliseconds: 100), height: isLongPressed ? 70 : 0, - width: mediaWidth(context, 1), + width: context.mediaWidth(1), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ @@ -935,9 +933,8 @@ class _MangaDetailViewState extends ConsumerState l10n.filter_scanlator_groups, ), content: SizedBox( - width: - mediaWidth( - context, + width: context + .mediaWidth( 0.8), child: ListView .builder( @@ -978,7 +975,7 @@ class _MangaDetailViewState extends ConsumerState }, child: Text( l10n.reset, - style: TextStyle(color: primaryColor(context)), + style: TextStyle(color: context.primaryColor), )), ], ), @@ -993,7 +990,7 @@ class _MangaDetailViewState extends ConsumerState }, child: Text( l10n.cancel, - style: TextStyle(color: primaryColor(context)), + style: TextStyle(color: context.primaryColor), )), TextButton( onPressed: () { @@ -1002,7 +999,7 @@ class _MangaDetailViewState extends ConsumerState }, child: Text( l10n.filter, - style: TextStyle(color: primaryColor(context)), + style: TextStyle(color: context.primaryColor), )), ], ), @@ -1138,7 +1135,7 @@ class _MangaDetailViewState extends ConsumerState Stack( children: [ SizedBox( - width: mediaWidth(context, 1), + width: context.mediaWidth(1), child: Row( children: [ _coverCard(), @@ -1182,7 +1179,7 @@ class _MangaDetailViewState extends ConsumerState ? const SizedBox( height: 30, ) - : _expanded || isTablet(context) + : _expanded || context.isTablet ? Wrap( children: [ for (var i = 0; @@ -1207,7 +1204,7 @@ class _MangaDetailViewState extends ConsumerState widget.manga!.genre![i], style: TextStyle( fontSize: 11.5, - color: isLight(context) + color: context.isLight ? Colors.black : Colors.white), ), @@ -1243,7 +1240,7 @@ class _MangaDetailViewState extends ConsumerState widget.manga!.genre![i], style: TextStyle( fontSize: 11.5, - color: isLight(context) + color: context.isLight ? Colors.black : Colors.white), ), @@ -1253,7 +1250,7 @@ class _MangaDetailViewState extends ConsumerState ], ), )), - if (!isTablet(context)) + if (!context.isTablet) Column( children: [ //Description @@ -1283,12 +1280,12 @@ class _MangaDetailViewState extends ConsumerState borderRadius: BorderRadius.circular(5))), icon: Icon(Icons.add, - color: secondaryColor(context)), + color: context.secondaryColor), label: Text( l10n.add_chapters, style: TextStyle( fontWeight: FontWeight.bold, - color: secondaryColor(context)), + color: context.secondaryColor), ), onPressed: () async { await ref.watch( @@ -1309,8 +1306,8 @@ class _MangaDetailViewState extends ConsumerState ), if (chapterLength == 0) Container( - width: mediaWidth(context, 1), - height: mediaHeight(context, 1), + width: context.mediaWidth(1), + height: context.mediaHeight(1), color: Theme.of(context).scaffoldBackgroundColor) ], ), @@ -1403,8 +1400,8 @@ class _MangaDetailViewState extends ConsumerState snapshot.hasData ? snapshot.data : []; bool isNotEmpty = trackRes!.isNotEmpty; Color color = isNotEmpty - ? primaryColor(context) - : secondaryColor(context); + ? context.primaryColor + : context.secondaryColor; return Column( children: [ Icon( @@ -1459,7 +1456,7 @@ class _MangaDetailViewState extends ConsumerState Icon( Icons.public, size: 20, - color: secondaryColor(context), + color: context.secondaryColor, ), const SizedBox( height: 4, @@ -1467,7 +1464,7 @@ class _MangaDetailViewState extends ConsumerState Text( 'WebView', style: TextStyle( - fontSize: 11, color: secondaryColor(context)), + fontSize: 11, color: context.secondaryColor), ) ], ), @@ -1742,7 +1739,7 @@ class _MangaDetailViewState extends ConsumerState barItem: Container(), color: Theme.of(context).scaffoldBackgroundColor), child: Material( - color: isLight(context) + color: context.isLight ? Theme.of(context).scaffoldBackgroundColor.withOpacity(0.9) : !ref.watch(pureBlackDarkModeStateProvider) ? Theme.of(context).scaffoldBackgroundColor.withOpacity(0.9) diff --git a/lib/modules/manga/detail/manga_details_view.dart b/lib/modules/manga/detail/manga_details_view.dart index 2224881b..56789d7d 100644 --- a/lib/modules/manga/detail/manga_details_view.dart +++ b/lib/modules/manga/detail/manga_details_view.dart @@ -9,9 +9,8 @@ import 'package:mangayomi/modules/manga/detail/widgets/custom_floating_action_bt import 'package:mangayomi/modules/manga/reader/providers/push_router.dart'; import 'package:mangayomi/models/manga.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/constant.dart'; -import 'package:mangayomi/utils/media_query.dart'; import 'package:mangayomi/modules/manga/detail/manga_detail_view.dart'; import 'package:mangayomi/modules/manga/detail/providers/state_providers.dart'; import 'package:mangayomi/modules/manga/detail/widgets/chapter_filter_list_tile_widget.dart'; @@ -203,7 +202,7 @@ class _MangaDetailsViewState extends ConsumerState { Icon( Icons.favorite_border_rounded, size: 20, - color: secondaryColor(context), + color: context.secondaryColor, ), const SizedBox( height: 4, @@ -211,7 +210,7 @@ class _MangaDetailsViewState extends ConsumerState { Text( l10n.add_to_library, style: TextStyle( - color: secondaryColor(context), fontSize: 11), + color: context.secondaryColor, fontSize: 11), textAlign: TextAlign.center, ) ], @@ -240,7 +239,7 @@ class _MangaDetailsViewState extends ConsumerState { l10n.set_categories, ), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: StreamBuilder( stream: isar.categorys .filter() diff --git a/lib/modules/manga/detail/widgets/chapter_list_tile_widget.dart b/lib/modules/manga/detail/widgets/chapter_list_tile_widget.dart index 9d423d37..73d44ece 100644 --- a/lib/modules/manga/detail/widgets/chapter_list_tile_widget.dart +++ b/lib/modules/manga/detail/widgets/chapter_list_tile_widget.dart @@ -4,9 +4,8 @@ import 'package:mangayomi/models/chapter.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; import 'package:mangayomi/utils/date.dart'; import 'package:mangayomi/modules/manga/reader/providers/push_router.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/extensions.dart'; -import 'package:mangayomi/utils/utils.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:mangayomi/modules/manga/detail/providers/state_providers.dart'; import 'package:mangayomi/modules/manga/download/download_page_widget.dart'; @@ -27,11 +26,11 @@ class ChapterListTileWidget extends ConsumerWidget { final l10n = l10nLocalizations(context)!; return Container( color: chapterList.contains(chapter) - ? primaryColor(context).withOpacity(0.4) + ? context.primaryColor.withOpacity(0.4) : null, child: ListTile( textColor: chapter.isRead! - ? isLight(context) + ? context.isLight ? Colors.black.withOpacity(0.4) : Colors.white.withOpacity(0.3) : null, @@ -61,7 +60,7 @@ class ChapterListTileWidget extends ConsumerWidget { ? Icon( Icons.bookmark, size: 16, - color: primaryColor(context), + color: context.primaryColor, ) : Container(), Flexible( @@ -99,7 +98,7 @@ class ChapterListTileWidget extends ConsumerWidget { : l10n.page(chapter.lastPageRead!), style: TextStyle( fontSize: 11, - color: isLight(context) + color: context.isLight ? Colors.black.withOpacity(0.4) : Colors.white.withOpacity(0.3)), ), @@ -114,7 +113,7 @@ class ChapterListTileWidget extends ConsumerWidget { style: TextStyle( fontSize: 11, color: chapter.isRead! - ? isLight(context) + ? context.isLight ? Colors.black.withOpacity(0.4) : Colors.white.withOpacity(0.3) : null), diff --git a/lib/modules/manga/detail/widgets/custom_floating_action_btn.dart b/lib/modules/manga/detail/widgets/custom_floating_action_btn.dart index 50216032..faab24a0 100644 --- a/lib/modules/manga/detail/widgets/custom_floating_action_btn.dart +++ b/lib/modules/manga/detail/widgets/custom_floating_action_btn.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class CustomFloatingActionBtn extends StatelessWidget { final bool isExtended; @@ -24,7 +24,7 @@ class CustomFloatingActionBtn extends StatelessWidget { duration: const Duration(milliseconds: 200), curve: Curves.easeIn, child: FloatingActionButton( - backgroundColor: primaryColor(context), + backgroundColor: context.primaryColor, onPressed: onPressed, child: Row( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/modules/manga/detail/widgets/readmore.dart b/lib/modules/manga/detail/widgets/readmore.dart index 0db366ac..58c2bbdf 100644 --- a/lib/modules/manga/detail/widgets/readmore.dart +++ b/lib/modules/manga/detail/widgets/readmore.dart @@ -1,10 +1,11 @@ import 'package:expandable_text/expandable_text.dart'; import 'package:flutter/material.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class ReadMoreWidget extends StatefulWidget { - const ReadMoreWidget({super.key, required this.text, required this.onChanged}); + const ReadMoreWidget( + {super.key, required this.text, required this.onChanged}); final Function(bool) onChanged; final String text; @@ -54,7 +55,7 @@ class ReadMoreWidgetState extends State right: 0, left: 0, child: Container( - width: mediaWidth(context, 1), + width: context.mediaWidth(1), height: 30, decoration: BoxDecoration( color: Theme.of(context).scaffoldBackgroundColor, @@ -77,7 +78,7 @@ class ReadMoreWidgetState extends State ), if (expanded) SizedBox( - width: mediaWidth(context, 1), + width: context.mediaWidth(1), height: 20, child: const Icon(Icons.keyboard_arrow_up_sharp), ) diff --git a/lib/modules/manga/detail/widgets/tracker_search_widget.dart b/lib/modules/manga/detail/widgets/tracker_search_widget.dart index 69dd06b2..4bee4f05 100644 --- a/lib/modules/manga/detail/widgets/tracker_search_widget.dart +++ b/lib/modules/manga/detail/widgets/tracker_search_widget.dart @@ -6,8 +6,7 @@ import 'package:mangayomi/models/track.dart'; import 'package:mangayomi/models/track_search.dart'; import 'package:mangayomi/modules/manga/detail/providers/track_state_providers.dart'; import 'package:mangayomi/modules/widgets/progress_center.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class TrackerWidgetSearch extends ConsumerStatefulWidget { final bool isManga; @@ -56,7 +55,7 @@ class _TrackerWidgetSearchState extends ConsumerState { : Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: SizedBox( - height: mediaHeight(context, 0.8), + height: context.mediaHeight(0.8), child: Column( children: [ Flexible( @@ -97,7 +96,7 @@ class _TrackerWidgetSearchState extends ConsumerState { CrossAxisAlignment.start, children: [ SizedBox( - width: mediaWidth(context, 0.6), + width: context.mediaWidth(0.6), child: Text( tracks![index].title!, style: const TextStyle( @@ -196,15 +195,15 @@ class _TrackerWidgetSearchState extends ConsumerState { icon: const Icon(Icons.clear)), enabledBorder: OutlineInputBorder( borderSide: - BorderSide(color: primaryColor(context)), + BorderSide(color: context.primaryColor), ), focusedBorder: OutlineInputBorder( borderSide: - BorderSide(color: primaryColor(context)), + BorderSide(color: context.primaryColor), ), border: OutlineInputBorder( borderSide: - BorderSide(color: primaryColor(context)))), + BorderSide(color: context.primaryColor))), ), ), ], diff --git a/lib/modules/manga/detail/widgets/tracker_widget.dart b/lib/modules/manga/detail/widgets/tracker_widget.dart index 6ae53d97..92f5bc4c 100644 --- a/lib/modules/manga/detail/widgets/tracker_widget.dart +++ b/lib/modules/manga/detail/widgets/tracker_widget.dart @@ -6,11 +6,9 @@ import 'package:mangayomi/modules/manga/detail/providers/track_state_providers.d import 'package:mangayomi/modules/manga/detail/widgets/tracker_search_widget.dart'; import 'package:mangayomi/modules/more/settings/track/providers/track_providers.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/constant.dart'; import 'package:mangayomi/utils/date.dart'; -import 'package:mangayomi/utils/media_query.dart'; -import 'package:mangayomi/utils/utils.dart'; import 'package:numberpicker/numberpicker.dart'; class TrackerWidget extends ConsumerStatefulWidget { @@ -58,7 +56,7 @@ class _TrackerWidgetState extends ConsumerState { final l10nLocale = ref.watch(l10nLocaleStateProvider); return Container( decoration: BoxDecoration( - color: isLight(context) + color: context.isLight ? Theme.of(context).scaffoldBackgroundColor : Colors.black, borderRadius: BorderRadius.circular(20)), @@ -68,7 +66,8 @@ class _TrackerWidgetState extends ConsumerState { children: [ if (!widget.hide) Padding( - padding: const EdgeInsets.symmetric(horizontal: 12,vertical: 5), + padding: + const EdgeInsets.symmetric(horizontal: 12, vertical: 5), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), @@ -148,7 +147,7 @@ class _TrackerWidgetState extends ConsumerState { l10n!.status, ), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: ref @@ -199,7 +198,7 @@ class _TrackerWidgetState extends ConsumerState { child: Text( l10n.cancel, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), ], ) @@ -254,7 +253,7 @@ class _TrackerWidgetState extends ConsumerState { child: Text( l10n.cancel, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), TextButton( onPressed: () async { @@ -271,7 +270,7 @@ class _TrackerWidgetState extends ConsumerState { child: Text( l10n.ok, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), ], ) @@ -341,7 +340,7 @@ class _TrackerWidgetState extends ConsumerState { child: Text( l10n.cancel, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), TextButton( onPressed: () async { @@ -357,7 +356,7 @@ class _TrackerWidgetState extends ConsumerState { child: Text( l10n.ok, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), ], ) @@ -456,14 +455,14 @@ Widget _elevatedButton(BuildContext context, return ElevatedButton( style: ElevatedButton.styleFrom( padding: const EdgeInsets.all(0), - backgroundColor: isLight(context) + backgroundColor: context.isLight ? Theme.of(context).scaffoldBackgroundColor : Colors.black, elevation: 0, shadowColor: Colors.transparent, shape: RoundedRectangleBorder( side: BorderSide( - width: 0, color: secondaryColor(context).withOpacity(0.1)), + width: 0, color: context.secondaryColor.withOpacity(0.1)), borderRadius: borderRadius ?? BorderRadius.circular(0))), onPressed: onPressed, child: child ?? diff --git a/lib/modules/manga/download/providers/download_provider.dart b/lib/modules/manga/download/providers/download_provider.dart index 135d9a60..42c52e9b 100644 --- a/lib/modules/manga/download/providers/download_provider.dart +++ b/lib/modules/manga/download/providers/download_provider.dart @@ -10,7 +10,7 @@ import 'package:mangayomi/modules/more/settings/downloads/providers/downloads_st import 'package:mangayomi/providers/storage_provider.dart'; import 'package:mangayomi/services/get_video_list.dart'; import 'package:mangayomi/services/get_chapter_pages.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:mangayomi/utils/headers.dart'; import 'package:mangayomi/utils/reg_exp_matcher.dart'; import 'package:path_provider/path_provider.dart'; diff --git a/lib/modules/manga/home/manga_home_screen.dart b/lib/modules/manga/home/manga_home_screen.dart index 6f029769..a291728c 100644 --- a/lib/modules/manga/home/manga_home_screen.dart +++ b/lib/modules/manga/home/manga_home_screen.dart @@ -13,8 +13,7 @@ import 'package:mangayomi/services/get_latest_updates.dart'; import 'package:mangayomi/services/get_popular.dart'; import 'package:mangayomi/services/search.dart'; import 'package:mangayomi/services/supports_latest.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/modules/library/widgets/search_text_form_field.dart'; import 'package:mangayomi/modules/manga/home/widget/mangas_card_selector.dart'; import 'package:mangayomi/modules/widgets/gridview_widget.dart'; @@ -192,7 +191,7 @@ class _MangaHomeScreenState extends ConsumerState { icon: Icon( Icons.public, size: 22, - color: secondaryColor(context), + color: context.secondaryColor, ), ) ], @@ -201,7 +200,7 @@ class _MangaHomeScreenState extends ConsumerState { child: Column( children: [ SizedBox( - width: mediaWidth(context, 1), + width: context.mediaWidth(1), height: 45, child: ListView.builder( scrollDirection: Axis.horizontal, @@ -247,7 +246,7 @@ class _MangaHomeScreenState extends ConsumerState { ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: - primaryColor(context)), + context.primaryColor), onPressed: () { Navigator.pop(context, 'filter'); }, @@ -305,9 +304,9 @@ class _MangaHomeScreenState extends ConsumerState { ), ), Container( - color: primaryColor(context), + color: context.primaryColor, height: 0.3, - width: mediaWidth(context, 1), + width: context.mediaWidth(1), ) ], ), @@ -339,7 +338,7 @@ class _MangaHomeScreenState extends ConsumerState { ), ), ) - : isTablet(context) + : context.isTablet ? Padding( padding: const EdgeInsets.all(4), child: ElevatedButton( @@ -491,7 +490,7 @@ class _MangaHomeScreenState extends ConsumerState { icon: Icon( Icons.public, size: 22, - color: secondaryColor(context), + color: context.secondaryColor, ), ), const Text("Webview") diff --git a/lib/modules/manga/home/widget/filter_widget.dart b/lib/modules/manga/home/widget/filter_widget.dart index 17c2a915..584785df 100644 --- a/lib/modules/manga/home/widget/filter_widget.dart +++ b/lib/modules/manga/home/widget/filter_widget.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:mangayomi/eval/model/filter.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class FilterWidget extends StatelessWidget { final List filterList; @@ -106,7 +105,7 @@ class FilterWidget extends StatelessWidget { ); } else if (filterState is SelectFilter) { widget = SizedBox( - width: mediaWidth(context, 1), + width: context.mediaWidth(1), child: Row( mainAxisSize: MainAxisSize.min, children: [ @@ -181,10 +180,10 @@ class _SeachFormTextFieldWidgetState extends State { isDense: true, filled: false, enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: secondaryColor(context)), + borderSide: BorderSide(color: context.secondaryColor), ), focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor(context)), + borderSide: BorderSide(color: context.primaryColor), ), border: const OutlineInputBorder(borderSide: BorderSide()), labelText: widget.labelText, diff --git a/lib/modules/manga/home/widget/mangas_card_selector.dart b/lib/modules/manga/home/widget/mangas_card_selector.dart index efd4f3e6..eb092063 100644 --- a/lib/modules/manga/home/widget/mangas_card_selector.dart +++ b/lib/modules/manga/home/widget/mangas_card_selector.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class MangasCardSelector extends StatelessWidget { final String text; @@ -20,8 +20,8 @@ class MangasCardSelector extends StatelessWidget { child: ElevatedButton( style: ElevatedButton.styleFrom( padding: const EdgeInsets.all(0), - side: BorderSide(width: 0.6, color: primaryColor(context)), - backgroundColor: selected ? primaryColor(context) : null, + side: BorderSide(width: 0.6, color: context.primaryColor), + backgroundColor: selected ? context.primaryColor : null, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)), ), diff --git a/lib/modules/manga/reader/double_columm_view_center.dart b/lib/modules/manga/reader/double_columm_view_center.dart index 9d5a2bb4..bad5d831 100644 --- a/lib/modules/manga/reader/double_columm_view_center.dart +++ b/lib/modules/manga/reader/double_columm_view_center.dart @@ -7,8 +7,7 @@ import 'package:mangayomi/modules/manga/reader/reader_view.dart'; import 'package:mangayomi/modules/manga/reader/widgets/circular_progress_indicator_animate_rotate.dart'; import 'package:mangayomi/modules/more/settings/reader/reader_screen.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:photo_view/photo_view.dart'; import 'package:photo_view/photo_view_gallery.dart'; @@ -137,14 +136,12 @@ class _DoubleColummViewState extends State state.loadingProgress; final double progress = loadingProgress?.expectedTotalBytes != null - ? loadingProgress! - .cumulativeBytesLoaded / + ? loadingProgress!.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! : 0; return Container( - color: getBackgroundColor( - widget.backgroundColor), - height: mediaHeight(context, 0.8), + color: getBackgroundColor(widget.backgroundColor), + height: context.mediaHeight(0.8), child: CircularProgressIndicatorAnimateRotate( progress: progress), ); @@ -158,44 +155,38 @@ class _DoubleColummViewState extends State LoadState.failed) { widget.isFailedToLoadImage(true); return Container( - color: getBackgroundColor( - widget.backgroundColor), - height: mediaHeight(context, 0.8), + color: + getBackgroundColor(widget.backgroundColor), + height: context.mediaHeight(0.8), child: Column( - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( l10n.image_loading_error, style: TextStyle( - color: Colors.white - .withOpacity(0.7)), + color: Colors.white.withOpacity(0.7)), ), Padding( padding: const EdgeInsets.all(8.0), child: GestureDetector( onLongPress: () { state.reLoadImage(); - widget - .isFailedToLoadImage(false); + widget.isFailedToLoadImage(false); }, onTap: () { state.reLoadImage(); - widget - .isFailedToLoadImage(false); + widget.isFailedToLoadImage(false); }, child: Container( decoration: BoxDecoration( - color: - primaryColor(context), + color: context.primaryColor, borderRadius: - BorderRadius.circular( - 30)), + BorderRadius.circular(30)), child: Padding( - padding: const EdgeInsets - .symmetric( - vertical: 8, - horizontal: 16), + padding: + const EdgeInsets.symmetric( + vertical: 8, + horizontal: 16), child: Text( l10n.retry, ), @@ -222,14 +213,12 @@ class _DoubleColummViewState extends State state.loadingProgress; final double progress = loadingProgress?.expectedTotalBytes != null - ? loadingProgress! - .cumulativeBytesLoaded / + ? loadingProgress!.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! : 0; return Container( - color: getBackgroundColor( - widget.backgroundColor), - height: mediaHeight(context, 0.8), + color: getBackgroundColor(widget.backgroundColor), + height: context.mediaHeight(0.8), child: CircularProgressIndicatorAnimateRotate( progress: progress), ); @@ -243,44 +232,38 @@ class _DoubleColummViewState extends State LoadState.failed) { widget.isFailedToLoadImage(true); return Container( - color: getBackgroundColor( - widget.backgroundColor), - height: mediaHeight(context, 0.8), + color: + getBackgroundColor(widget.backgroundColor), + height: context.mediaHeight(0.8), child: Column( - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( l10n.image_loading_error, style: TextStyle( - color: Colors.white - .withOpacity(0.7)), + color: Colors.white.withOpacity(0.7)), ), Padding( padding: const EdgeInsets.all(8.0), child: GestureDetector( onLongPress: () { state.reLoadImage(); - widget - .isFailedToLoadImage(false); + widget.isFailedToLoadImage(false); }, onTap: () { state.reLoadImage(); - widget - .isFailedToLoadImage(false); + widget.isFailedToLoadImage(false); }, child: Container( decoration: BoxDecoration( - color: - primaryColor(context), + color: context.primaryColor, borderRadius: - BorderRadius.circular( - 30)), + BorderRadius.circular(30)), child: Padding( - padding: const EdgeInsets - .symmetric( - vertical: 8, - horizontal: 16), + padding: + const EdgeInsets.symmetric( + vertical: 8, + horizontal: 16), child: Text( l10n.retry, ), diff --git a/lib/modules/manga/reader/double_columm_view_vertical.dart b/lib/modules/manga/reader/double_columm_view_vertical.dart index b1540dcc..e33da8db 100644 --- a/lib/modules/manga/reader/double_columm_view_vertical.dart +++ b/lib/modules/manga/reader/double_columm_view_vertical.dart @@ -6,8 +6,7 @@ import 'package:mangayomi/modules/manga/reader/reader_view.dart'; import 'package:mangayomi/modules/manga/reader/widgets/circular_progress_indicator_animate_rotate.dart'; import 'package:mangayomi/modules/more/settings/reader/reader_screen.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class DoubleColummVerticalView extends StatelessWidget { final bool cropBorders; @@ -51,7 +50,7 @@ class DoubleColummVerticalView extends StatelessWidget { : 0; return Container( color: getBackgroundColor(backgroundColor), - height: mediaHeight(context, 0.8), + height: context.mediaHeight(0.8), child: CircularProgressIndicatorAnimateRotate( progress: progress), ); @@ -64,7 +63,7 @@ class DoubleColummVerticalView extends StatelessWidget { isFailedToLoadImage(true); return Container( color: getBackgroundColor(backgroundColor), - height: mediaHeight(context, 0.8), + height: context.mediaHeight(0.8), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -86,7 +85,7 @@ class DoubleColummVerticalView extends StatelessWidget { }, child: Container( decoration: BoxDecoration( - color: primaryColor(context), + color: context.primaryColor, borderRadius: BorderRadius.circular(30)), child: Padding( @@ -122,7 +121,7 @@ class DoubleColummVerticalView extends StatelessWidget { : 0; return Container( color: getBackgroundColor(backgroundColor), - height: mediaHeight(context, 0.8), + height: context.mediaHeight(0.8), child: CircularProgressIndicatorAnimateRotate( progress: progress), ); @@ -135,7 +134,7 @@ class DoubleColummVerticalView extends StatelessWidget { isFailedToLoadImage(true); return Container( color: getBackgroundColor(backgroundColor), - height: mediaHeight(context, 0.8), + height: context.mediaHeight(0.8), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -157,7 +156,7 @@ class DoubleColummVerticalView extends StatelessWidget { }, child: Container( decoration: BoxDecoration( - color: primaryColor(context), + color: context.primaryColor, borderRadius: BorderRadius.circular(30)), child: Padding( diff --git a/lib/modules/manga/reader/image_view_vertical.dart b/lib/modules/manga/reader/image_view_vertical.dart index 54cbf633..59c91e1b 100644 --- a/lib/modules/manga/reader/image_view_vertical.dart +++ b/lib/modules/manga/reader/image_view_vertical.dart @@ -7,9 +7,8 @@ import 'package:mangayomi/modules/manga/reader/providers/reader_controller_provi import 'package:mangayomi/modules/manga/reader/reader_view.dart'; import 'package:mangayomi/modules/more/settings/reader/providers/reader_state_provider.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/headers.dart'; -import 'package:mangayomi/utils/media_query.dart'; import 'package:mangayomi/utils/reg_exp_matcher.dart'; import 'package:mangayomi/modules/manga/reader/widgets/circular_progress_indicator_animate_rotate.dart'; @@ -75,7 +74,7 @@ class ImageViewVertical extends ConsumerWidget { : 0; return Container( color: Colors.black, - height: mediaHeight(context, 0.8), + height: context.mediaHeight(0.8), child: CircularProgressIndicatorAnimateRotate( progress: progress), ); @@ -84,7 +83,7 @@ class ImageViewVertical extends ConsumerWidget { failedToLoadImage(true); return Container( color: Colors.black, - height: mediaHeight(context, 0.8), + height: context.mediaHeight(0.8), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -104,7 +103,7 @@ class ImageViewVertical extends ConsumerWidget { }, child: Container( decoration: BoxDecoration( - color: primaryColor(context), + color: context.primaryColor, borderRadius: BorderRadius.circular(30)), child: Padding( padding: const EdgeInsets.symmetric( diff --git a/lib/modules/manga/reader/reader_view.dart b/lib/modules/manga/reader/reader_view.dart index b43b78d3..1b55ac18 100644 --- a/lib/modules/manga/reader/reader_view.dart +++ b/lib/modules/manga/reader/reader_view.dart @@ -20,9 +20,8 @@ import 'package:mangayomi/providers/l10n_providers.dart'; import 'package:mangayomi/sources/utils/utils.dart'; import 'package:mangayomi/modules/manga/reader/providers/push_router.dart'; import 'package:mangayomi/services/get_chapter_pages.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/headers.dart'; -import 'package:mangayomi/utils/media_query.dart'; import 'package:mangayomi/modules/manga/reader/image_view_center.dart'; import 'package:mangayomi/modules/manga/reader/image_view_vertical.dart'; import 'package:mangayomi/modules/manga/reader/providers/reader_controller_provider.dart'; @@ -364,7 +363,7 @@ class _MangaChapterPageGalleryState onScaleEnd: _onScaleEnd, child: ScrollablePositionedList.separated( minCacheExtent: pagePreloadAmount * - mediaHeight(context, 1), + context.mediaHeight(1), initialScrollIndex: _readerController.getPageIndex(), itemCount: @@ -514,7 +513,7 @@ class _MangaChapterPageGalleryState return Container( color: getBackgroundColor( backgroundColor), - height: mediaHeight(context, 0.8), + height: context.mediaHeight(0.8), child: CircularProgressIndicatorAnimateRotate( progress: progress), @@ -560,7 +559,7 @@ class _MangaChapterPageGalleryState color: getBackgroundColor( backgroundColor), height: - mediaHeight(context, 0.8), + context.mediaHeight(0.8), child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -589,9 +588,8 @@ class _MangaChapterPageGalleryState }, child: Container( decoration: BoxDecoration( - color: - primaryColor( - context), + color: context + .primaryColor, borderRadius: BorderRadius .circular( @@ -1150,7 +1148,7 @@ class _MangaChapterPageGalleryState return Positioned( top: 0, child: AnimatedContainer( - width: mediaWidth(context, 1), + width: context.mediaWidth(1), height: _isView ? Platform.isIOS ? 120 @@ -1176,7 +1174,7 @@ class _MangaChapterPageGalleryState title: ListTile( dense: true, title: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: Text( '${_readerController.getMangaName()} ', style: const TextStyle(fontWeight: FontWeight.bold), @@ -1184,7 +1182,7 @@ class _MangaChapterPageGalleryState ), ), subtitle: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: Text( _readerController.getChapterTitle(), style: const TextStyle( @@ -1265,7 +1263,7 @@ class _MangaChapterPageGalleryState child: AnimatedContainer( curve: Curves.ease, duration: const Duration(milliseconds: 300), - width: mediaWidth(context, 1), + width: context.mediaWidth(1), height: (_isView ? 130 : 0), child: Column( children: [ @@ -1691,8 +1689,8 @@ class _MangaChapterPageGalleryState flex: 2, child: failedToLoadImage ? SizedBox( - width: mediaWidth(context, 1), - height: mediaHeight(context, 0.7), + width: context.mediaWidth(1), + height: context.mediaHeight(0.7), ) : GestureDetector( behavior: HitTestBehavior.translucent, diff --git a/lib/modules/more/about/providers/check_for_update.dart b/lib/modules/more/about/providers/check_for_update.dart index 9da23c21..42a2b2c4 100644 --- a/lib/modules/more/about/providers/check_for_update.dart +++ b/lib/modules/more/about/providers/check_for_update.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:mangayomi/modules/browse/extension/providers/fetch_manga_sources.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:url_launcher/url_launcher.dart'; diff --git a/lib/modules/more/backup_and_restore/backup_and_restore.dart b/lib/modules/more/backup_and_restore/backup_and_restore.dart index 210b6615..4d21407b 100644 --- a/lib/modules/more/backup_and_restore/backup_and_restore.dart +++ b/lib/modules/more/backup_and_restore/backup_and_restore.dart @@ -7,8 +7,7 @@ import 'package:mangayomi/modules/more/backup_and_restore/providers/auto_backup. import 'package:mangayomi/modules/more/backup_and_restore/providers/backup.dart'; import 'package:mangayomi/modules/more/backup_and_restore/providers/restore.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class BackupAndRestore extends ConsumerWidget { const BackupAndRestore({super.key}); @@ -42,7 +41,7 @@ class BackupAndRestore extends ConsumerWidget { return AlertDialog( title: Text(l10n.create_backup_dialog_title), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: list.length, @@ -74,13 +73,13 @@ class BackupAndRestore extends ConsumerWidget { child: Text( l10n.cancel, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), TextButton( onPressed: () async { final result = await FilePicker.platform .getDirectoryPath(); - + if (result != null && context.mounted) { ref.watch(doBackUpProvider( list: indexList, @@ -91,7 +90,7 @@ class BackupAndRestore extends ConsumerWidget { child: Text( l10n.ok, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), ], ) @@ -104,7 +103,7 @@ class BackupAndRestore extends ConsumerWidget { title: Text(l10n.create_backup), subtitle: Text( l10n.create_backup_subtitle, - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -115,20 +114,21 @@ class BackupAndRestore extends ConsumerWidget { return AlertDialog( title: Text(l10n.restore_backup), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView( shrinkWrap: true, children: [ Row( children: [ Icon(Icons.info_outline_rounded, - color: secondaryColor(context)), + color: context.secondaryColor), ], ), Padding( padding: const EdgeInsets.symmetric(vertical: 5), - child: Text(l10n.restore_backup_warning_title), + child: + Text(l10n.restore_backup_warning_title), ), ], )), @@ -143,15 +143,15 @@ class BackupAndRestore extends ConsumerWidget { child: Text( l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), TextButton( onPressed: () async { try { - FilePickerResult? result = await FilePicker - .platform - .pickFiles(allowMultiple: false); - + FilePickerResult? result = + await FilePicker.platform + .pickFiles(allowMultiple: false); + if (result != null && context.mounted) { ref.watch(doRestoreProvider( path: result.files.first.path!, @@ -167,7 +167,7 @@ class BackupAndRestore extends ConsumerWidget { child: Text( l10n.ok, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -178,7 +178,7 @@ class BackupAndRestore extends ConsumerWidget { title: Text(l10n.restore_backup), subtitle: Text( l10n.restore_backup_subtitle, - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), Padding( @@ -187,7 +187,7 @@ class BackupAndRestore extends ConsumerWidget { children: [ Text(l10n.automatic_backups, style: - TextStyle(fontSize: 13, color: primaryColor(context))), + TextStyle(fontSize: 13, color: context.primaryColor)), ], ), ), @@ -200,7 +200,7 @@ class BackupAndRestore extends ConsumerWidget { return AlertDialog( title: Text(l10n.backup_frequency), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: list.length, @@ -212,8 +212,8 @@ class BackupAndRestore extends ConsumerWidget { groupValue: backupFrequency, onChanged: (value) { ref - .read( - backupFrequencyStateProvider.notifier) + .read(backupFrequencyStateProvider + .notifier) .set(value!); Navigator.pop(context); }, @@ -234,7 +234,7 @@ class BackupAndRestore extends ConsumerWidget { child: Text( l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -245,16 +245,18 @@ class BackupAndRestore extends ConsumerWidget { title: Text(l10n.backup_frequency), subtitle: Text( _getBackupFrequencyList(context)[backupFrequency], - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), // if (!isIOS) ListTile( onTap: () async { String? result = await FilePicker.platform.getDirectoryPath(); - + if (result != null) { - ref.read(autoBackupLocationStateProvider.notifier).set(result); + ref + .read(autoBackupLocationStateProvider.notifier) + .set(result); } }, title: Text(l10n.backup_location), @@ -262,7 +264,7 @@ class BackupAndRestore extends ConsumerWidget { autoBackupLocation.$2.isEmpty ? autoBackupLocation.$1 : autoBackupLocation.$2, - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -280,7 +282,7 @@ class BackupAndRestore extends ConsumerWidget { l10n.backup_options_subtitle, ), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: list.length, @@ -312,7 +314,7 @@ class BackupAndRestore extends ConsumerWidget { child: Text( l10n.cancel, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), TextButton( onPressed: () async { @@ -326,7 +328,7 @@ class BackupAndRestore extends ConsumerWidget { child: Text( l10n.ok, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), ], ) @@ -339,7 +341,7 @@ class BackupAndRestore extends ConsumerWidget { title: Text(l10n.backup_options), subtitle: Text( l10n.backup_options_subtitle, - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -348,12 +350,13 @@ class BackupAndRestore extends ConsumerWidget { child: Row( children: [ Icon(Icons.info_outline_rounded, - color: secondaryColor(context)), + color: context.secondaryColor), ], ), ), subtitle: Text(l10n.backup_and_restore_warning_info, - style: TextStyle(fontSize: 11, color: secondaryColor(context))), + style: + TextStyle(fontSize: 11, color: context.secondaryColor)), ) ], ), diff --git a/lib/modules/more/backup_and_restore/providers/backup.dart b/lib/modules/more/backup_and_restore/providers/backup.dart index 8cbc2bdc..50dfb510 100644 --- a/lib/modules/more/backup_and_restore/providers/backup.dart +++ b/lib/modules/more/backup_and_restore/providers/backup.dart @@ -15,7 +15,7 @@ import 'package:mangayomi/models/settings.dart'; import 'package:mangayomi/models/source.dart'; import 'package:mangayomi/models/track.dart'; import 'package:mangayomi/models/track_preference.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:share_plus/share_plus.dart'; part 'backup.g.dart'; diff --git a/lib/modules/more/settings/appearance/appearance_screen.dart b/lib/modules/more/settings/appearance/appearance_screen.dart index 9ef785d3..3f74f70f 100644 --- a/lib/modules/more/settings/appearance/appearance_screen.dart +++ b/lib/modules/more/settings/appearance/appearance_screen.dart @@ -2,9 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:mangayomi/modules/more/settings/appearance/providers/theme_mode_state_provider.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/date.dart'; -import 'package:mangayomi/utils/media_query.dart'; import 'package:mangayomi/modules/more/settings/appearance/providers/date_format_state_provider.dart'; import 'package:mangayomi/modules/more/settings/appearance/providers/pure_black_dark_mode_state_provider.dart'; import 'package:mangayomi/modules/more/settings/appearance/widgets/blend_level_slider.dart'; @@ -38,7 +37,7 @@ class AppearanceScreen extends ConsumerWidget { children: [ Text(l10n.theme, style: TextStyle( - fontSize: 13, color: primaryColor(context))), + fontSize: 13, color: context.primaryColor)), ], ), ), @@ -71,7 +70,7 @@ class AppearanceScreen extends ConsumerWidget { children: [ Text(l10n.timestamp, style: TextStyle( - fontSize: 13, color: primaryColor(context))), + fontSize: 13, color: context.primaryColor)), ], ), ), @@ -85,7 +84,7 @@ class AppearanceScreen extends ConsumerWidget { l10n.relative_timestamp, ), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: @@ -124,7 +123,7 @@ class AppearanceScreen extends ConsumerWidget { child: Text( l10n.cancel, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), ], ) @@ -136,7 +135,7 @@ class AppearanceScreen extends ConsumerWidget { subtitle: Text( relativeTimestampsList(context)[relativeTimestamps], style: TextStyle( - fontSize: 11, color: secondaryColor(context)), + fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -149,7 +148,7 @@ class AppearanceScreen extends ConsumerWidget { l10n.date_format, ), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: dateFormatsList.length, @@ -186,7 +185,7 @@ class AppearanceScreen extends ConsumerWidget { child: Text( l10n.cancel, style: TextStyle( - color: primaryColor(context)), + color: context.primaryColor), )), ], ) @@ -198,7 +197,7 @@ class AppearanceScreen extends ConsumerWidget { subtitle: Text( "$dateFormatState (${dateFormat(context: context, DateTime.now().millisecondsSinceEpoch.toString(), useRelativeTimesTamps: false, dateFormat: dateFormatState, ref: ref)})", style: TextStyle( - fontSize: 11, color: secondaryColor(context)), + fontSize: 11, color: context.secondaryColor), ), ), ], diff --git a/lib/modules/more/settings/appearance/widgets/dark_mode_button.dart b/lib/modules/more/settings/appearance/widgets/dark_mode_button.dart index 3d389fc0..fad4f204 100644 --- a/lib/modules/more/settings/appearance/widgets/dark_mode_button.dart +++ b/lib/modules/more/settings/appearance/widgets/dark_mode_button.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/modules/more/settings/appearance/providers/theme_mode_state_provider.dart'; // import 'package:rive/rive.dart'; @@ -30,7 +30,7 @@ class _DarkModeButtonState extends ConsumerState { title: Text(l10n!.dark_mode), subtitle: Text( !isDark ? l10n.off : l10n.on, - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), value: isDark, ); diff --git a/lib/modules/more/settings/appearance/widgets/theme_selector.dart b/lib/modules/more/settings/appearance/widgets/theme_selector.dart index 6f407f1c..55035b43 100644 --- a/lib/modules/more/settings/appearance/widgets/theme_selector.dart +++ b/lib/modules/more/settings/appearance/widgets/theme_selector.dart @@ -4,7 +4,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:mangayomi/main.dart'; import 'package:mangayomi/models/settings.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/modules/more/settings/appearance/providers/flex_scheme_color_state_provider.dart'; class ThemeSelector extends ConsumerStatefulWidget { @@ -96,7 +96,7 @@ class _ThemeSelectorState extends ConsumerState { backgroundColor: theme.primaryColorLight, child: Icon( FontAwesomeIcons.check, - color: secondaryColor(context), + color: context.secondaryColor, size: 16, )), ) diff --git a/lib/modules/more/settings/browse/browse_screen.dart b/lib/modules/more/settings/browse/browse_screen.dart index 5a72b449..af1a226d 100644 --- a/lib/modules/more/settings/browse/browse_screen.dart +++ b/lib/modules/more/settings/browse/browse_screen.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/modules/more/settings/browse/providers/browse_state_provider.dart'; class BrowseSScreen extends ConsumerWidget { @@ -33,7 +33,7 @@ class BrowseSScreen extends ConsumerWidget { children: [ Text(l10n.extensions, style: TextStyle( - fontSize: 13, color: primaryColor(context))), + fontSize: 13, color: context.primaryColor)), ], ), ), @@ -52,7 +52,7 @@ class BrowseSScreen extends ConsumerWidget { subtitle: Text( l10n.auto_extensions_updates_subtitle, style: TextStyle( - fontSize: 11, color: secondaryColor(context))), + fontSize: 11, color: context.secondaryColor)), onChanged: (value) { ref .read(autoUpdateExtensionsStateProvider.notifier) @@ -71,7 +71,7 @@ class BrowseSScreen extends ConsumerWidget { children: [ Text(l10n.global_search, style: TextStyle( - fontSize: 13, color: primaryColor(context))), + fontSize: 13, color: context.primaryColor)), ], ), ), @@ -96,7 +96,7 @@ class BrowseSScreen extends ConsumerWidget { children: [ Text(l10n.nsfw_sources, style: TextStyle( - fontSize: 13, color: primaryColor(context))), + fontSize: 13, color: context.primaryColor)), ], ), ), @@ -113,14 +113,14 @@ class BrowseSScreen extends ConsumerWidget { children: [ Icon( Icons.info_outline_rounded, - color: secondaryColor(context), + color: context.secondaryColor, ), ], ), ), subtitle: Text(l10n.nsfw_sources_info, style: TextStyle( - fontSize: 11, color: secondaryColor(context))), + fontSize: 11, color: context.secondaryColor)), ) ], ), diff --git a/lib/modules/more/settings/downloads/downloads_screen.dart b/lib/modules/more/settings/downloads/downloads_screen.dart index 48a99f1b..46f314fc 100644 --- a/lib/modules/more/settings/downloads/downloads_screen.dart +++ b/lib/modules/more/settings/downloads/downloads_screen.dart @@ -3,8 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:mangayomi/modules/more/settings/downloads/providers/downloads_state_provider.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class DownloadsScreen extends ConsumerStatefulWidget { const DownloadsScreen({super.key}); @@ -38,7 +37,7 @@ class _DownloadsScreenState extends ConsumerState { return AlertDialog( title: Text(l10n.download_location), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView( shrinkWrap: true, children: [ @@ -91,7 +90,7 @@ class _DownloadsScreenState extends ConsumerState { child: Text( l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -104,7 +103,7 @@ class _DownloadsScreenState extends ConsumerState { downloadLocationState.$2.isEmpty ? downloadLocationState.$1 : downloadLocationState.$2, - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), SwitchListTile( diff --git a/lib/modules/more/settings/general/general_screen.dart b/lib/modules/more/settings/general/general_screen.dart index 8339cc20..4fb6233e 100644 --- a/lib/modules/more/settings/general/general_screen.dart +++ b/lib/modules/more/settings/general/general_screen.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/language.dart'; -import 'package:mangayomi/utils/media_query.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; class GeneralScreen extends ConsumerWidget { @@ -30,10 +29,11 @@ class GeneralScreen extends ConsumerWidget { l10n.app_language, ), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, - itemCount: AppLocalizations.supportedLocales.length, + itemCount: + AppLocalizations.supportedLocales.length, itemBuilder: (context, index) { final locale = AppLocalizations.supportedLocales[index]; @@ -64,7 +64,7 @@ class GeneralScreen extends ConsumerWidget { child: Text( l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -75,7 +75,7 @@ class GeneralScreen extends ConsumerWidget { title: Text(l10n.app_language), subtitle: Text( completeLanguageName(l10nLocale.toLanguageTag()), - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ], diff --git a/lib/modules/more/settings/player/player_screen.dart b/lib/modules/more/settings/player/player_screen.dart index f520a5e0..c987dea3 100644 --- a/lib/modules/more/settings/player/player_screen.dart +++ b/lib/modules/more/settings/player/player_screen.dart @@ -2,8 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:mangayomi/modules/more/settings/player/providers/player_state_provider.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:numberpicker/numberpicker.dart'; class PlayerScreen extends ConsumerWidget { @@ -35,7 +34,7 @@ class PlayerScreen extends ConsumerWidget { return AlertDialog( title: Text(context.l10n.markEpisodeAsSeenSetting), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: values.length, @@ -69,7 +68,7 @@ class PlayerScreen extends ConsumerWidget { child: Text( context.l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -80,7 +79,7 @@ class PlayerScreen extends ConsumerWidget { title: Text(context.l10n.markEpisodeAsSeenSetting), subtitle: Text( "$markEpisodeAsSeenType%", - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -122,7 +121,7 @@ class PlayerScreen extends ConsumerWidget { child: Text( context.l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), TextButton( onPressed: () async { @@ -136,7 +135,7 @@ class PlayerScreen extends ConsumerWidget { child: Text( context.l10n.ok, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -147,7 +146,7 @@ class PlayerScreen extends ConsumerWidget { title: Text(context.l10n.default_skip_intro_length), subtitle: Text( "${defaultSkipIntroLength}s", - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -160,7 +159,7 @@ class PlayerScreen extends ConsumerWidget { title: Text(context.l10n.default_skip_forward_skip_length), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: values.length, @@ -195,7 +194,7 @@ class PlayerScreen extends ConsumerWidget { child: Text( context.l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -206,7 +205,7 @@ class PlayerScreen extends ConsumerWidget { title: Text(context.l10n.default_skip_forward_skip_length), subtitle: Text( "${defaultDoubleTapToSkipLength}s", - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -218,7 +217,7 @@ class PlayerScreen extends ConsumerWidget { return AlertDialog( title: Text(context.l10n.default_playback_speed_length), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: values.length, @@ -252,7 +251,7 @@ class PlayerScreen extends ConsumerWidget { child: Text( context.l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -263,7 +262,7 @@ class PlayerScreen extends ConsumerWidget { title: Text(context.l10n.default_playback_speed_length), subtitle: Text( "x$defaultPlayBackSpeed", - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ], diff --git a/lib/modules/more/settings/reader/reader_screen.dart b/lib/modules/more/settings/reader/reader_screen.dart index 3de83aa3..5631c2c4 100644 --- a/lib/modules/more/settings/reader/reader_screen.dart +++ b/lib/modules/more/settings/reader/reader_screen.dart @@ -2,8 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:mangayomi/models/settings.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/modules/more/settings/reader/providers/reader_state_provider.dart'; class ReaderScreen extends ConsumerWidget { @@ -36,7 +35,7 @@ class ReaderScreen extends ConsumerWidget { return AlertDialog( title: Text(context.l10n.default_reading_mode), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: ReaderMode.values.length, @@ -73,7 +72,7 @@ class ReaderScreen extends ConsumerWidget { child: Text( context.l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -84,7 +83,7 @@ class ReaderScreen extends ConsumerWidget { title: Text(context.l10n.default_reading_mode), subtitle: Text( getReaderModeName(defaultReadingMode, context), - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -97,7 +96,7 @@ class ReaderScreen extends ConsumerWidget { context.l10n.double_tap_animation_speed, ), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: 3, @@ -135,7 +134,7 @@ class ReaderScreen extends ConsumerWidget { child: Text( context.l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -146,7 +145,7 @@ class ReaderScreen extends ConsumerWidget { title: Text(context.l10n.double_tap_animation_speed), subtitle: Text( getAnimationSpeedName(doubleTapAnimationSpeed, context), - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -157,7 +156,7 @@ class ReaderScreen extends ConsumerWidget { return AlertDialog( title: Text(context.l10n.background_color), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: BackgroundColor.values.length, @@ -195,7 +194,7 @@ class ReaderScreen extends ConsumerWidget { child: Text( context.l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -206,7 +205,7 @@ class ReaderScreen extends ConsumerWidget { title: Text(context.l10n.background_color), subtitle: Text( getBackgroundColorName(backgroundColor, context), - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -220,7 +219,7 @@ class ReaderScreen extends ConsumerWidget { context.l10n.page_preload_amount, ), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: numbers.length, @@ -254,7 +253,7 @@ class ReaderScreen extends ConsumerWidget { child: Text( context.l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -265,7 +264,7 @@ class ReaderScreen extends ConsumerWidget { title: Text(context.l10n.page_preload_amount), subtitle: Text( context.l10n.page_preload_amount_subtitle, - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -278,7 +277,7 @@ class ReaderScreen extends ConsumerWidget { context.l10n.scale_type, ), content: SizedBox( - width: mediaWidth(context, 0.8), + width: context.mediaWidth(0.8), child: ListView.builder( shrinkWrap: true, itemCount: getScaleTypeNames(context).length, @@ -314,7 +313,7 @@ class ReaderScreen extends ConsumerWidget { child: Text( context.l10n.cancel, style: - TextStyle(color: primaryColor(context)), + TextStyle(color: context.primaryColor), )), ], ) @@ -325,7 +324,7 @@ class ReaderScreen extends ConsumerWidget { title: Text(context.l10n.scale_type), subtitle: Text( getScaleTypeNames(context)[scaleType.index], - style: TextStyle(fontSize: 11, color: secondaryColor(context)), + style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), SwitchListTile( @@ -386,7 +385,6 @@ Color? getBackgroundColor(BackgroundColor backgroundColor) { } String getAnimationSpeedName(int type, BuildContext context) { - return switch (type) { 0 => context.l10n.no_animation, 1 => context.l10n.normal, diff --git a/lib/modules/more/settings/track/manage_trackers/manage_trackers.dart b/lib/modules/more/settings/track/manage_trackers/manage_trackers.dart index 60e2c903..ab500897 100644 --- a/lib/modules/more/settings/track/manage_trackers/manage_trackers.dart +++ b/lib/modules/more/settings/track/manage_trackers/manage_trackers.dart @@ -6,7 +6,7 @@ import 'package:mangayomi/models/track_preference.dart'; import 'package:mangayomi/modules/widgets/gridview_widget.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; import 'package:mangayomi/utils/constant.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class ManageTrackersScreen extends StatefulWidget { const ManageTrackersScreen({super.key}); @@ -55,7 +55,7 @@ class _ManageTrackersScreenState extends State { borderRadius: BorderRadius.circular(10)), child: trackerPref.syncId == -1 ? SizedBox( - width: mediaWidth(context, 1), + width: context.mediaWidth(1), child: const Icon(Icons.local_library_rounded, size: 60)) : Image.asset( diff --git a/lib/modules/more/settings/track/track.dart b/lib/modules/more/settings/track/track.dart index 3f13cdd3..a58dc345 100644 --- a/lib/modules/more/settings/track/track.dart +++ b/lib/modules/more/settings/track/track.dart @@ -11,15 +11,15 @@ import 'package:mangayomi/providers/l10n_providers.dart'; import 'package:mangayomi/services/trackers/anilist.dart'; import 'package:mangayomi/services/trackers/kitsu.dart'; import 'package:mangayomi/services/trackers/myanimelist.dart'; -import 'package:mangayomi/utils/colors.dart'; -import 'package:mangayomi/utils/media_query.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class TrackScreen extends ConsumerWidget { const TrackScreen({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { - final updateProgressAfterReading = ref.watch(updateProgressAfterReadingStateProvider); + final updateProgressAfterReading = + ref.watch(updateProgressAfterReadingStateProvider); final l10n = l10nLocalizations(context)!; return Scaffold( appBar: AppBar( @@ -41,7 +41,8 @@ class TrackScreen extends ConsumerWidget { title: Text(context.l10n.updateProgressAfterReading), onChanged: (value) { ref - .read(updateProgressAfterReadingStateProvider.notifier) + .read(updateProgressAfterReadingStateProvider + .notifier) .set(value); }), Padding( @@ -51,7 +52,7 @@ class TrackScreen extends ConsumerWidget { children: [ Text(l10n.services, style: TextStyle( - fontSize: 13, color: primaryColor(context))), + fontSize: 13, color: context.primaryColor)), ], ), ), @@ -85,14 +86,14 @@ class TrackScreen extends ConsumerWidget { children: [ Icon( Icons.info_outline_rounded, - color: secondaryColor(context), + color: context.secondaryColor, ), ], ), ), subtitle: Text(l10n.tracking_warning_info, style: TextStyle( - fontSize: 11, color: secondaryColor(context))), + fontSize: 11, color: context.secondaryColor)), ), ListTileWidget( title: l10n.manage_trackers, @@ -188,7 +189,7 @@ void _showDialogLogin(BuildContext context, WidgetRef ref) { Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: SizedBox( - width: mediaWidth(context, 1), + width: context.mediaWidth(1), height: 50, child: ElevatedButton( onPressed: isLoading diff --git a/lib/modules/more/settings/track/widgets/track_listile.dart b/lib/modules/more/settings/track/widgets/track_listile.dart index 8d168528..e5262498 100644 --- a/lib/modules/more/settings/track/widgets/track_listile.dart +++ b/lib/modules/more/settings/track/widgets/track_listile.dart @@ -3,7 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:mangayomi/models/track_preference.dart'; import 'package:mangayomi/modules/more/settings/track/providers/track_providers.dart'; import 'package:mangayomi/providers/l10n_providers.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/constant.dart'; class TrackListile extends ConsumerWidget { @@ -63,7 +63,7 @@ class TrackListile extends ConsumerWidget { surfaceTintColor: Colors.transparent, shape: RoundedRectangleBorder( side: BorderSide( - color: secondaryColor(context)), + color: context.secondaryColor), borderRadius: BorderRadius.circular(20))), onPressed: () { @@ -72,7 +72,7 @@ class TrackListile extends ConsumerWidget { child: Text( l10n.cancel, style: TextStyle( - color: secondaryColor(context)), + color: context.secondaryColor), )), const SizedBox(width: 15), ElevatedButton( @@ -89,7 +89,7 @@ class TrackListile extends ConsumerWidget { child: Text( l10n.log_out, style: TextStyle( - color: secondaryColor(context)), + color: context.secondaryColor), )), ], ) diff --git a/lib/modules/more/widgets/list_tile_widget.dart b/lib/modules/more/widgets/list_tile_widget.dart index e23a95d3..3cc4b049 100644 --- a/lib/modules/more/widgets/list_tile_widget.dart +++ b/lib/modules/more/widgets/list_tile_widget.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class ListTileWidget extends StatelessWidget { final VoidCallback onTap; @@ -22,14 +22,14 @@ class ListTileWidget extends StatelessWidget { // subtitle: subtitle != null // ? Text( // subtitle!, - // style: TextStyle(fontSize: 11, color: secondaryColor(context)), + // style: TextStyle(fontSize: 11, color: context.secondaryColor), // ) // : null, leading: SizedBox( height: 40, child: Icon( icon, - color: primaryColor(context), + color: context.primaryColor, )), title: Text(title), trailing: trailing, diff --git a/lib/modules/widgets/bottom_text_widget.dart b/lib/modules/widgets/bottom_text_widget.dart index 6ada5945..a75e2e76 100644 --- a/lib/modules/widgets/bottom_text_widget.dart +++ b/lib/modules/widgets/bottom_text_widget.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class BottomTextWidget extends StatelessWidget { final bool isLoading; @@ -30,7 +30,7 @@ class BottomTextWidget extends StatelessWidget { style: TextStyle( fontSize: fontSize, fontWeight: FontWeight.w600, - color: textColor ?? primaryColor(context), + color: textColor ?? context.primaryColor, ), maxLines: maxLines, overflow: TextOverflow.ellipsis, diff --git a/lib/modules/widgets/cover_view_widget.dart b/lib/modules/widgets/cover_view_widget.dart index 0572785b..4262a0c2 100644 --- a/lib/modules/widgets/cover_view_widget.dart +++ b/lib/modules/widgets/cover_view_widget.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class CoverViewWidget extends StatelessWidget { final List children; @@ -35,7 +35,7 @@ class CoverViewWidget extends StatelessWidget { onLongPress: onLongPress, child: Container( color: isLongPressed != null && isLongPressed! - ? primaryColor(context).withOpacity(0.4) + ? context.primaryColor.withOpacity(0.4) : Colors.transparent, child: image == null ? isComfortableGrid diff --git a/lib/modules/widgets/manga_image_card_widget.dart b/lib/modules/widgets/manga_image_card_widget.dart index 54372d5d..eede39c4 100644 --- a/lib/modules/widgets/manga_image_card_widget.dart +++ b/lib/modules/widgets/manga_image_card_widget.dart @@ -11,7 +11,7 @@ import 'package:mangayomi/models/settings.dart'; import 'package:mangayomi/models/source.dart'; import 'package:mangayomi/modules/manga/detail/manga_detail_main.dart'; import 'package:mangayomi/router/router.dart'; -import 'package:mangayomi/utils/colors.dart'; +import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:mangayomi/utils/constant.dart'; import 'package:mangayomi/utils/headers.dart'; import 'package:mangayomi/modules/widgets/bottom_text_widget.dart'; @@ -75,7 +75,7 @@ class MangaImageCardWidget extends ConsumerWidget { child: Padding( padding: const EdgeInsets.all(4), child: Icon(Icons.collections_bookmark, - color: primaryColor(context)), + color: context.primaryColor), )), BottomTextWidget(text: getMangaDetail!.name!) ]); diff --git a/lib/services/anime_extractors/dood_extractor.dart b/lib/services/anime_extractors/dood_extractor.dart index cf7d399c..b85c7aa5 100644 --- a/lib/services/anime_extractors/dood_extractor.dart +++ b/lib/services/anime_extractors/dood_extractor.dart @@ -1,7 +1,7 @@ import 'dart:math'; import 'package:http/http.dart' as http; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; class DoodExtractor { Future> videosFromUrl( diff --git a/lib/services/anime_extractors/filemoon.dart b/lib/services/anime_extractors/filemoon.dart index 518b47d5..2a2b491a 100644 --- a/lib/services/anime_extractors/filemoon.dart +++ b/lib/services/anime_extractors/filemoon.dart @@ -1,7 +1,7 @@ import 'package:http/http.dart' as http; import 'package:js_packer/js_packer.dart'; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:mangayomi/utils/xpath_selector.dart'; class FilemoonExtractor { diff --git a/lib/services/anime_extractors/gogocdn_extractor.dart b/lib/services/anime_extractors/gogocdn_extractor.dart index e0c9415f..98049d4b 100644 --- a/lib/services/anime_extractors/gogocdn_extractor.dart +++ b/lib/services/anime_extractors/gogocdn_extractor.dart @@ -4,7 +4,7 @@ import 'package:http/http.dart' as http; import 'package:mangayomi/eval/model/m_bridge.dart'; import 'package:mangayomi/models/video.dart'; import 'package:html/parser.dart' as parser; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; class GogoCdnExtractor { final http.Client client = http.Client(); diff --git a/lib/services/anime_extractors/mp4upload_extractor.dart b/lib/services/anime_extractors/mp4upload_extractor.dart index 244c2f78..c97378c0 100644 --- a/lib/services/anime_extractors/mp4upload_extractor.dart +++ b/lib/services/anime_extractors/mp4upload_extractor.dart @@ -1,7 +1,7 @@ import 'package:http/http.dart' as http; import 'package:js_packer/js_packer.dart'; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:mangayomi/utils/xpath_selector.dart'; class Mp4uploadExtractor { diff --git a/lib/services/anime_extractors/mystream_extractor.dart b/lib/services/anime_extractors/mystream_extractor.dart index 2db68197..e5430ada 100644 --- a/lib/services/anime_extractors/mystream_extractor.dart +++ b/lib/services/anime_extractors/mystream_extractor.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:http/http.dart' as http; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; class MyStreamExtractor { Future> videosFromUrl( diff --git a/lib/services/anime_extractors/mytv_extractor.dart b/lib/services/anime_extractors/mytv_extractor.dart index 6c24946a..ef8934f8 100644 --- a/lib/services/anime_extractors/mytv_extractor.dart +++ b/lib/services/anime_extractors/mytv_extractor.dart @@ -1,7 +1,7 @@ import 'package:http/http.dart' as http; import 'package:html/parser.dart' show parse; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; class MytvExtractor { final http.Client client = http.Client(); diff --git a/lib/services/anime_extractors/okru_extractor.dart b/lib/services/anime_extractors/okru_extractor.dart index 203606c0..5dec2471 100644 --- a/lib/services/anime_extractors/okru_extractor.dart +++ b/lib/services/anime_extractors/okru_extractor.dart @@ -1,7 +1,7 @@ import 'package:http/http.dart' as http; import 'package:html/parser.dart' show parse; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; class OkruExtractor { final http.Client client = http.Client(); diff --git a/lib/services/anime_extractors/sendvid_extractor.dart b/lib/services/anime_extractors/sendvid_extractor.dart index 27f1bb31..e3447868 100644 --- a/lib/services/anime_extractors/sendvid_extractor.dart +++ b/lib/services/anime_extractors/sendvid_extractor.dart @@ -1,7 +1,7 @@ import 'package:http/http.dart' as http; import 'package:html/parser.dart' as parser; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; class SendvidExtractor { final http.Client client = http.Client(); diff --git a/lib/services/anime_extractors/sibnet_extractor.dart b/lib/services/anime_extractors/sibnet_extractor.dart index 3a51156b..1c789ad6 100644 --- a/lib/services/anime_extractors/sibnet_extractor.dart +++ b/lib/services/anime_extractors/sibnet_extractor.dart @@ -1,6 +1,6 @@ import 'package:http/http.dart' as http; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; class SibnetExtractor { final http.Client client = http.Client(); diff --git a/lib/services/anime_extractors/streamlare_extractor.dart b/lib/services/anime_extractors/streamlare_extractor.dart index d7ab5efc..e759f471 100644 --- a/lib/services/anime_extractors/streamlare_extractor.dart +++ b/lib/services/anime_extractors/streamlare_extractor.dart @@ -1,6 +1,7 @@ import 'package:http/http.dart' as http; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/others.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; class StreamlareExtractor { final http.Client client = http.Client(); diff --git a/lib/services/anime_extractors/streamtape_extractor.dart b/lib/services/anime_extractors/streamtape_extractor.dart index 082ee0df..c87b0e72 100644 --- a/lib/services/anime_extractors/streamtape_extractor.dart +++ b/lib/services/anime_extractors/streamtape_extractor.dart @@ -1,7 +1,7 @@ import 'package:mangayomi/models/video.dart'; import 'package:html/parser.dart' show parse; import 'package:http/http.dart' as http; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; class StreamTapeExtractor { Future> videosFromUrl(String url, diff --git a/lib/services/anime_extractors/streamwish_extractor.dart b/lib/services/anime_extractors/streamwish_extractor.dart index d5e8912d..f8fd010e 100644 --- a/lib/services/anime_extractors/streamwish_extractor.dart +++ b/lib/services/anime_extractors/streamwish_extractor.dart @@ -1,7 +1,8 @@ import 'package:http/http.dart' as http; import 'package:js_packer/js_packer.dart'; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/others.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:mangayomi/utils/xpath_selector.dart'; class StreamWishExtractor { @@ -19,11 +20,11 @@ class StreamWishExtractor { if (jsEval.isEmpty) { return []; } - - String? masterUrl = jsEval.first + + String? masterUrl = jsEval.first! .let( (script) { - if (script!.contains("function(p,a,c")) { + if (script.contains("function(p,a,c")) { return JSPacker(script).unpack() ?? ""; } return script; diff --git a/lib/services/anime_extractors/vidbom_extractor.dart b/lib/services/anime_extractors/vidbom_extractor.dart index 5bc47b28..d7ac6119 100644 --- a/lib/services/anime_extractors/vidbom_extractor.dart +++ b/lib/services/anime_extractors/vidbom_extractor.dart @@ -1,6 +1,6 @@ import 'package:http/http.dart' as http; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:mangayomi/utils/xpath_selector.dart'; class VidBomExtractor { diff --git a/lib/services/anime_extractors/voe_extractor.dart b/lib/services/anime_extractors/voe_extractor.dart index 4e8edd0a..5fc36a3f 100644 --- a/lib/services/anime_extractors/voe_extractor.dart +++ b/lib/services/anime_extractors/voe_extractor.dart @@ -1,6 +1,6 @@ import 'package:http/http.dart' as http; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:mangayomi/utils/xpath_selector.dart'; class VoeExtractor { diff --git a/lib/services/anime_extractors/your_upload_extractor.dart b/lib/services/anime_extractors/your_upload_extractor.dart index d69560f2..f4ae514c 100644 --- a/lib/services/anime_extractors/your_upload_extractor.dart +++ b/lib/services/anime_extractors/your_upload_extractor.dart @@ -1,6 +1,6 @@ import 'package:http/http.dart' as http; import 'package:mangayomi/models/video.dart'; -import 'package:mangayomi/utils/extensions.dart'; +import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:mangayomi/utils/xpath_selector.dart'; class YourUploadExtractor { diff --git a/lib/sources/source_test.dart b/lib/sources/source_test.dart index b98babb7..e59cb3f5 100644 --- a/lib/sources/source_test.dart +++ b/lib/sources/source_test.dart @@ -23,6 +23,9 @@ import 'dart:convert'; class TestSource extends MProvider { TestSource(); + @override + bool get supportsLatest => true; + @override Future getPopular(MSource source, int page) async { // TODO: implement diff --git a/lib/utils/colors.dart b/lib/utils/colors.dart deleted file mode 100644 index 9af6e790..00000000 --- a/lib/utils/colors.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:flutter/material.dart'; - -Color primaryColor(BuildContext context) { - return Theme.of(context).primaryColor; -} - -Color secondaryColor(BuildContext context) { - return Theme.of(context).iconTheme.color!.withOpacity(0.7); -} diff --git a/lib/utils/extensions/build_context_extensions.dart b/lib/utils/extensions/build_context_extensions.dart new file mode 100644 index 00000000..cebcf3b0 --- /dev/null +++ b/lib/utils/extensions/build_context_extensions.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; + +extension BuildContextExtensions on BuildContext { + bool get isLight { + return Theme.of(this).brightness == Brightness.light; + } + + Color get primaryColor { + return Theme.of(this).primaryColor; + } + + Color get secondaryColor { + return Theme.of(this).iconTheme.color!.withOpacity(0.7); + } + + double mediaHeight(double data) { + return MediaQuery.of(this).size.height * data; + } + + double mediaWidth(double data) { + return MediaQuery.of(this).size.width * data; + } + + bool get isDesktop { + return MediaQuery.of(this).size.width >= 1200; + } + + bool get isTablet { + return MediaQuery.of(this).size.width >= 600; + } +} diff --git a/lib/utils/extensions.dart b/lib/utils/extensions/dom_extensions.dart similarity index 62% rename from lib/utils/extensions.dart rename to lib/utils/extensions/dom_extensions.dart index cbcc5b0e..2e63da49 100644 --- a/lib/utils/extensions.dart +++ b/lib/utils/extensions/dom_extensions.dart @@ -2,70 +2,6 @@ import 'package:html/dom.dart'; import 'package:mangayomi/utils/reg_exp_matcher.dart'; import 'package:xpath_selector_html_parser/xpath_selector_html_parser.dart'; -extension StringExtensions on String { - String substringAfter(String pattern) { - final startIndex = indexOf(pattern); - if (startIndex == -1) return substring(0); - - final start = startIndex + pattern.length; - return substring(start); - } - - String substringAfterLast(String pattern) { - return split(pattern).last; - } - - String substringBefore(String pattern) { - final endIndex = indexOf(pattern); - if (endIndex == -1) return substring(0); - - return substring(0, endIndex); - } - - String substringBeforeLast(String pattern) { - final endIndex = lastIndexOf(pattern); - if (endIndex == -1) return substring(0); - - return substring(0, endIndex); - } - - String substringBetween(String left, String right) { - int startIndex = 0; - int index = indexOf(left, startIndex); - if (index == -1) return ""; - int leftIndex = index + left.length; - int rightIndex = indexOf(right, leftIndex); - if (rightIndex == -1) return ""; - startIndex = rightIndex + right.length; - return substring(leftIndex, rightIndex); - } - - bool isMediaVideo() { - return [ - "3gp", - "avi", - "mpg", - "mpeg", - "webm", - "ogg", - "flv", - "m4v", - "mvp", - "mp4", - "wmv", - "mkv", - "mov", - "ts" - ].any((extension) => toLowerCase().endsWith(extension)); - } -} - -extension LetExtension on T { - R let(R Function(T) block) { - return block(this); - } -} - extension DocumentExtension on Document? { List? select(String selector) { try { diff --git a/lib/utils/extensions/others.dart b/lib/utils/extensions/others.dart new file mode 100644 index 00000000..acbd466e --- /dev/null +++ b/lib/utils/extensions/others.dart @@ -0,0 +1,5 @@ +extension LetExtension on T { + R let(R Function(T) block) { + return block(this); + } +} diff --git a/lib/utils/extensions/string_extensions.dart b/lib/utils/extensions/string_extensions.dart new file mode 100644 index 00000000..24b0640b --- /dev/null +++ b/lib/utils/extensions/string_extensions.dart @@ -0,0 +1,57 @@ +extension StringExtensions on String { + String substringAfter(String pattern) { + final startIndex = indexOf(pattern); + if (startIndex == -1) return substring(0); + + final start = startIndex + pattern.length; + return substring(start); + } + + String substringAfterLast(String pattern) { + return split(pattern).last; + } + + String substringBefore(String pattern) { + final endIndex = indexOf(pattern); + if (endIndex == -1) return substring(0); + + return substring(0, endIndex); + } + + String substringBeforeLast(String pattern) { + final endIndex = lastIndexOf(pattern); + if (endIndex == -1) return substring(0); + + return substring(0, endIndex); + } + + String substringBetween(String left, String right) { + int startIndex = 0; + int index = indexOf(left, startIndex); + if (index == -1) return ""; + int leftIndex = index + left.length; + int rightIndex = indexOf(right, leftIndex); + if (rightIndex == -1) return ""; + startIndex = rightIndex + right.length; + return substring(leftIndex, rightIndex); + } + + bool isMediaVideo() { + return [ + "3gp", + "avi", + "mpg", + "mpeg", + "webm", + "ogg", + "flv", + "m4v", + "mvp", + "mp4", + "wmv", + "mkv", + "mov", + "ts" + ].any((extension) => toLowerCase().endsWith(extension)); + } +} diff --git a/lib/utils/media_query.dart b/lib/utils/media_query.dart deleted file mode 100644 index 30f9f0a8..00000000 --- a/lib/utils/media_query.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:flutter/material.dart'; - -double mediaHeight(BuildContext context, double data) { - return MediaQuery.of(context).size.height * data; -} - -double mediaWidth(BuildContext context, double data) { - return MediaQuery.of(context).size.width * data; -} - -bool isDesktop(BuildContext context) { - return MediaQuery.of(context).size.width >= 1200; -} - -bool isTablet(BuildContext context) { - return MediaQuery.of(context).size.width >= 600; -} \ No newline at end of file diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart deleted file mode 100644 index 1b4376ab..00000000 --- a/lib/utils/utils.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:flutter/material.dart'; - -bool isLight(BuildContext context) { - return Theme.of(context).brightness == Brightness.light; -}