37 lines
1.2 KiB
Dart
37 lines
1.2 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:school_asignment_app/common/utils/toast_utils.dart';
|
|
import 'package:school_asignment_app/page/global_widget/bottom_navigation_bar.dart';
|
|
|
|
class GlobalScaffold extends StatelessWidget {
|
|
final AppBar? appBar;
|
|
final Widget body;
|
|
final int active;
|
|
DateTime? lastPopTime;
|
|
|
|
GlobalScaffold({Key? key, required this.body, this.appBar, required this.active}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: appBar,
|
|
backgroundColor: const Color.fromRGBO(245, 245, 245, 1),
|
|
body: WillPopScope(
|
|
onWillPop: () {
|
|
// 点击返回键的操作
|
|
if (lastPopTime == null || DateTime.now().difference(lastPopTime!) > const Duration(seconds: 2)) {
|
|
lastPopTime = DateTime.now();
|
|
ToastUtils.showInfo('再按一次退出');
|
|
return Future.value(false);
|
|
} else {
|
|
return Future.value(true);
|
|
}
|
|
},
|
|
child: body),
|
|
bottomNavigationBar: MyBottomNavigationBar(active: active),
|
|
);
|
|
}
|
|
}
|