62 lines
2.5 KiB
Dart
62 lines
2.5 KiB
Dart
|
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) {
|
||
|
return ScreenUtilInit(
|
||
|
minTextAdapt: true,
|
||
|
designSize: 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,
|
||
|
builder: (_, widget) => Obx(() => MediaQuery(
|
||
|
//设置文字大小不随系统设置改变
|
||
|
data: MediaQuery.of(context).copyWith(
|
||
|
textScaleFactor: AppInfoService.to.scale.value),
|
||
|
child: GestureDetector(
|
||
|
onTap: () {
|
||
|
FocusScopeNode currentFocus = FocusScope.of(context);
|
||
|
if (!currentFocus.hasPrimaryFocus &&
|
||
|
currentFocus.focusedChild != null) {
|
||
|
FocusManager.instance.primaryFocus?.unfocus();
|
||
|
}
|
||
|
},
|
||
|
child: widget!,
|
||
|
))))));
|
||
|
}
|
||
|
|
||
|
String getInitialRoute() {
|
||
|
if (AppInfoService.to.checkIsFirstInstall()) {
|
||
|
// 如果是第一次打开app打开的页面
|
||
|
}
|
||
|
return StorageService.to.getString(CacheKeys.token, isWithUser: false) ==
|
||
|
null
|
||
|
? RouteConfig.login
|
||
|
: RouteConfig.home;
|
||
|
}
|
||
|
}
|