diff --git a/assets/translations/en-US.json b/assets/translations/en-US.json index 631151e..1747d60 100644 --- a/assets/translations/en-US.json +++ b/assets/translations/en-US.json @@ -488,5 +488,6 @@ "postCategoryNews": "News", "postCategoryKnowledge": "Knowledge", "postCategoryLiterature": "Literature", + "postCategoryFunny": "Funny", "postCategoryUncategorized": "Uncategorized" } diff --git a/assets/translations/zh-CN.json b/assets/translations/zh-CN.json index c693658..6a427b6 100644 --- a/assets/translations/zh-CN.json +++ b/assets/translations/zh-CN.json @@ -486,5 +486,6 @@ "postCategoryNews": "新闻", "postCategoryKnowledge": "知识", "postCategoryLiterature": "文学", + "postCategoryFunny": "搞笑", "postCategoryUncategorized": "未分类" } diff --git a/assets/translations/zh-HK.json b/assets/translations/zh-HK.json index e1c2bc0..9212e06 100644 --- a/assets/translations/zh-HK.json +++ b/assets/translations/zh-HK.json @@ -486,5 +486,6 @@ "postCategoryNews": "新聞", "postCategoryKnowledge": "知識", "postCategoryLiterature": "文學", + "postCategoryFunny": "搞笑", "postCategoryUncategorized": "未分類" } diff --git a/assets/translations/zh-TW.json b/assets/translations/zh-TW.json index d28e6b2..ed4c50d 100644 --- a/assets/translations/zh-TW.json +++ b/assets/translations/zh-TW.json @@ -486,5 +486,6 @@ "postCategoryNews": "新聞", "postCategoryKnowledge": "知識", "postCategoryLiterature": "文學", + "postCategoryFunny": "搞笑", "postCategoryUncategorized": "未分類" } diff --git a/lib/main.dart b/lib/main.dart index a0d12f3..9a47f28 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -265,6 +265,7 @@ class _AppSplashScreenState extends State<_AppSplashScreen> { // The Network initialization will also save initialize the Config, so it not need to be initialized again final sn = context.read(); await sn.initializeUserAgent(); + await sn.setConfigWithNative(); if (!mounted) return; final ua = context.read(); await ua.initialize(); diff --git a/lib/providers/sn_network.dart b/lib/providers/sn_network.dart index 76eaadd..bba2a9b 100644 --- a/lib/providers/sn_network.dart +++ b/lib/providers/sn_network.dart @@ -68,9 +68,8 @@ class SnNetworkProvider { _config.initialize().then((_) { _prefs = _config.prefs; client.options.baseUrl = _config.serverUrl; - if (!context.mounted) return; - _home.saveWidgetData("nex_server_url", client.options.baseUrl); }); + } static Future createOffContextClient() async { @@ -109,6 +108,10 @@ class SnNetworkProvider { return client; } + Future setConfigWithNative() async { + _home.saveWidgetData("nex_server_url", client.options.baseUrl); + } + static Future _getUserAgent() async { final String platformInfo; if (kIsWeb) { diff --git a/lib/providers/userinfo.dart b/lib/providers/userinfo.dart index 105d418..d8010b8 100644 --- a/lib/providers/userinfo.dart +++ b/lib/providers/userinfo.dart @@ -34,7 +34,6 @@ class UserProvider extends ChangeNotifier { refreshUser().then((value) { if (value != null) { log('Logged in as @${value.name}'); - _home.saveWidgetData('user', value.toJson()); } }); } diff --git a/lib/providers/widget.dart b/lib/providers/widget.dart index 1af4452..2b3fe71 100644 --- a/lib/providers/widget.dart +++ b/lib/providers/widget.dart @@ -13,7 +13,7 @@ class HomeWidgetProvider { Future initialize() async { if (kIsWeb || !(Platform.isAndroid || Platform.isIOS)) return; - if (!kIsWeb && Platform.isIOS) { + if (Platform.isIOS) { await HomeWidget.setAppGroupId("group.solsynth.solian"); } } diff --git a/lib/screens/explore.dart b/lib/screens/explore.dart index 0687547..d2adeda 100644 --- a/lib/screens/explore.dart +++ b/lib/screens/explore.dart @@ -22,8 +22,9 @@ const Map kCategoryIcons = { 'sports': Symbols.sports_soccer, 'music': Symbols.music_note, 'news': Symbols.newspaper, - 'knowledge': Symbols.book, + 'knowledge': Symbols.library_books, 'literature': Symbols.book, + 'funny': Symbols.attractions, }; class ExploreScreen extends StatefulWidget { @@ -184,26 +185,27 @@ class _ExploreScreenState extends State { preferredSize: const Size.fromHeight(50), child: SizedBox( height: 50, - child: ListView.builder( - padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12), + child: SingleChildScrollView( scrollDirection: Axis.horizontal, - itemCount: _categories.length, - itemBuilder: (context, idx) { - final ele = _categories[idx]; - return StyledWidget(ChoiceChip( - avatar: Icon(kCategoryIcons[ele.alias] ?? Symbols.question_mark), - label: Text( - 'postCategory${ele.alias.capitalize()}'.trExists() - ? 'postCategory${ele.alias.capitalize()}'.tr() - : ele.name, - ), - selected: _selectedCategory == ele.alias, - onSelected: (value) { - _selectedCategory = value ? ele.alias : null; - _refreshPosts(); - }, - )).padding(horizontal: 4); - }, + padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: _categories.map((ele) { + return StyledWidget(ChoiceChip( + avatar: Icon(kCategoryIcons[ele.alias] ?? Symbols.question_mark), + label: Text( + 'postCategory${ele.alias.capitalize()}'.trExists() + ? 'postCategory${ele.alias.capitalize()}'.tr() + : ele.name, + ), + selected: _selectedCategory == ele.alias, + onSelected: (value) { + _selectedCategory = value ? ele.alias : null; + _refreshPosts(); + }, + )).padding(horizontal: 4); + }).toList(), + ), ), ), ), diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 0bdfab6..1d50c77 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -493,9 +493,7 @@ class _HomeDashRecommendationPostWidgetState extends State<_HomeDashRecommendati setState(() => _isBusy = true); try { final pt = context.read(); - final home = context.read(); _posts = await pt.listRecommendations(); - home.saveWidgetData('post_featured', _posts!.first.toJson()); } catch (err) { if (!mounted) return; context.showErrorDialog(err); diff --git a/lib/widgets/post/post_tags_field.dart b/lib/widgets/post/post_tags_field.dart index 0b8b57c..307d38c 100644 --- a/lib/widgets/post/post_tags_field.dart +++ b/lib/widgets/post/post_tags_field.dart @@ -282,20 +282,6 @@ class _PostCategoriesFieldState extends State { : null, ), onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), - onChanged: (value) { - for (final divider in kTagsDividers) { - if (value.endsWith(divider)) { - final tagValue = value.substring(0, value.length - 1); - if (tagValue.isEmpty) return; - if (!_currentCategories.contains(tagValue)) { - setState(() => _currentCategories.add(tagValue)); - } - controller.clear(); - widget.onUpdate(_currentCategories); - break; - } - } - }, onSubmitted: (_) { onSubmitted(); },