|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:isekai_wiki/global.dart';
|
|
|
|
import 'package:isekai_wiki/models/settings.dart';
|
|
|
|
import 'package:isekai_wiki/models/site_config.dart';
|
|
|
|
import 'package:isekai_wiki/models/user.dart';
|
|
|
|
import 'package:isekai_wiki/pages/welcome_page.dart';
|
|
|
|
import 'models/model.dart';
|
|
|
|
import 'pages/tab_page.dart';
|
|
|
|
import 'styles.dart';
|
|
|
|
|
|
|
|
class IsekaiWikiApp extends StatelessWidget {
|
|
|
|
const IsekaiWikiApp({super.key});
|
|
|
|
|
|
|
|
Widget _buildApp(BuildContext context) {
|
|
|
|
if (Global.isAppActive) {
|
|
|
|
return const IsekaiWikiTabsPage();
|
|
|
|
} else {
|
|
|
|
return const WelcomePage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This widget is the root of your application.
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Get.put(UserController());
|
|
|
|
Get.put(AppSettingsController());
|
|
|
|
|
|
|
|
return Material(
|
|
|
|
child: GetCupertinoApp(
|
|
|
|
title: '异世界百科',
|
|
|
|
theme: Styles.cupertinoLightTheme,
|
|
|
|
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
GlobalCupertinoLocalizations.delegate,
|
|
|
|
],
|
|
|
|
supportedLocales: const [
|
|
|
|
Locale('zh', 'CN'),
|
|
|
|
Locale('en'),
|
|
|
|
],
|
|
|
|
initialBinding: InitialBinding(),
|
|
|
|
home: _buildApp(context),
|
|
|
|
builder: (context, child) {
|
|
|
|
if (child == null) {
|
|
|
|
return Container();
|
|
|
|
} else {
|
|
|
|
Styles.textScaleFactor = MediaQuery.of(context).textScaleFactor;
|
|
|
|
Styles.isXs = MediaQuery.of(context).size.width <= 340;
|
|
|
|
return CupertinoTheme(
|
|
|
|
data: MediaQuery.of(context).platformBrightness != Brightness.dark
|
|
|
|
? Styles.cupertinoLightTheme
|
|
|
|
: Styles.cupertinoDarkTheme,
|
|
|
|
child: Theme(
|
|
|
|
data: MediaQuery.of(context).platformBrightness != Brightness.dark
|
|
|
|
? Styles.materialLightTheme
|
|
|
|
: Styles.materialDarkTheme,
|
|
|
|
child: child),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|