From f921ee55d12a8499f37653d2e7e55c54a7109709 Mon Sep 17 00:00:00 2001 From: H2Sxxa Date: Thu, 1 Aug 2024 20:53:46 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F=20make=20the=20card=20siz?= =?UTF-8?q?e=20fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/i18n/i18n.dart | 9 ++++----- lib/main.dart | 2 +- lib/views/pages/manage.dart | 11 +++-------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/i18n/i18n.dart b/lib/i18n/i18n.dart index 4fc54ea..affa608 100644 --- a/lib/i18n/i18n.dart +++ b/lib/i18n/i18n.dart @@ -8,19 +8,18 @@ import 'package:url_launcher/url_launcher_string.dart'; import 'package:wslconfigurer/i18n/constants.dart'; import 'package:yaml/yaml.dart'; -class I18n { +@immutable +final class I18n { late final Map _fields; late final Map avaiableLanguages; - String locale = "en_US"; + late final String locale; late final LazyDynamicCan> themeModeTranslator; Map _load(String data) => Map.from(loadYaml(data)); FutureOr init([String? locale]) async { avaiableLanguages = _load(await rootBundle.loadString(i18nLanguages)); - if (locale != null) { - this.locale = locale; - } + this.locale = locale ?? "en_US"; _fields = _load(await rootBundle.loadString(fileName("fields.yaml"))); _initLazyCans(); diff --git a/lib/main.dart b/lib/main.dart index 9c1e5d6..9d722a2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -70,7 +70,7 @@ class MyAppState extends State with RefreshMountedStateMixin { @override Widget build(BuildContext context) { var configs = ArcheBus.bus.of(); - var locale = configs.locale.getOr("en_US").split("_"); + var locale = context.i18n.locale.split("_"); return DynamicColorBuilder( builder: (lightDynamic, darkDynamic) => MaterialApp( theme: ThemeData( diff --git a/lib/views/pages/manage.dart b/lib/views/pages/manage.dart index ea5fe6d..912d9aa 100644 --- a/lib/views/pages/manage.dart +++ b/lib/views/pages/manage.dart @@ -37,20 +37,15 @@ class _DistributionManagePageState extends State { child: CircularProgressIndicator(), ); } - return SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(8), child: AnimationLimiter( - child: GridView.count( - shrinkWrap: true, - crossAxisCount: 5, + child: Wrap( children: data.enumerate( (index, distro) { - return AnimationConfiguration.staggeredGrid( + return AnimationConfiguration.staggeredList( position: index, - duration: const Duration(milliseconds: 375), - columnCount: (data.length ~/ 5) + 1, child: ScaleAnimation( child: FadeInAnimation( child: Card.filled( @@ -60,7 +55,7 @@ class _DistributionManagePageState extends State { current = distro; }), child: SizedBox.square( - dimension: 80, + dimension: 120, child: Center( child: Text(distro), ),