pikapika/lib/screens/InitScreen.dart

119 lines
4.2 KiB
Dart
Raw Normal View History

2021-09-29 23:57:09 +00:00
import 'package:flutter/material.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/config/Address.dart';
import 'package:pikapika/basic/config/AndroidDisplayMode.dart';
import 'package:pikapika/basic/config/AndroidSecureFlag.dart';
import 'package:pikapika/basic/config/AutoClean.dart';
import 'package:pikapika/basic/config/AutoFullScreen.dart';
import 'package:pikapika/basic/config/ChooserRoot.dart';
import 'package:pikapika/basic/config/ContentFailedReloadAction.dart';
import 'package:pikapika/basic/config/ConvertToPNG.dart';
import 'package:pikapika/basic/config/DownloadAndExportPath.dart';
import 'package:pikapika/basic/config/DownloadThreadCount.dart';
import 'package:pikapika/basic/config/FullScreenAction.dart';
import 'package:pikapika/basic/config/FullScreenUI.dart';
2021-11-30 02:23:49 +00:00
import 'package:pikapika/basic/config/ImageAddress.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/config/KeyboardController.dart';
2021-11-21 13:18:23 +00:00
import 'package:pikapika/basic/config/NoAnimation.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/config/PagerAction.dart';
import 'package:pikapika/basic/config/Platform.dart';
import 'package:pikapika/basic/config/Proxy.dart';
import 'package:pikapika/basic/config/Quality.dart';
import 'package:pikapika/basic/config/ReaderDirection.dart';
2021-12-09 00:08:01 +00:00
import 'package:pikapika/basic/config/ReaderSliderPosition.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/config/ReaderType.dart';
import 'package:pikapika/basic/config/ShadowCategories.dart';
import 'package:pikapika/basic/config/Themes.dart';
import 'package:pikapika/basic/Method.dart';
import 'package:pikapika/basic/config/ListLayout.dart';
import 'package:pikapika/basic/config/TimeOffsetHour.dart';
2022-03-27 06:19:08 +00:00
import 'package:pikapika/basic/config/UsingRightClickPop.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/config/Version.dart';
import 'package:pikapika/basic/config/VolumeController.dart';
2021-11-24 13:22:22 +00:00
import 'package:pikapika/basic/config/shadowCategoriesMode.dart';
2021-09-29 23:57:09 +00:00
2022-02-25 10:46:11 +00:00
import '../basic/config/ExportRename.dart';
2021-09-29 23:57:09 +00:00
import 'AccountScreen.dart';
import 'AppScreen.dart';
// 初始化界面
class InitScreen extends StatefulWidget {
2022-03-17 03:31:25 +00:00
const InitScreen({Key? key}) : super(key: key);
2021-09-29 23:57:09 +00:00
@override
State<StatefulWidget> createState() => _InitScreenState();
}
class _InitScreenState extends State<InitScreen> {
@override
initState() {
_init();
super.initState();
}
Future<dynamic> _init() async {
// 初始化配置文件
2021-10-29 03:38:36 +00:00
await initPlatform(); // 必须第一个初始化, 加载设备信息
2021-11-04 05:56:25 +00:00
await initAutoClean();
2021-09-29 23:57:09 +00:00
await initAddress();
2021-11-30 02:23:49 +00:00
await initImageAddress();
2021-09-29 23:57:09 +00:00
await initProxy();
await initQuality();
2021-10-15 06:18:29 +00:00
await initFont();
2021-09-29 23:57:09 +00:00
await initTheme();
await initListLayout();
await initReaderType();
await initReaderDirection();
2021-12-09 00:08:01 +00:00
await initReaderSliderPosition();
2021-09-29 23:57:09 +00:00
await initAutoFullScreen();
await initFullScreenAction();
await initPagerAction();
2021-11-24 13:22:22 +00:00
await initShadowCategoriesMode();
2021-09-29 23:57:09 +00:00
await initShadowCategories();
await initFullScreenUI();
switchFullScreenUI();
await initContentFailedReloadAction();
await initVolumeController();
await initKeyboardController();
await initAndroidDisplayMode();
2021-10-07 03:47:28 +00:00
await initChooserRoot();
await initTimeZone();
2021-10-25 11:27:38 +00:00
await initDownloadAndExportPath();
2021-10-29 03:38:36 +00:00
await initAndroidSecureFlag();
2021-10-31 06:01:19 +00:00
await initDownloadThreadCount();
2021-11-06 11:25:44 +00:00
await initConvertToPNG();
2021-11-21 13:18:23 +00:00
await initNoAnimation();
2022-02-25 10:46:11 +00:00
await initExportRename();
2021-11-11 02:10:18 +00:00
await initVersion();
2022-03-27 06:19:08 +00:00
await initUsingRightClickPop();
2021-11-11 09:05:48 +00:00
autoCheckNewVersion();
2021-09-29 23:57:09 +00:00
// 登录, 如果token失效重新登录, 网络不好的时候可能需要1分钟
if (await method.preLogin()) {
// 如果token或username+password有效则直接进入登录好的界面
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const AppScreen()),
2021-09-29 23:57:09 +00:00
);
} else {
// 否则跳转到登录页
Navigator.pushReplacement(
context,
2022-03-19 04:12:27 +00:00
MaterialPageRoute(builder: (context) => const AccountScreen()),
2021-09-29 23:57:09 +00:00
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
2022-03-19 04:12:27 +00:00
backgroundColor: const Color(0xfffffced),
2021-09-29 23:57:09 +00:00
body: ConstrainedBox(
2022-03-19 04:12:27 +00:00
constraints: const BoxConstraints.expand(),
2022-03-17 03:31:25 +00:00
child: Image.asset(
2021-09-29 23:57:09 +00:00
"lib/assets/init.jpg",
fit: BoxFit.contain,
),
),
);
}
}