mobile_skt/lib/index.dart

73 lines
2.9 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2024-04-10 17:08:26 +08:00
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:sk_base_mobile/config.dart';
import 'package:sk_base_mobile/services/storage.service.dart';
import 'package:sk_base_mobile/app_theme.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
2024-03-25 14:16:00 +08:00
import 'package:sk_base_mobile/widgets/refresh_footer.dart';
import 'package:sk_base_mobile/widgets/refresh_header.dart';
import 'constants/constants.dart';
import 'services/app_info.service.dart';
// The index screen shows login if no user identity was found, otherwise the landing screen
class IndexPage extends StatelessWidget {
const IndexPage({super.key});
@override
Widget build(BuildContext context) {
2024-03-18 15:54:06 +08:00
final isLandscape =
MediaQuery.of(context).orientation == Orientation.landscape;
return ScreenUtilInit(
minTextAdapt: true,
2024-03-18 15:54:06 +08:00
designSize: isLandscape
? const Size(1490, 932)
: const Size(932, 1490), // 2800 * 1800p 309ppi
builder: (buildContext, child) => RefreshConfiguration(
headerBuilder: () => RefreshHeader(),
footerBuilder: () => const RefreshFooter(),
hideFooterWhenNotFull: true,
headerTriggerDistance: 30,
maxOverScrollExtent: 80,
footerTriggerDistance: 150,
child: GetMaterialApp(
2024-04-10 17:08:26 +08:00
locale: const Locale('zh', 'CN'), // 设置为中文
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate, // 添加这一行
],
supportedLocales: const [
Locale('zh', 'CN'), // 支持的语言
],
theme: _getAppTheme(),
title: GloablConfig.DOMAIN_NAME,
getPages: RouteConfig.getPages,
initialRoute: getInitialRoute(),
debugShowCheckedModeBanner: false,
2024-03-18 15:54:06 +08:00
builder: (_, widget) {
return Obx(() => MediaQuery(
//设置文字大小不随系统设置改变
data: MediaQuery.of(context).copyWith(
2024-03-31 17:13:29 +08:00
textScaler:
TextScaler.linear(AppInfoService.to.scale.value)),
2024-03-18 15:54:06 +08:00
child: widget!));
})));
}
String getInitialRoute() {
if (AppInfoService.to.checkIsFirstInstall()) {
// 如果是第一次打开app打开的页面
}
2024-03-22 17:26:57 +08:00
final token =
StorageService.to.getString(CacheKeys.token, isWithUser: false);
bool isLogined = token != null;
return isLogined ? RouteConfig.home : RouteConfig.login;
}
2024-04-10 17:08:26 +08:00
ThemeData _getAppTheme() {
return theme;
}
}