99 lines
3.1 KiB
Dart
99 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:forui/forui.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
|
|
import 'package:flutter_subscreen_plugin/flutter_subscreen_plugin.dart';
|
|
|
|
import 'package:pj_supermarket_cloud/common/index.dart';
|
|
|
|
class MainApp extends StatefulWidget {
|
|
const MainApp({super.key});
|
|
|
|
@override
|
|
State<MainApp> createState() => _MainAppState();
|
|
}
|
|
|
|
class _MainAppState extends State<MainApp> with WidgetsBindingObserver {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
WidgetsBinding.instance.addObserver(this);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
WidgetsBinding.instance.removeObserver(this);
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
void didChangeAppLifecycleState(AppLifecycleState state) async {
|
|
SyncIdleTool.instance.updateLifecycle(state);
|
|
if (state == AppLifecycleState.paused ||
|
|
state == AppLifecycleState.detached) {
|
|
try {
|
|
SubScreenPlugin.doubleScreenCancel();
|
|
} catch (_) {}
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ScreenUtilInit(
|
|
designSize: const Size(1920, 1080),
|
|
minTextAdapt: true,
|
|
splitScreenMode: true,
|
|
builder: (_, child) {
|
|
return Obx(() {
|
|
final appTheme = Get.find<AppThemeControl>();
|
|
final fTheme = appTheme.theme.value;
|
|
final sizeScalar = appTheme.sizeScalar.value;
|
|
final themeData = FThemeData.inherit(
|
|
colorScheme: fTheme.colorScheme,
|
|
typography: fTheme.typography.scale(sizeScalar: sizeScalar),
|
|
style: fTheme.style.copyWith(
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(12.w),
|
|
),
|
|
borderWidth: 1,
|
|
iconStyle: fTheme.style.iconStyle.copyWith(
|
|
size: fTheme.typography.xl2.fontSize,
|
|
),
|
|
pagePadding: EdgeInsets.symmetric(vertical: 5.h, horizontal: 1.w),
|
|
),
|
|
);
|
|
return GetMaterialApp(
|
|
title: '收银机',
|
|
theme: ThemeData(
|
|
bottomSheetTheme: const BottomSheetThemeData(
|
|
backgroundColor: Colors.transparent,
|
|
),
|
|
),
|
|
defaultTransition: Transition.noTransition,
|
|
initialRoute: RouteNames.load,
|
|
getPages: RoutePages.list,
|
|
enableLog: true,
|
|
debugShowCheckedModeBanner: false,
|
|
locale: const Locale('zh', 'CN'),
|
|
localizationsDelegates: FLocalizations.localizationsDelegates,
|
|
supportedLocales: FLocalizations.supportedLocales,
|
|
navigatorObservers: [
|
|
GlobalRouteObserver(),
|
|
],
|
|
builder: EasyLoading.init(
|
|
builder: (_, childSecond) => Listener(
|
|
onPointerDown: (_) => SyncIdleTool.instance.recordUserActivity(),
|
|
child: FTheme(
|
|
data: themeData,
|
|
child: childSecond!,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
});
|
|
},
|
|
);
|
|
}
|
|
}
|