2024-03-18 13:23:58 +08:00
|
|
|
import 'package:flutter/material.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';
|
2024-03-18 13:23:58 +08:00
|
|
|
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;
|
2024-03-26 16:02:49 +08:00
|
|
|
final isLogin =
|
|
|
|
StorageService.to.getString(CacheKeys.token, isWithUser: false) != null;
|
2024-03-18 13:23:58 +08:00
|
|
|
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
|
2024-03-18 13:23:58 +08:00
|
|
|
builder: (buildContext, child) => RefreshConfiguration(
|
|
|
|
headerBuilder: () => RefreshHeader(),
|
|
|
|
footerBuilder: () => const RefreshFooter(),
|
|
|
|
hideFooterWhenNotFull: true,
|
|
|
|
headerTriggerDistance: 30,
|
|
|
|
maxOverScrollExtent: 80,
|
|
|
|
footerTriggerDistance: 150,
|
|
|
|
child: GetMaterialApp(
|
|
|
|
theme: theme,
|
|
|
|
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(
|
|
|
|
textScaleFactor: AppInfoService.to.scale.value),
|
|
|
|
child: widget!));
|
|
|
|
})));
|
2024-03-18 13:23:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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-03-18 13:23:58 +08:00
|
|
|
}
|
|
|
|
}
|