🐛 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",
"postCategoryKnowledge": "Knowledge",
"postCategoryLiterature": "Literature",
"postCategoryFunny": "Funny",
"postCategoryUncategorized": "Uncategorized"
}

View File

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

View File

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

View File

@ -486,5 +486,6 @@
"postCategoryNews": "新聞",
"postCategoryKnowledge": "知識",
"postCategoryLiterature": "文學",
"postCategoryFunny": "搞笑",
"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
final sn = context.read<SnNetworkProvider>();
await sn.initializeUserAgent();
await sn.setConfigWithNative();
if (!mounted) return;
final ua = context.read<UserProvider>();
await ua.initialize();

View File

@ -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<Dio> createOffContextClient() async {
@ -109,6 +108,10 @@ class SnNetworkProvider {
return client;
}
Future<void> setConfigWithNative() async {
_home.saveWidgetData("nex_server_url", client.options.baseUrl);
}
static Future<String> _getUserAgent() async {
final String platformInfo;
if (kIsWeb) {

View File

@ -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());
}
});
}

View File

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

View File

@ -22,8 +22,9 @@ const Map<String, IconData> 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,12 +185,12 @@ class _ExploreScreenState extends State<ExploreScreen> {
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];
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(
@ -203,7 +204,8 @@ class _ExploreScreenState extends State<ExploreScreen> {
_refreshPosts();
},
)).padding(horizontal: 4);
},
}).toList(),
),
),
),
),

View File

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

View File

@ -282,20 +282,6 @@ class _PostCategoriesFieldState extends State<PostCategoriesField> {
: 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();
},