From c6a200c2249b0cf2a53ec969a70dfadaf0f5e6a8 Mon Sep 17 00:00:00 2001 From: zyrouge Date: Sat, 4 Nov 2023 22:58:07 +0530 Subject: [PATCH] chore: backup --- .phrasey/config.toml | 2 +- .phrasey/hooks/dart-sync.js | 22 +-- .phrasey/schema.toml | 68 ++++++++ cli/prerequisites.dart | 2 + cli/tasks/i18n.dart | 11 ++ cli/tasks/meta.dart | 2 +- i18n/en.toml | 17 ++ lib/core/anilist/translations.dart | 52 +++--- lib/core/app/meta.dart | 4 +- lib/core/tenka/utils.dart | 6 +- lib/core/themes/colors.dart | 93 +++++++++-- lib/ui/base.dart | 5 +- lib/ui/components/anilist/media_slide.dart | 158 ++++++++++-------- lib/ui/components/slideshow.dart | 2 - lib/ui/components/super_imposer.dart | 1 - lib/ui/components/toast.dart | 3 - lib/ui/pages/_home/components/appbar.dart | 1 - lib/ui/pages/home/view.dart | 1 - .../pages/search/components/search_bar.dart | 1 - .../pages/settings/components/appearance.dart | 6 +- .../settings/components/tiles/choice.dart | 31 +++- lib/ui/pages/settings/view.dart | 4 +- lib/ui/pages/view/components/body.dart | 1 - packages/anilist/lib/endpoints/graphql.dart | 2 +- packages/anilist/lib/endpoints/media.dart | 2 +- .../anilist/lib/endpoints/media_list.dart | 2 +- packages/anilist/lib/endpoints/relation.dart | 2 +- packages/anilist/lib/endpoints/user.dart | 2 +- packages/anilist/lib/models/character.dart | 2 +- .../anilist/lib/models/character_edge.dart | 2 +- .../anilist/lib/models/character_role.dart | 2 +- packages/anilist/lib/models/fuzzy_date.dart | 2 +- packages/anilist/lib/models/media.dart | 2 +- .../anilist/lib/models/media_list_entry.dart | 2 +- .../anilist/lib/models/media_list_sort.dart | 2 +- .../anilist/lib/models/media_list_status.dart | 2 +- packages/anilist/lib/models/media_sort.dart | 2 +- packages/anilist/lib/models/media_status.dart | 2 +- packages/anilist/lib/models/media_type.dart | 2 +- .../anilist/lib/models/relation_edge.dart | 2 +- .../anilist/lib/models/relation_type.dart | 2 +- packages/anilist/lib/models/seasons.dart | 2 +- packages/anilist/lib/models/user.dart | 2 +- packages/anilist/pubspec.lock | 8 +- packages/shared/pubspec.lock | 6 +- pubspec.yaml | 2 +- 46 files changed, 358 insertions(+), 191 deletions(-) create mode 100644 cli/tasks/i18n.dart diff --git a/.phrasey/config.toml b/.phrasey/config.toml index 8ace111b..54beae58 100644 --- a/.phrasey/config.toml +++ b/.phrasey/config.toml @@ -10,7 +10,7 @@ format = "toml" [output] dir = "../assets/translations" format = "json" -stringFormat = "format-string" +stringFormat = "python-positional-format-string" [hooks] files = ["./hooks/dart-sync.js"] diff --git a/.phrasey/hooks/dart-sync.js b/.phrasey/hooks/dart-sync.js index 9354d823..5a5fdd48 100644 --- a/.phrasey/hooks/dart-sync.js +++ b/.phrasey/hooks/dart-sync.js @@ -43,20 +43,14 @@ async function createTranslationDart(phrasey, state, log) { .join(", "); const callArgs = x.parameters.join(", "); dynamicKeys.push( - ` String ${cname}(${params}) => StringUtils.formatPositional(_json['keys']['${x.name}'], [${callArgs}]);` + ` String ${cname}(${params}) => StringUtils.formatPositional(_key('${x.name}'), [${callArgs}]);` ); } else { - staticKeys.push( - ` String ${cname} get => _json['keys']['${x.name}'];` - ); + staticKeys.push(` String get ${cname} => _key('${x.name}');`); } } const content = ` -import 'dart:convert'; -import 'package:utilx/locale.dart'; -import 'package:utilx/utilx.dart'; - part of 'translator.dart'; class Translation { @@ -64,13 +58,15 @@ class Translation { final Map _json; - String localeDisplayName get => json['locale']['display']; - String localeNativeName get => json['locale']['native']; - String localeCode get => json['locale']['code']; - Locale locale get => Locale(localeDisplayName, localeNativeName, localeCode); + JsonMap get _localeJson => _json['locale'] as JsonMap; + String get localeDisplayName => _localeJson['display']; + String get localeNativeName => _localeJson['native']; + String get localeCode => _localeJson['code']; + Locale get locale => Locale(localeDisplayName, localeNativeName, localeCode); + JsonMap get _keysJson => _json['keys'] as JsonMap; + String _key(final String name) => _keysJson[name] as String; ${staticKeys.join("\n")} - ${dynamicKeys.join("\n")} static const List availableLocales = [${locales diff --git a/.phrasey/schema.toml b/.phrasey/schema.toml index b8a592c1..e0fd815d 100644 --- a/.phrasey/schema.toml +++ b/.phrasey/schema.toml @@ -215,3 +215,71 @@ description = "Chapters read" [[keys]] name = "VolumesRead" description = "Volumes read" + +[[keys]] +name = "Red" +description = "Red" + +[[keys]] +name = "Orange" +description = "Orange" + +[[keys]] +name = "Amber" +description = "Amber" + +[[keys]] +name = "Yellow" +description = "Yellow" + +[[keys]] +name = "Lime" +description = "Lime" + +[[keys]] +name = "Green" +description = "Green" + +[[keys]] +name = "Emerald" +description = "Emerald" + +[[keys]] +name = "Teal" +description = "Teal" + +[[keys]] +name = "Cyan" +description = "Cyan" + +[[keys]] +name = "Sky" +description = "Sky" + +[[keys]] +name = "Blue" +description = "Blue" + +[[keys]] +name = "Indigo" +description = "Indigo" + +[[keys]] +name = "Violet" +description = "Violet" + +[[keys]] +name = "Purple" +description = "Purple" + +[[keys]] +name = "Fuchsia" +description = "Fuchsia" + +[[keys]] +name = "Pink" +description = "Pink" + +[[keys]] +name = "Rose" +description = "Rose" diff --git a/cli/prerequisites.dart b/cli/prerequisites.dart index a4f5667e..ca373c36 100644 --- a/cli/prerequisites.dart +++ b/cli/prerequisites.dart @@ -1,8 +1,10 @@ import 'tasks/build_runner.dart' as build_runner; +import 'tasks/i18n.dart' as i18n; import 'tasks/icon.dart' as icon; import 'tasks/meta.dart' as meta; Future main(final List args) async { + await i18n.main(args); await build_runner.main(args); await meta.main(); await icon.main(); diff --git a/cli/tasks/i18n.dart b/cli/tasks/i18n.dart new file mode 100644 index 00000000..54bbd891 --- /dev/null +++ b/cli/tasks/i18n.dart @@ -0,0 +1,11 @@ +import 'dart:io'; + +Future main(final List args) async { + final ProcessResult result = await Process.run( + 'npm', + ['run', 'i18n:build'], + ); + if (result.exitCode != 0) { + throw Exception('i18n builder failed with error code $exitCode'); + } +} diff --git a/cli/tasks/meta.dart b/cli/tasks/meta.dart index 7e918cc5..054a2a5a 100644 --- a/cli/tasks/meta.dart +++ b/cli/tasks/meta.dart @@ -16,7 +16,7 @@ Future main() async { Future getGeneratedAppMetaContent() async => ''' part of 'meta.dart'; -abstract class _GeneratedAppMeta { +abstract class GeneratedAppMeta { static const String version = '${await getVersion()}'; static const int builtAtMs = ${DateTime.now().millisecondsSinceEpoch}; } diff --git a/i18n/en.toml b/i18n/en.toml index 60862aae..9bedcb79 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -54,3 +54,20 @@ TimeSpent = "Time spent" TotalManga = "Total manga" ChaptersRead = "Chapters read" VolumesRead = "Volumes read" +Red = "Red" +Orange = "Orange" +Amber = "Amber" +Yellow = "Yellow" +Lime = "Lime" +Green = "Green" +Emerald = "Emerald" +Teal = "Teal" +Cyan = "Cyan" +Sky = "Sky" +Blue = "Blue" +Indigo = "Indigo" +Violet = "Violet" +Purple = "Purple" +Fuchsia = "Fuchsia" +Pink = "Pink" +Rose = "Rose" diff --git a/lib/core/anilist/translations.dart b/lib/core/anilist/translations.dart index 96c6408c..8272df88 100644 --- a/lib/core/anilist/translations.dart +++ b/lib/core/anilist/translations.dart @@ -33,39 +33,39 @@ extension TenkaTypeAnilistUtils on TenkaType { } extension AnimeSeasonsTUtils on AnimeSeasons { - String getTitleCase(final Translation translations) { + String getTitleCase(final Translation translation) { switch (this) { case AnimeSeasons.winter: - return translations.winter; + return translation.winter; case AnimeSeasons.spring: - return translations.spring; + return translation.spring; case AnimeSeasons.summer: - return translations.summer; + return translation.summer; case AnimeSeasons.fall: - return translations.fall; + return translation.fall; } } } extension AnilistMediaTUtils on AnilistMedia { - String getWatchtime(final Translation translations) { + String getWatchtime(final Translation translation) { switch (type) { case AnilistMediaType.anime: if (format == AnilistMediaFormat.movie) { return duration != null ? PrettyDurations.prettyHoursMinutesShort( - translations, + translation, Duration(minutes: duration!), ) - : translations.nMins(Translation.unk); + : translation.nMins(Translation.unk); } - return translations.nEps(episodes?.toString() ?? Translation.unk); + return translation.nEps(episodes?.toString() ?? Translation.unk); case AnilistMediaType.manga: - return translations.nChs(chapters?.toString() ?? Translation.unk); + return translation.nChs(chapters?.toString() ?? Translation.unk); } } @@ -78,32 +78,32 @@ extension AnilistMediaTUtils on AnilistMedia { } extension AnilistRelationTypeTUtils on AnilistRelationType { - String getTitleCase(final Translation translations) => + String getTitleCase(final Translation translation) => StringCase(name).titleCase; } extension AnilistCharacterRoleTUtils on AnilistCharacterRole { - String getTitleCase(final Translation translations) => + String getTitleCase(final Translation translation) => StringCase(name).titleCase; } extension AnilistMediaStatusTUtils on AnilistMediaStatus { - String getTitleCase(final Translation translations) { + String getTitleCase(final Translation translation) { switch (this) { case AnilistMediaStatus.cancelled: - return translations.cancelled; + return translation.cancelled; case AnilistMediaStatus.releasing: - return translations.releasing; + return translation.releasing; case AnilistMediaStatus.notYetReleased: - return translations.notYetReleased; + return translation.notYetReleased; case AnilistMediaStatus.finished: - return translations.finished; + return translation.finished; case AnilistMediaStatus.hiatus: - return translations.hiatus; + return translation.hiatus; } } } @@ -123,30 +123,30 @@ const Map _anilistMediaFormatTitleMap = }; extension AnilistMediaFormatTUtils on AnilistMediaFormat { - String getTitleCase(final Translation translations) => + String getTitleCase(final Translation translation) => _anilistMediaFormatTitleMap[this]!; } extension AnilistMediaListStatusTUtils on AnilistMediaListStatus { - String getTitleCase(final Translation translations) { + String getTitleCase(final Translation translation) { switch (this) { case AnilistMediaListStatus.current: - return translations.current; + return translation.current; case AnilistMediaListStatus.planning: - return translations.planning; + return translation.planning; case AnilistMediaListStatus.completed: - return translations.completed; + return translation.completed; case AnilistMediaListStatus.dropped: - return translations.dropped; + return translation.dropped; case AnilistMediaListStatus.paused: - return translations.paused; + return translation.paused; case AnilistMediaListStatus.repeating: - return translations.repeating; + return translation.repeating; } } } diff --git a/lib/core/app/meta.dart b/lib/core/app/meta.dart index 3e58acfe..4e7319dc 100644 --- a/lib/core/app/meta.dart +++ b/lib/core/app/meta.dart @@ -6,7 +6,7 @@ abstract class AppMeta { static const String scheme = 'kazahana'; static const String yuki = '雪'; - static const String version = _GeneratedAppMeta.version; + static const String version = GeneratedAppMeta.version; static final DateTime builtAt = - DateTime.fromMillisecondsSinceEpoch(_GeneratedAppMeta.builtAtMs); + DateTime.fromMillisecondsSinceEpoch(GeneratedAppMeta.builtAtMs); } diff --git a/lib/core/tenka/utils.dart b/lib/core/tenka/utils.dart index 818944b6..72d42027 100644 --- a/lib/core/tenka/utils.dart +++ b/lib/core/tenka/utils.dart @@ -2,13 +2,13 @@ import 'package:tenka/tenka.dart'; import '../translator/exports.dart'; extension TenkaTypeUtils on TenkaType { - String getTitleCase(final Translation translations) { + String getTitleCase(final Translation translation) { switch (this) { case TenkaType.anime: - return translations.anime; + return translation.anime; case TenkaType.manga: - return translations.manga; + return translation.manga; } } } diff --git a/lib/core/themes/colors.dart b/lib/core/themes/colors.dart index 84563431..9359d6df 100644 --- a/lib/core/themes/colors.dart +++ b/lib/core/themes/colors.dart @@ -1,23 +1,24 @@ import 'package:flutter/material.dart'; +import '../translator/exports.dart'; abstract class ForegroundColors { - static const Color red = Color(0xef4444ff); - static const Color orange = Color(0xf97316ff); - static const Color amber = Color(0xf59e0bff); - static const Color yellow = Color(0xeab308ff); - static const Color lime = Color(0x84cc16ff); - static const Color green = Color(0x22c55eff); - static const Color emerald = Color(0x10b981ff); - static const Color teal = Color(0x14b8a6ff); - static const Color cyan = Color(0x06b6d4ff); - static const Color sky = Color(0x0ea5e9ff); - static const Color blue = Color(0x3b82f6ff); - static const Color indigo = Color(0x6366f1ff); - static const Color violet = Color(0x8b5cf6ff); - static const Color purple = Color(0xa855f7ff); - static const Color fuchsia = Color(0xd946efff); - static const Color pink = Color(0xec4899ff); - static const Color rose = Color(0xf43f5eff); + static const Color red = Color(0xffef4444); + static const Color orange = Color(0xfff97316); + static const Color amber = Color(0xfff59e0b); + static const Color yellow = Color(0xffeab308); + static const Color lime = Color(0xff84cc16); + static const Color green = Color(0xff22c55e); + static const Color emerald = Color(0xff10b981); + static const Color teal = Color(0xff14b8a6); + static const Color cyan = Color(0xff06b6d4); + static const Color sky = Color(0xff0ea5e9); + static const Color blue = Color(0xff3b82f6); + static const Color indigo = Color(0xff6366f1); + static const Color violet = Color(0xff8b5cf6); + static const Color purple = Color(0xffa855f7); + static const Color fuchsia = Color(0xffd946ef); + static const Color pink = Color(0xffec4899); + static const Color rose = Color(0xfff43f5e); static const Map colors = { 'red': red, @@ -42,4 +43,62 @@ abstract class ForegroundColors { static Color? find(final String name) => colors[name]; static List names() => colors.keys.toList(); + + static String getTitleCase(final Translation translation, final String name) { + switch (name) { + case 'red': + return translation.red; + + case 'orange': + return translation.orange; + + case 'amber': + return translation.amber; + + case 'yellow': + return translation.yellow; + + case 'lime': + return translation.lime; + + case 'green': + return translation.green; + + case 'emerald': + return translation.emerald; + + case 'teal': + return translation.teal; + + case 'cyan': + return translation.cyan; + + case 'sky': + return translation.sky; + + case 'blue': + return translation.blue; + + case 'indigo': + return translation.indigo; + + case 'violet': + return translation.violet; + + case 'purple': + return translation.purple; + + case 'fuchsia': + return translation.fuchsia; + + case 'pink': + return translation.pink; + + case 'rose': + return translation.rose; + + default: + return name; + } + } } diff --git a/lib/ui/base.dart b/lib/ui/base.dart index 6edb97a0..55123fed 100644 --- a/lib/ui/base.dart +++ b/lib/ui/base.dart @@ -18,11 +18,9 @@ class _BaseAppState extends State { @override void initState() { super.initState(); - theme = Themer.defaultTheme(); scale = RelativeScaleData.defaultScale; - translationId = Translator.identifier; - + translationId = ''; AppEvents.stream.listen((final AppEvent event) { if (event == AppEvent.settingsChange) { final ThemerThemeData nTheme = Themer.getCurrentTheme(); @@ -38,7 +36,6 @@ class _BaseAppState extends State { }); } } - if (event == AppEvent.translationsChange) { final String nTranslationId = Translator.identifier; if (translationId != nTranslationId) { diff --git a/lib/ui/components/anilist/media_slide.dart b/lib/ui/components/anilist/media_slide.dart index 890bd26c..7d4f21b5 100644 --- a/lib/ui/components/anilist/media_slide.dart +++ b/lib/ui/components/anilist/media_slide.dart @@ -15,6 +15,70 @@ class AnilistMediaSlide extends StatefulWidget { class _AnilistMediaSlideState extends State with AutomaticKeepAliveClientMixin { + Widget buildThumbnail(final BuildContext context) => ClipRRect( + borderRadius: BorderRadius.circular(context.r.scale(1)), + child: AspectRatio( + aspectRatio: AnilistMediaTile.coverRatio, + child: FadeInImage( + placeholder: MemoryImage(Placeholders.transparent1x1Image), + image: NetworkImage(widget.media.coverImageExtraLarge), + fit: BoxFit.cover, + ), + ), + ); + + Widget buildContent(final BuildContext context) => Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Wrap( + spacing: context.r.scale(0.25), + runSpacing: context.r.scale(0.2), + alignment: WrapAlignment.center, + children: [ + AnilistMediaTile.buildFormatChip( + context: context, + media: widget.media, + ), + AnilistMediaTile.buildWatchtimeChip( + context: context, + media: widget.media, + ), + if (widget.media.averageScore != null) + AnilistMediaTile.buildRatingChip( + context: context, + media: widget.media, + ), + if (widget.media.startDate != null || + widget.media.endDate != null) + AnilistMediaTile.buildAirdateChip( + context: context, + media: widget.media, + ), + if (widget.media.isAdult) + AnilistMediaTile.buildNSFWChip( + context: context, + media: widget.media, + ), + ], + ), + SizedBox(height: context.r.scale(0.25)), + Text( + widget.media.titleUserPreferred, + style: Theme.of(context) + .textTheme + .headlineSmall! + .copyWith(fontWeight: FontWeight.bold), + ), + SizedBox(height: context.r.scale(0.25)), + if (widget.media.description != null) + Text( + widget.media.description!, + maxLines: 5, + overflow: TextOverflow.ellipsis, + ), + ], + ); + @override Widget build(final BuildContext context) { super.build(context); @@ -41,26 +105,23 @@ class _AnilistMediaSlideState extends State child: Material( type: MaterialType.transparency, child: InkWell( - onTap: () { - Navigator.of(context) - .pusher - .pushToViewPageFromMedia(widget.media); - }, child: DecoratedBox( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ - Theme.of(context) - .bottomAppBarTheme - .color! - .withOpacity(0.25), - Theme.of(context).bottomAppBarTheme.color!, + Theme.of(context).colorScheme.background.withOpacity(0.3), + Theme.of(context).colorScheme.background.withOpacity(0.7), ], ), ), ), + onTap: () { + Navigator.of(context) + .pusher + .pushToViewPageFromMedia(widget.media); + }, ), ), ), @@ -68,73 +129,24 @@ class _AnilistMediaSlideState extends State alignment: Alignment.bottomLeft, child: IgnorePointer( child: Padding( - padding: EdgeInsets.all(HorizontalBodyPadding.size(context)), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, + padding: EdgeInsets.all(context.r.scale(1)), + child: Row( + // mainAxisSize: MainAxisSize.min, + // mainAxisAlignment: MainAxisAlignment.end, + // crossAxisAlignment: CrossAxisAlignment.start, children: [ + buildThumbnail(context), + // SizedBox(height: context.r.scale(0.5)), + SizedBox(width: context.r.scale(1.5)), Expanded( - child: ClipRRect( - borderRadius: BorderRadius.circular(context.r.scale(0.5)), - child: AspectRatio( - aspectRatio: AnilistMediaTile.coverRatio, - child: FadeInImage( - placeholder: - MemoryImage(Placeholders.transparent1x1Image), - image: - NetworkImage(widget.media.coverImageExtraLarge), - fit: BoxFit.cover, - ), - ), + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + buildContent(context), + ], ), ), - SizedBox(height: context.r.scale(0.5)), - Wrap( - spacing: context.r.scale(0.25), - runSpacing: context.r.scale(0.2), - alignment: WrapAlignment.center, - children: [ - AnilistMediaTile.buildFormatChip( - context: context, - media: widget.media, - ), - AnilistMediaTile.buildWatchtimeChip( - context: context, - media: widget.media, - ), - if (widget.media.averageScore != null) - AnilistMediaTile.buildRatingChip( - context: context, - media: widget.media, - ), - if (widget.media.startDate != null || - widget.media.endDate != null) - AnilistMediaTile.buildAirdateChip( - context: context, - media: widget.media, - ), - if (widget.media.isAdult) - AnilistMediaTile.buildNSFWChip( - context: context, - media: widget.media, - ), - ], - ), - SizedBox(height: context.r.scale(0.25)), - Text( - widget.media.titleUserPreferred, - style: Theme.of(context) - .textTheme - .headlineSmall! - .copyWith(fontWeight: FontWeight.bold), - ), - SizedBox(height: context.r.scale(0.25)), - if (widget.media.description != null) - Text( - widget.media.description!, - maxLines: 5, - overflow: TextOverflow.ellipsis, - ), ], ), ), diff --git a/lib/ui/components/slideshow.dart b/lib/ui/components/slideshow.dart index 183c977d..a09d3489 100644 --- a/lib/ui/components/slideshow.dart +++ b/lib/ui/components/slideshow.dart @@ -25,12 +25,10 @@ class _SlideshowState extends State @override void initState() { super.initState(); - tabController = TabController( length: widget.children.length, vsync: this, ); - scheduleSlideChange(); } diff --git a/lib/ui/components/super_imposer.dart b/lib/ui/components/super_imposer.dart index 5c284b4f..059f35e8 100644 --- a/lib/ui/components/super_imposer.dart +++ b/lib/ui/components/super_imposer.dart @@ -47,7 +47,6 @@ class _SuperImposerState extends State { @override void initState() { super.initState(); - subscription = SuperImposer.onChange.listen((final _) { if (!mounted) return; setState(() {}); diff --git a/lib/ui/components/toast.dart b/lib/ui/components/toast.dart index d253f624..1a09962b 100644 --- a/lib/ui/components/toast.dart +++ b/lib/ui/components/toast.dart @@ -45,15 +45,12 @@ class _ToastState extends State { @override void initState() { super.initState(); - Future.microtask(() async { setState(() { visible = true; }); - await Future.delayed(widget.duration); if (!mounted) return; - setState(() { visible = false; }); diff --git a/lib/ui/pages/_home/components/appbar.dart b/lib/ui/pages/_home/components/appbar.dart index 82d15509..4e91c3ca 100644 --- a/lib/ui/pages/_home/components/appbar.dart +++ b/lib/ui/pages/_home/components/appbar.dart @@ -22,7 +22,6 @@ class _UnderScoreHomePageAppBarState extends State { @override void initState() { super.initState(); - appEventSubscription = AppEvents.stream.listen((final AppEvent event) { if (event != AppEvent.anilistStateChange) return; setState(() {}); diff --git a/lib/ui/pages/home/view.dart b/lib/ui/pages/home/view.dart index 9c4d3864..56790bb8 100644 --- a/lib/ui/pages/home/view.dart +++ b/lib/ui/pages/home/view.dart @@ -16,7 +16,6 @@ class _HomePageState extends State { @override void initState() { super.initState(); - AppLoader.initialize().then((final _) async { if (mounted) { setState(() {}); diff --git a/lib/ui/pages/search/components/search_bar.dart b/lib/ui/pages/search/components/search_bar.dart index 3f155e32..16353956 100644 --- a/lib/ui/pages/search/components/search_bar.dart +++ b/lib/ui/pages/search/components/search_bar.dart @@ -26,7 +26,6 @@ class _SearchBarState extends State { @override void initState() { super.initState(); - textEditingController = TextEditingController(); } diff --git a/lib/ui/pages/settings/components/appearance.dart b/lib/ui/pages/settings/components/appearance.dart index 09ab6b99..c0cf0718 100644 --- a/lib/ui/pages/settings/components/appearance.dart +++ b/lib/ui/pages/settings/components/appearance.dart @@ -28,8 +28,10 @@ class _ApperanceSettingsState extends State { value: SettingsDatabase.settings.primaryColor ?? ThemerThemeData.defaultForegroundName, items: ForegroundColors.names().asMap().map( - (final _, final String name) => - MapEntry(name, Text(name)), + (final _, final String name) => MapEntry( + name, + Text(ForegroundColors.getTitleCase(context.t, name)), + ), ), onChanged: (final String value) { SettingsDatabase.settings.primaryColor = value; diff --git a/lib/ui/pages/settings/components/tiles/choice.dart b/lib/ui/pages/settings/components/tiles/choice.dart index 6d11dd91..94a30c62 100644 --- a/lib/ui/pages/settings/components/tiles/choice.dart +++ b/lib/ui/pages/settings/components/tiles/choice.dart @@ -1,7 +1,7 @@ import 'package:kazahana/core/exports.dart'; import '../../../../exports.dart'; -class MultiChoiceListTile extends StatelessWidget { +class MultiChoiceListTile extends StatefulWidget { const MultiChoiceListTile({ required this.title, required this.value, @@ -17,15 +17,25 @@ class MultiChoiceListTile extends StatelessWidget { final Map items; final void Function(T) onChanged; + @override + State> createState() => _MultiChoiceListTileState(); +} + +class _MultiChoiceListTileState extends State> { + final GlobalKey _initActiveOptionKey = GlobalKey(); + @override Widget build(final BuildContext context) => ListTile( leading: SizedBox( height: double.infinity, - child: secondary, + child: widget.secondary, ), - title: title, - subtitle: items[value], + title: widget.title, + subtitle: widget.items[widget.value], onTap: () async { + WidgetsBinding.instance.addPostFrameCallback((final _) { + Scrollable.ensureVisible(_initActiveOptionKey.currentContext!); + }); final T? value = await showModalBottomSheet( context: context, shape: RoundedRectangleBorder( @@ -46,18 +56,21 @@ class MultiChoiceListTile extends StatelessWidget { ), child: DefaultTextStyle( style: Theme.of(context).textTheme.titleLarge!, - child: title, + child: widget.title, ), ), const Divider(), - ...items + ...widget.items .map( (final T key, final Widget value) => MapEntry( key, RadioListTile( + key: key == widget.value + ? _initActiveOptionKey + : null, value: key, - groupValue: this.value, + groupValue: widget.value, title: value, onChanged: (final T? value) { if (value == null) return; @@ -71,8 +84,8 @@ class MultiChoiceListTile extends StatelessWidget { ), ), ); - if (value != null && value != this.value) { - onChanged(value); + if (value != null && value != widget.value) { + widget.onChanged(value); } }, ); diff --git a/lib/ui/pages/settings/view.dart b/lib/ui/pages/settings/view.dart index 37468ae3..d3b1ea35 100644 --- a/lib/ui/pages/settings/view.dart +++ b/lib/ui/pages/settings/view.dart @@ -16,10 +16,10 @@ enum _SettingsCategory { } extension on _SettingsCategory { - String getTitleCase(final Translation translations) { + String getTitleCase(final Translation translation) { switch (this) { case _SettingsCategory.appearance: - return translations.appearance; + return translation.appearance; } } } diff --git a/lib/ui/pages/view/components/body.dart b/lib/ui/pages/view/components/body.dart index 12c60a4d..50a0b6ca 100644 --- a/lib/ui/pages/view/components/body.dart +++ b/lib/ui/pages/view/components/body.dart @@ -52,7 +52,6 @@ class _ViewPageBodyState extends State @override void initState() { super.initState(); - tabController = TabController(length: tabs.length, vsync: this); scrollController = ScrollController() ..addListener(() { diff --git a/packages/anilist/lib/endpoints/graphql.dart b/packages/anilist/lib/endpoints/graphql.dart index 9baa2d78..f8ae6ff6 100644 --- a/packages/anilist/lib/endpoints/graphql.dart +++ b/packages/anilist/lib/endpoints/graphql.dart @@ -1,6 +1,6 @@ import 'dart:convert'; import 'package:shared/http.dart' as http; -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; import '../models/exports.dart'; class AnilistGraphQLRequest { diff --git a/packages/anilist/lib/endpoints/media.dart b/packages/anilist/lib/endpoints/media.dart index fc1310fc..a83af094 100644 --- a/packages/anilist/lib/endpoints/media.dart +++ b/packages/anilist/lib/endpoints/media.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; import '../models/exports.dart'; import 'graphql.dart'; diff --git a/packages/anilist/lib/endpoints/media_list.dart b/packages/anilist/lib/endpoints/media_list.dart index 8c141faa..67b64293 100644 --- a/packages/anilist/lib/endpoints/media_list.dart +++ b/packages/anilist/lib/endpoints/media_list.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; import '../models/exports.dart'; import 'graphql.dart'; diff --git a/packages/anilist/lib/endpoints/relation.dart b/packages/anilist/lib/endpoints/relation.dart index 75ed6e25..2e0a59c8 100644 --- a/packages/anilist/lib/endpoints/relation.dart +++ b/packages/anilist/lib/endpoints/relation.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; import '../models/exports.dart'; import 'graphql.dart'; diff --git a/packages/anilist/lib/endpoints/user.dart b/packages/anilist/lib/endpoints/user.dart index e4f616c1..5a2d2a86 100644 --- a/packages/anilist/lib/endpoints/user.dart +++ b/packages/anilist/lib/endpoints/user.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; import '../models/exports.dart'; import 'graphql.dart'; diff --git a/packages/anilist/lib/models/character.dart b/packages/anilist/lib/models/character.dart index 76fb472f..ef5d0a93 100644 --- a/packages/anilist/lib/models/character.dart +++ b/packages/anilist/lib/models/character.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; import '../utils.dart'; import 'fuzzy_date.dart'; diff --git a/packages/anilist/lib/models/character_edge.dart b/packages/anilist/lib/models/character_edge.dart index f42cead1..63ce32d5 100644 --- a/packages/anilist/lib/models/character_edge.dart +++ b/packages/anilist/lib/models/character_edge.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; import 'character.dart'; import 'character_role.dart'; diff --git a/packages/anilist/lib/models/character_role.dart b/packages/anilist/lib/models/character_role.dart index ac677f80..f865bdf7 100644 --- a/packages/anilist/lib/models/character_role.dart +++ b/packages/anilist/lib/models/character_role.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; enum AnilistCharacterRole { main, diff --git a/packages/anilist/lib/models/fuzzy_date.dart b/packages/anilist/lib/models/fuzzy_date.dart index cdc7e6ca..666f3cc3 100644 --- a/packages/anilist/lib/models/fuzzy_date.dart +++ b/packages/anilist/lib/models/fuzzy_date.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; class AnilistFuzzyDate { const AnilistFuzzyDate(this.json); diff --git a/packages/anilist/lib/models/media.dart b/packages/anilist/lib/models/media.dart index deeb432b..828ac6a5 100644 --- a/packages/anilist/lib/models/media.dart +++ b/packages/anilist/lib/models/media.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; import '../endpoints/exports.dart'; import '../utils.dart'; import 'character_edge.dart'; diff --git a/packages/anilist/lib/models/media_list_entry.dart b/packages/anilist/lib/models/media_list_entry.dart index 59c4580f..e069673e 100644 --- a/packages/anilist/lib/models/media_list_entry.dart +++ b/packages/anilist/lib/models/media_list_entry.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; import 'fuzzy_date.dart'; import 'media_list_status.dart'; diff --git a/packages/anilist/lib/models/media_list_sort.dart b/packages/anilist/lib/models/media_list_sort.dart index 34e00dea..eabf0c7f 100644 --- a/packages/anilist/lib/models/media_list_sort.dart +++ b/packages/anilist/lib/models/media_list_sort.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; enum AnilistMediaListSort { mediaId, diff --git a/packages/anilist/lib/models/media_list_status.dart b/packages/anilist/lib/models/media_list_status.dart index f64d1fce..48aea419 100644 --- a/packages/anilist/lib/models/media_list_status.dart +++ b/packages/anilist/lib/models/media_list_status.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; enum AnilistMediaListStatus { current, diff --git a/packages/anilist/lib/models/media_sort.dart b/packages/anilist/lib/models/media_sort.dart index 68648035..1128c90b 100644 --- a/packages/anilist/lib/models/media_sort.dart +++ b/packages/anilist/lib/models/media_sort.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; enum AnilistMediaSort { id, diff --git a/packages/anilist/lib/models/media_status.dart b/packages/anilist/lib/models/media_status.dart index cf37c351..eefee1ce 100644 --- a/packages/anilist/lib/models/media_status.dart +++ b/packages/anilist/lib/models/media_status.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; enum AnilistMediaStatus { finished, diff --git a/packages/anilist/lib/models/media_type.dart b/packages/anilist/lib/models/media_type.dart index ce1f7423..52cbb6aa 100644 --- a/packages/anilist/lib/models/media_type.dart +++ b/packages/anilist/lib/models/media_type.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; enum AnilistMediaType { anime, diff --git a/packages/anilist/lib/models/relation_edge.dart b/packages/anilist/lib/models/relation_edge.dart index 20963721..c8a273fa 100644 --- a/packages/anilist/lib/models/relation_edge.dart +++ b/packages/anilist/lib/models/relation_edge.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; import 'media.dart'; import 'relation_type.dart'; diff --git a/packages/anilist/lib/models/relation_type.dart b/packages/anilist/lib/models/relation_type.dart index 0d4f13cc..8dc45ffd 100644 --- a/packages/anilist/lib/models/relation_type.dart +++ b/packages/anilist/lib/models/relation_type.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; enum AnilistRelationType { adaptation, diff --git a/packages/anilist/lib/models/seasons.dart b/packages/anilist/lib/models/seasons.dart index be3e529e..42cf63b8 100644 --- a/packages/anilist/lib/models/seasons.dart +++ b/packages/anilist/lib/models/seasons.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; enum AnimeSeasons { winter, diff --git a/packages/anilist/lib/models/user.dart b/packages/anilist/lib/models/user.dart index be3ed177..05bd6d85 100644 --- a/packages/anilist/lib/models/user.dart +++ b/packages/anilist/lib/models/user.dart @@ -1,4 +1,4 @@ -import 'package:utilx/utils.dart'; +import 'package:utilx/utilx.dart'; class AnilistUserStatistics { const AnilistUserStatistics(this.json); diff --git a/packages/anilist/pubspec.lock b/packages/anilist/pubspec.lock index edd025bf..a44d709d 100644 --- a/packages/anilist/pubspec.lock +++ b/packages/anilist/pubspec.lock @@ -22,7 +22,7 @@ packages: description: path: "." ref: dart_devx - resolved-ref: b337c5c4f10c4a23a626a1e8de5cf93f7fd57231 + resolved-ref: "4cd1360f1d226e1793ef62b347a7078f0b446182" url: "https://github.com/yukino-org/packages.git" source: git version: "0.0.0" @@ -54,10 +54,10 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.11.0" path: dependency: transitive description: @@ -110,7 +110,7 @@ packages: description: path: "." ref: dart_utilx - resolved-ref: "7b2ddc4c01806acf239b47eba3bda5e59f983f5c" + resolved-ref: d3adba9598e4dfcc0e470ce7f5ce1d3fc3f088a1 url: "https://github.com/yukino-org/packages.git" source: git version: "0.0.0" diff --git a/packages/shared/pubspec.lock b/packages/shared/pubspec.lock index 2b9cdf34..67f0a0f2 100644 --- a/packages/shared/pubspec.lock +++ b/packages/shared/pubspec.lock @@ -22,7 +22,7 @@ packages: description: path: "." ref: dart_devx - resolved-ref: b337c5c4f10c4a23a626a1e8de5cf93f7fd57231 + resolved-ref: "4cd1360f1d226e1793ef62b347a7078f0b446182" url: "https://github.com/yukino-org/packages.git" source: git version: "0.0.0" @@ -54,10 +54,10 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.11.0" path: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index bc358352..f896865b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: encrypt: ^5.0.1 flutter: sdk: flutter - json_annotation: ^4.6.0 + json_annotation: ^4.8.1 media_kit: ^1.1.10 media_kit_libs_video: ^1.0.4 media_kit_video: ^1.2.4