mobile_skt/lib/index.dart

59 lines
2.3 KiB
Dart
Raw Normal View History

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';
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(
theme: theme,
title: GloablConfig.DOMAIN_NAME,
getPages: RouteConfig.getPages,
initialRoute: getInitialRoute(),
// initialRoute: RouteConfig.onboarding,
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!));
})));
}
String getInitialRoute() {
if (AppInfoService.to.checkIsFirstInstall()) {
// 如果是第一次打开app打开的页面
}
return StorageService.to.getString(CacheKeys.token, isWithUser: false) ==
null
? RouteConfig.login
: RouteConfig.home;
}
}