🐛 Bug fixes on something

This commit is contained in:
LittleSheep 2024-12-23 21:55:07 +08:00
parent 3eda464e03
commit 36a5b8fb39
11 changed files with 33 additions and 40 deletions

View File

@ -488,5 +488,6 @@
"postCategoryNews": "News", "postCategoryNews": "News",
"postCategoryKnowledge": "Knowledge", "postCategoryKnowledge": "Knowledge",
"postCategoryLiterature": "Literature", "postCategoryLiterature": "Literature",
"postCategoryFunny": "Funny",
"postCategoryUncategorized": "Uncategorized" "postCategoryUncategorized": "Uncategorized"
} }

View File

@ -486,5 +486,6 @@
"postCategoryNews": "新闻", "postCategoryNews": "新闻",
"postCategoryKnowledge": "知识", "postCategoryKnowledge": "知识",
"postCategoryLiterature": "文学", "postCategoryLiterature": "文学",
"postCategoryFunny": "搞笑",
"postCategoryUncategorized": "未分类" "postCategoryUncategorized": "未分类"
} }

View File

@ -486,5 +486,6 @@
"postCategoryNews": "新聞", "postCategoryNews": "新聞",
"postCategoryKnowledge": "知識", "postCategoryKnowledge": "知識",
"postCategoryLiterature": "文學", "postCategoryLiterature": "文學",
"postCategoryFunny": "搞笑",
"postCategoryUncategorized": "未分類" "postCategoryUncategorized": "未分類"
} }

View File

@ -486,5 +486,6 @@
"postCategoryNews": "新聞", "postCategoryNews": "新聞",
"postCategoryKnowledge": "知識", "postCategoryKnowledge": "知識",
"postCategoryLiterature": "文學", "postCategoryLiterature": "文學",
"postCategoryFunny": "搞笑",
"postCategoryUncategorized": "未分類" "postCategoryUncategorized": "未分類"
} }

View File

@ -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 // The Network initialization will also save initialize the Config, so it not need to be initialized again
final sn = context.read<SnNetworkProvider>(); final sn = context.read<SnNetworkProvider>();
await sn.initializeUserAgent(); await sn.initializeUserAgent();
await sn.setConfigWithNative();
if (!mounted) return; if (!mounted) return;
final ua = context.read<UserProvider>(); final ua = context.read<UserProvider>();
await ua.initialize(); await ua.initialize();

View File

@ -68,9 +68,8 @@ class SnNetworkProvider {
_config.initialize().then((_) { _config.initialize().then((_) {
_prefs = _config.prefs; _prefs = _config.prefs;
client.options.baseUrl = _config.serverUrl; client.options.baseUrl = _config.serverUrl;
if (!context.mounted) return;
_home.saveWidgetData("nex_server_url", client.options.baseUrl);
}); });
} }
static Future<Dio> createOffContextClient() async { static Future<Dio> createOffContextClient() async {
@ -109,6 +108,10 @@ class SnNetworkProvider {
return client; return client;
} }
Future<void> setConfigWithNative() async {
_home.saveWidgetData("nex_server_url", client.options.baseUrl);
}
static Future<String> _getUserAgent() async { static Future<String> _getUserAgent() async {
final String platformInfo; final String platformInfo;
if (kIsWeb) { if (kIsWeb) {

View File

@ -34,7 +34,6 @@ class UserProvider extends ChangeNotifier {
refreshUser().then((value) { refreshUser().then((value) {
if (value != null) { if (value != null) {
log('Logged in as @${value.name}'); log('Logged in as @${value.name}');
_home.saveWidgetData('user', value.toJson());
} }
}); });
} }

View File

@ -13,7 +13,7 @@ class HomeWidgetProvider {
Future<void> initialize() async { Future<void> initialize() async {
if (kIsWeb || !(Platform.isAndroid || Platform.isIOS)) return; if (kIsWeb || !(Platform.isAndroid || Platform.isIOS)) return;
if (!kIsWeb && Platform.isIOS) { if (Platform.isIOS) {
await HomeWidget.setAppGroupId("group.solsynth.solian"); await HomeWidget.setAppGroupId("group.solsynth.solian");
} }
} }

View File

@ -22,8 +22,9 @@ const Map<String, IconData> kCategoryIcons = {
'sports': Symbols.sports_soccer, 'sports': Symbols.sports_soccer,
'music': Symbols.music_note, 'music': Symbols.music_note,
'news': Symbols.newspaper, 'news': Symbols.newspaper,
'knowledge': Symbols.book, 'knowledge': Symbols.library_books,
'literature': Symbols.book, 'literature': Symbols.book,
'funny': Symbols.attractions,
}; };
class ExploreScreen extends StatefulWidget { class ExploreScreen extends StatefulWidget {
@ -184,26 +185,27 @@ class _ExploreScreenState extends State<ExploreScreen> {
preferredSize: const Size.fromHeight(50), preferredSize: const Size.fromHeight(50),
child: SizedBox( child: SizedBox(
height: 50, height: 50,
child: ListView.builder( child: SingleChildScrollView(
padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12),
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: _categories.length, padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12),
itemBuilder: (context, idx) { child: Row(
final ele = _categories[idx]; mainAxisAlignment: MainAxisAlignment.center,
return StyledWidget(ChoiceChip( children: _categories.map((ele) {
avatar: Icon(kCategoryIcons[ele.alias] ?? Symbols.question_mark), return StyledWidget(ChoiceChip(
label: Text( avatar: Icon(kCategoryIcons[ele.alias] ?? Symbols.question_mark),
'postCategory${ele.alias.capitalize()}'.trExists() label: Text(
? 'postCategory${ele.alias.capitalize()}'.tr() 'postCategory${ele.alias.capitalize()}'.trExists()
: ele.name, ? 'postCategory${ele.alias.capitalize()}'.tr()
), : ele.name,
selected: _selectedCategory == ele.alias, ),
onSelected: (value) { selected: _selectedCategory == ele.alias,
_selectedCategory = value ? ele.alias : null; onSelected: (value) {
_refreshPosts(); _selectedCategory = value ? ele.alias : null;
}, _refreshPosts();
)).padding(horizontal: 4); },
}, )).padding(horizontal: 4);
}).toList(),
),
), ),
), ),
), ),

View File

@ -493,9 +493,7 @@ class _HomeDashRecommendationPostWidgetState extends State<_HomeDashRecommendati
setState(() => _isBusy = true); setState(() => _isBusy = true);
try { try {
final pt = context.read<SnPostContentProvider>(); final pt = context.read<SnPostContentProvider>();
final home = context.read<HomeWidgetProvider>();
_posts = await pt.listRecommendations(); _posts = await pt.listRecommendations();
home.saveWidgetData('post_featured', _posts!.first.toJson());
} catch (err) { } catch (err) {
if (!mounted) return; if (!mounted) return;
context.showErrorDialog(err); context.showErrorDialog(err);

View File

@ -282,20 +282,6 @@ class _PostCategoriesFieldState extends State<PostCategoriesField> {
: null, : null,
), ),
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), 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: (_) {
onSubmitted(); onSubmitted();
}, },