🐛 Fix splash screen

This commit is contained in:
LittleSheep 2024-12-15 22:54:00 +08:00
parent 7508a54907
commit 7e0faba5db
3 changed files with 16 additions and 4 deletions

View File

@ -37,7 +37,6 @@ import 'package:flutter_web_plugins/url_strategy.dart' show usePathUrlStrategy;
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/version_label.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalization.ensureInitialized();
@ -94,7 +93,7 @@ class SolianApp extends StatelessWidget {
Provider(create: (ctx) => HomeWidgetProvider(ctx)),
// Data layer
Provider(create: (_) => SnNetworkProvider()),
Provider(create: (ctx) => SnNetworkProvider(ctx)),
Provider(create: (ctx) => UserDirectoryProvider(ctx)),
Provider(create: (ctx) => SnAttachmentProvider(ctx)),
Provider(create: (ctx) => SnPostContentProvider(ctx)),
@ -206,6 +205,9 @@ class _AppSplashScreenState extends State<_AppSplashScreen> {
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
if (MediaQuery.of(context).platformBrightness == Brightness.dark)
Image.asset("assets/icon/icon-dark.png", width: 64, height: 64)
else
Image.asset("assets/icon/icon.png", width: 64, height: 64),
const Gap(6),
LinearProgressIndicator(

View File

@ -6,9 +6,12 @@ import 'dart:io';
import 'package:dio/dio.dart';
import 'package:dio_smart_retry/dio_smart_retry.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:surface/providers/widget.dart';
import 'package:synchronized/synchronized.dart';
const kAtkStoreKey = 'nex_user_atk';
@ -26,10 +29,13 @@ class SnNetworkProvider {
late final Dio client;
late final SharedPreferences _prefs;
late final HomeWidgetProvider _home;
String? _userAgent;
SnNetworkProvider() {
SnNetworkProvider(BuildContext context) {
_home = context.read<HomeWidgetProvider>();
client = Dio();
client.interceptors.add(RetryInterceptor(
@ -63,6 +69,8 @@ class SnNetworkProvider {
SharedPreferences.getInstance().then((prefs) {
_prefs = prefs;
client.options.baseUrl = _prefs.getString(kNetworkServerStoreKey) ?? kNetworkServerDefault;
if (!context.mounted) return;
_home.saveWidgetData("server_url", client.options.baseUrl);
});
}
@ -190,5 +198,6 @@ class SnNetworkProvider {
void setBaseUrl(String url) {
client.options.baseUrl = url;
_home.saveWidgetData("server_url", client.options.baseUrl);
}
}

View File

@ -138,6 +138,7 @@ flutter:
# To add assets to your application, add an assets section, like this:
assets:
- assets/icon/icon.png
- assets/icon/icon-dark.png
- assets/icon/icon-light-radius.png
- assets/translations/