|
|
@@ -3,8 +3,11 @@ import 'package:electronic_assistant/module/main/controller.dart';
|
|
|
import 'package:electronic_assistant/module/main/drawer/view.dart';
|
|
|
import 'package:electronic_assistant/resource/assets.gen.dart';
|
|
|
import 'package:electronic_assistant/resource/colors.gen.dart';
|
|
|
+import 'package:electronic_assistant/resource/string.gen.dart';
|
|
|
import 'package:electronic_assistant/utils/expand.dart';
|
|
|
+import 'package:electronic_assistant/utils/toast_util.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter/services.dart';
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import '../files/view.dart';
|
|
|
@@ -20,22 +23,36 @@ class MainTabPage extends BasePage<MainController> {
|
|
|
|
|
|
@override
|
|
|
Widget buildBody(BuildContext context) {
|
|
|
- return Scaffold(
|
|
|
- key: controller.scaffoldKey,
|
|
|
- body: Obx(() {
|
|
|
- return pages[controller.currentIndex];
|
|
|
- }),
|
|
|
- resizeToAvoidBottomInset: false,
|
|
|
- floatingActionButton: buildAIChatBtn(),
|
|
|
- floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
|
|
- bottomNavigationBar: buildBottomAppBar(),
|
|
|
- drawerEdgeDragWidth: 0,
|
|
|
- drawer: Drawer(
|
|
|
- shape: const RoundedRectangleBorder(
|
|
|
- borderRadius: BorderRadius.zero,
|
|
|
+ return PopScope(
|
|
|
+ canPop: false,
|
|
|
+ onPopInvokedWithResult: (bool didPop, dynamic result) async {
|
|
|
+ if (!didPop &&
|
|
|
+ (controller.lastPressedAt == null ||
|
|
|
+ DateTime.now().difference(controller.lastPressedAt!) >
|
|
|
+ const Duration(seconds: 2))) {
|
|
|
+ controller.setLastPressedAt(DateTime.now());
|
|
|
+ ToastUtil.showToast(StringName.exitAppTip.tr);
|
|
|
+ } else {
|
|
|
+ SystemNavigator.pop();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ child: Scaffold(
|
|
|
+ key: controller.scaffoldKey,
|
|
|
+ body: Obx(() {
|
|
|
+ return pages[controller.currentIndex];
|
|
|
+ }),
|
|
|
+ resizeToAvoidBottomInset: false,
|
|
|
+ floatingActionButton: buildAIChatBtn(),
|
|
|
+ floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
|
|
+ bottomNavigationBar: buildBottomAppBar(),
|
|
|
+ drawerEdgeDragWidth: 0,
|
|
|
+ drawer: Drawer(
|
|
|
+ shape: const RoundedRectangleBorder(
|
|
|
+ borderRadius: BorderRadius.zero,
|
|
|
+ ),
|
|
|
+ backgroundColor: "#F6F5F8".toColor(),
|
|
|
+ child: const MainDrawerView(),
|
|
|
),
|
|
|
- backgroundColor: "#F6F5F8".toColor(),
|
|
|
- child: const MainDrawerView(),
|
|
|
),
|
|
|
);
|
|
|
}
|