更新测试账号屏蔽小e
This commit is contained in:
@@ -183,30 +183,33 @@ class _HomePageState extends State<HomePage> {
|
|||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (userInfoController.model.login == 1) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
homeController.getSleepReport();
|
if (userInfoController.model.login == 1) {
|
||||||
deviceController.getDeviceNum().then((apiResponse) {
|
homeController.getSleepReport();
|
||||||
if (apiResponse.code != HttpStatusCodes.ok) {
|
deviceController.getDeviceNum().then((apiResponse) {
|
||||||
TopSlideNotification.show(
|
if (apiResponse.code != HttpStatusCodes.ok) {
|
||||||
Get.context!,
|
TopSlideNotification.show(
|
||||||
text: apiResponse.msg!,
|
Get.context!,
|
||||||
textColor: themeController.currentColor.sc9,
|
text: apiResponse.msg!,
|
||||||
);
|
textColor: themeController.currentColor.sc9,
|
||||||
}
|
);
|
||||||
});
|
}
|
||||||
deviceController.getDeviceList().then((apiResponse) {
|
});
|
||||||
if (apiResponse.code != HttpStatusCodes.ok) {
|
deviceController.getDeviceList().then((apiResponse) {
|
||||||
TopSlideNotification.show(
|
if (apiResponse.code != HttpStatusCodes.ok) {
|
||||||
Get.context!,
|
TopSlideNotification.show(
|
||||||
text: apiResponse.msg!,
|
Get.context!,
|
||||||
textColor: themeController.currentColor.sc9,
|
text: apiResponse.msg!,
|
||||||
);
|
textColor: themeController.currentColor.sc9,
|
||||||
} else {
|
);
|
||||||
//请求睡眠报告
|
} else {
|
||||||
deviceController.getSleepReport();
|
//请求睡眠报告
|
||||||
}
|
deviceController.getSleepReport();
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (userInfoController.device_bind_flag == 0) {
|
if (userInfoController.device_bind_flag == 0) {
|
||||||
dealBindProcess().then((value) {
|
dealBindProcess().then((value) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
|||||||
@@ -1,3 +1,275 @@
|
|||||||
|
// import 'dart:async';
|
||||||
|
// import 'dart:io';
|
||||||
|
|
||||||
|
// import 'package:ef/ef.dart';
|
||||||
|
// import 'package:flutter/material.dart';
|
||||||
|
// import 'package:flutter/services.dart';
|
||||||
|
// import 'package:flutter_svg/svg.dart';
|
||||||
|
// import 'package:get_storage/get_storage.dart';
|
||||||
|
// import 'package:vbvs_app/common/color/appConstants.dart';
|
||||||
|
// import 'package:vbvs_app/common/util/FitTool.dart';
|
||||||
|
// import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||||
|
// import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||||
|
// import 'package:vbvs_app/controller/main_bottom/main_page_controller.dart';
|
||||||
|
// import 'package:vbvs_app/controller/message/message_controller.dart';
|
||||||
|
// import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||||
|
// import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||||
|
// import 'package:vbvs_app/enum/LoginStatus.dart';
|
||||||
|
// import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||||
|
// import 'package:vbvs_app/pages/main_bottom/e_page.dart';
|
||||||
|
// import 'package:vbvs_app/pages/main_bottom/home_page.dart';
|
||||||
|
// import 'package:vbvs_app/pages/main_bottom/message_page.dart';
|
||||||
|
// import 'package:vbvs_app/pages/main_bottom/mine_page.dart';
|
||||||
|
|
||||||
|
// class MainPageBottomChange extends GetView<MainPageController> {
|
||||||
|
// GlobalController globalController = Get.find();
|
||||||
|
// ThemeController themeController = Get.find();
|
||||||
|
// MessageController messageController = Get.find();
|
||||||
|
// getBottomNavigationBarItem(String svgPath, String actSvgPath, String label,
|
||||||
|
// {double size = 0, bool isEmpty = false, bool showBadge = false}) {
|
||||||
|
// if (size == 0) {
|
||||||
|
// size = 36.rpx;
|
||||||
|
// }
|
||||||
|
// Widget buildIcon(String path) {
|
||||||
|
// return Padding(
|
||||||
|
// padding: EdgeInsets.only(bottom: 6.rpx),
|
||||||
|
// child: isEmpty
|
||||||
|
// ? Container()
|
||||||
|
// : Stack(
|
||||||
|
// clipBehavior: Clip.none,
|
||||||
|
// children: [
|
||||||
|
// SvgPicture.asset(
|
||||||
|
// path,
|
||||||
|
// width: size,
|
||||||
|
// height: size,
|
||||||
|
// ),
|
||||||
|
// if (showBadge)
|
||||||
|
// Positioned(
|
||||||
|
// right: -20.rpx,
|
||||||
|
// top: -2.rpx,
|
||||||
|
// child: Container(
|
||||||
|
// width: 14.rpx,
|
||||||
|
// height: 14.rpx,
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// color: Colors.red,
|
||||||
|
// shape: BoxShape.circle,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return BottomNavigationBarItem(
|
||||||
|
// icon: buildIcon(actSvgPath),
|
||||||
|
// activeIcon: buildIcon(svgPath),
|
||||||
|
// label: label,
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// List<Widget> arr = [
|
||||||
|
// HomePage(),
|
||||||
|
// // SleepReportPage(),
|
||||||
|
// // EPage(),
|
||||||
|
// EPage(sleepUri: "https://xiaoe.he-info.cn/"),
|
||||||
|
// MessagePage(),
|
||||||
|
// MinePage(),
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// DateTime? _lastBackPressedTime; // 记录上一次返回的时间
|
||||||
|
// final getStorage = GetStorage();
|
||||||
|
// @override
|
||||||
|
// Widget build(BuildContext context) {
|
||||||
|
// Future.delayed(const Duration(milliseconds: 0), () {
|
||||||
|
// String? isShowYingShiDialog = getStorage.read("isShowYingShiDialog");
|
||||||
|
// if (isShowYingShiDialog == null || isShowYingShiDialog != "true") {
|
||||||
|
// String btnName = "同意".tr;
|
||||||
|
// String cancelName = "取消".tr;
|
||||||
|
// if (Platform.isAndroid) {
|
||||||
|
// cancelName = "退出".tr;
|
||||||
|
// }
|
||||||
|
// showCustomConfirmOfWebViewDialog(context, "隐私协议".tr, getPrivacy(1),
|
||||||
|
// btnName: btnName, showCancel: true, cancelName: cancelName)
|
||||||
|
// .then((e) {
|
||||||
|
// if (e == "confirm") {
|
||||||
|
// getStorage.write("isShowYingShiDialog", "true");
|
||||||
|
// } else {
|
||||||
|
// if (cancelName == "退出") {
|
||||||
|
// SystemNavigator.pop();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// return PopScope(
|
||||||
|
// canPop: false,
|
||||||
|
|
||||||
|
// // onPopInvokedWithResult: (disposition, result) async {
|
||||||
|
// // if (Platform.isAndroid) {
|
||||||
|
// // var flag = await _handleBackPressed(context); // 自定义返回逻辑
|
||||||
|
// // if (flag) {
|
||||||
|
// // SystemNavigator.pop();
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// // },
|
||||||
|
// onPopInvokedWithResult: (disposition, result) async {
|
||||||
|
// UserInfoController userInfoController = Get.find();
|
||||||
|
// if (userInfoController.model.isProgrammaticPop) {
|
||||||
|
// // 如果是程序触发,重置标记并忽略
|
||||||
|
// userInfoController.model.isProgrammaticPop = false;
|
||||||
|
// return; // 阻止处理
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (Platform.isAndroid) {
|
||||||
|
// // var flag = await _handleBackPressed(context); // 自定义返回逻辑
|
||||||
|
// // if (flag) {
|
||||||
|
// // SystemNavigator.pop();
|
||||||
|
// // }
|
||||||
|
// Get.back();
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// child: Obx(
|
||||||
|
// () {
|
||||||
|
// if (globalController.model.hideBottomNavigationBar == true) {
|
||||||
|
// return Scaffold(
|
||||||
|
// // body: arr[controller.model.currentIndex],
|
||||||
|
// body: IndexedStack(
|
||||||
|
// // ✅ 改成 IndexedStack
|
||||||
|
// index: controller.model.currentIndex,
|
||||||
|
// children:
|
||||||
|
// arr.map((page) => SizedBox.expand(child: page)).toList(),
|
||||||
|
// ),
|
||||||
|
// floatingActionButtonAnimator:
|
||||||
|
// FloatingActionButtonAnimator.noAnimation,
|
||||||
|
// floatingActionButton: Container(),
|
||||||
|
// );
|
||||||
|
// } else {
|
||||||
|
// return Container(
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// image: DecorationImage(
|
||||||
|
// image: AssetImage('assets/img/bgImage.png'), // 本地图片
|
||||||
|
// fit: BoxFit.fill, // 填满整个 Container
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// child: Scaffold(
|
||||||
|
// backgroundColor: Colors.transparent,
|
||||||
|
// // body: arr[controller.model.currentIndex],
|
||||||
|
// body: IndexedStack(
|
||||||
|
// // ✅ 改成 IndexedStack
|
||||||
|
// index: controller.model.currentIndex??3,
|
||||||
|
// children: arr
|
||||||
|
// .map((page) => SizedBox.expand(child: page))
|
||||||
|
// .toList(),
|
||||||
|
// ),
|
||||||
|
// floatingActionButtonAnimator:
|
||||||
|
// FloatingActionButtonAnimator.noAnimation,
|
||||||
|
// floatingActionButtonLocation:
|
||||||
|
// FloatingActionButtonLocation.centerDocked,
|
||||||
|
// bottomNavigationBar: Theme(
|
||||||
|
// data: Theme.of(context).copyWith(
|
||||||
|
// splashFactory: NoSplash.splashFactory,
|
||||||
|
// splashColor: Colors.transparent,
|
||||||
|
// highlightColor: Colors.transparent,
|
||||||
|
// ),
|
||||||
|
// child: Container(
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// border: Border(
|
||||||
|
// top: BorderSide(
|
||||||
|
// color: themeController.currentColor.sc4
|
||||||
|
// .withOpacity(0.5),
|
||||||
|
// width: AppConstants().border_width,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// child: BottomNavigationBar(
|
||||||
|
// unselectedItemColor: themeController.currentColor.sc4,
|
||||||
|
// selectedItemColor: themeController.currentColor.sc1,
|
||||||
|
// backgroundColor: themeController.currentColor.sc5,
|
||||||
|
// selectedFontSize: 26.rpx,
|
||||||
|
// unselectedFontSize: 26.rpx,
|
||||||
|
// type: BottomNavigationBarType.fixed,
|
||||||
|
// currentIndex: controller.model.currentIndex,
|
||||||
|
// onTap: (index) {
|
||||||
|
// Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
|
// UserInfoController userInfoController = Get.find();
|
||||||
|
// bool isLoggedIn = userInfoController.model.login ==
|
||||||
|
// LoginStatus.LOGIN.code;
|
||||||
|
|
||||||
|
// // if ((index == 1 || index == 2) && !isLoggedIn) {
|
||||||
|
// if ((index == 2) && !isLoggedIn) {
|
||||||
|
// TopSlideNotification.show(
|
||||||
|
// context,
|
||||||
|
// text: "必须登录提示".tr,
|
||||||
|
// textColor: themeController.currentColor.sc9,
|
||||||
|
// );
|
||||||
|
// Future.delayed(Duration(milliseconds: 50), () {
|
||||||
|
// if (Get.currentRoute == '/ePage' ||
|
||||||
|
// Get.currentRoute == '/messagePage') {
|
||||||
|
// Get.back();
|
||||||
|
// }
|
||||||
|
// Future.delayed(Duration(milliseconds: 100), () {
|
||||||
|
// Get.toNamed("/otherLoginPage");
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (controller.model.currentIndex != index) {
|
||||||
|
// globalController.model.hideBottomNavigationBar =
|
||||||
|
// false;
|
||||||
|
// globalController.updateAll();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// controller.model.currentIndex = index;
|
||||||
|
// controller.updateAll();
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// items: [
|
||||||
|
// getBottomNavigationBarItem("assets/img/menu/home.svg",
|
||||||
|
// "assets/img/menu/n_home.svg", "菜单.首页".tr),
|
||||||
|
// getBottomNavigationBarItem("assets/img/menu/e.svg",
|
||||||
|
// "assets/img/menu/n_e.svg", "菜单.小e".tr),
|
||||||
|
// getBottomNavigationBarItem(
|
||||||
|
// "assets/img/menu/message.svg",
|
||||||
|
// "assets/img/menu/n_message.svg",
|
||||||
|
// "菜单.消息".tr,
|
||||||
|
// showBadge: (messageController
|
||||||
|
// .model.body_message_read ==
|
||||||
|
// 1 ||
|
||||||
|
// messageController.model.system_message_read ==
|
||||||
|
// 1)),
|
||||||
|
// getBottomNavigationBarItem("assets/img/menu/mine.svg",
|
||||||
|
// "assets/img/menu/n_mine.svg", "菜单.我的".tr),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ));
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Future<bool> _handleBackPressed(BuildContext context) async {
|
||||||
|
// final currentTime = DateTime.now();
|
||||||
|
|
||||||
|
// // 如果上次点击返回键时间为空,或者间隔超过 1 秒
|
||||||
|
// if (_lastBackPressedTime == null ||
|
||||||
|
// currentTime.difference(_lastBackPressedTime!) > Duration(seconds: 2)) {
|
||||||
|
// _lastBackPressedTime = currentTime;
|
||||||
|
// // showToast("再按一次退出程序", color: color_warning, closeTime: 2);
|
||||||
|
// TopSlideNotification.show(context, text: "滑动退出提醒".tr);
|
||||||
|
// return false; // 阻止退出程序
|
||||||
|
// } else {
|
||||||
|
// return true; // 允许退出程序
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
@@ -25,11 +297,60 @@ class MainPageBottomChange extends GetView<MainPageController> {
|
|||||||
GlobalController globalController = Get.find();
|
GlobalController globalController = Get.find();
|
||||||
ThemeController themeController = Get.find();
|
ThemeController themeController = Get.find();
|
||||||
MessageController messageController = Get.find();
|
MessageController messageController = Get.find();
|
||||||
|
final getStorage = GetStorage();
|
||||||
|
|
||||||
|
late final List<Widget> arr;
|
||||||
|
late final List<BottomNavigationBarItem> bottomItems;
|
||||||
|
DateTime? _lastBackPressedTime;
|
||||||
|
|
||||||
|
MainPageBottomChange({super.key}) {
|
||||||
|
// ✅ 根据是否测试账号动态生成页面
|
||||||
|
if (!AppConstants.is_test_account) {
|
||||||
|
arr = [
|
||||||
|
HomePage(),
|
||||||
|
EPage(sleepUri: "https://xiaoe.he-info.cn/"),
|
||||||
|
MessagePage(),
|
||||||
|
MinePage(),
|
||||||
|
];
|
||||||
|
bottomItems = [
|
||||||
|
getBottomNavigationBarItem("assets/img/menu/home.svg",
|
||||||
|
"assets/img/menu/n_home.svg", "菜单.首页".tr),
|
||||||
|
getBottomNavigationBarItem("assets/img/menu/e.svg",
|
||||||
|
"assets/img/menu/n_e.svg", "菜单.小e".tr),
|
||||||
|
getBottomNavigationBarItem(
|
||||||
|
"assets/img/menu/message.svg",
|
||||||
|
"assets/img/menu/n_message.svg",
|
||||||
|
"菜单.消息".tr,
|
||||||
|
showBadge: (messageController.model.body_message_read == 1 ||
|
||||||
|
messageController.model.system_message_read == 1)),
|
||||||
|
getBottomNavigationBarItem("assets/img/menu/mine.svg",
|
||||||
|
"assets/img/menu/n_mine.svg", "菜单.我的".tr),
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
arr = [
|
||||||
|
HomePage(),
|
||||||
|
MessagePage(),
|
||||||
|
MinePage(),
|
||||||
|
];
|
||||||
|
bottomItems = [
|
||||||
|
getBottomNavigationBarItem("assets/img/menu/home.svg",
|
||||||
|
"assets/img/menu/n_home.svg", "菜单.首页".tr),
|
||||||
|
getBottomNavigationBarItem(
|
||||||
|
"assets/img/menu/message.svg",
|
||||||
|
"assets/img/menu/n_message.svg",
|
||||||
|
"菜单.消息".tr,
|
||||||
|
showBadge: (messageController.model.body_message_read == 1 ||
|
||||||
|
messageController.model.system_message_read == 1)),
|
||||||
|
getBottomNavigationBarItem("assets/img/menu/mine.svg",
|
||||||
|
"assets/img/menu/n_mine.svg", "菜单.我的".tr),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getBottomNavigationBarItem(String svgPath, String actSvgPath, String label,
|
getBottomNavigationBarItem(String svgPath, String actSvgPath, String label,
|
||||||
{double size = 0, bool isEmpty = false, bool showBadge = false}) {
|
{double size = 0, bool isEmpty = false, bool showBadge = false}) {
|
||||||
if (size == 0) {
|
if (size == 0) size = 36.rpx;
|
||||||
size = 36.rpx;
|
|
||||||
}
|
|
||||||
Widget buildIcon(String path) {
|
Widget buildIcon(String path) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(bottom: 6.rpx),
|
padding: EdgeInsets.only(bottom: 6.rpx),
|
||||||
@@ -50,12 +371,12 @@ class MainPageBottomChange extends GetView<MainPageController> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
width: 14.rpx,
|
width: 14.rpx,
|
||||||
height: 14.rpx,
|
height: 14.rpx,
|
||||||
decoration: BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -68,203 +389,150 @@ class MainPageBottomChange extends GetView<MainPageController> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> arr = [
|
|
||||||
HomePage(),
|
|
||||||
// SleepReportPage(),
|
|
||||||
// EPage(),
|
|
||||||
EPage(sleepUri: "https://xiaoe.he-info.cn/"),
|
|
||||||
MessagePage(),
|
|
||||||
MinePage(),
|
|
||||||
];
|
|
||||||
|
|
||||||
DateTime? _lastBackPressedTime; // 记录上一次返回的时间
|
|
||||||
final getStorage = GetStorage();
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// Future.delayed(const Duration(milliseconds: 0), () {
|
Future.delayed(const Duration(milliseconds: 0), () {
|
||||||
// String? isShowYingShiDialog = getStorage.read("isShowYingShiDialog");
|
String? isShowYingShiDialog = getStorage.read("isShowYingShiDialog");
|
||||||
// if (isShowYingShiDialog == null || isShowYingShiDialog != "true") {
|
if (isShowYingShiDialog == null || isShowYingShiDialog != "true") {
|
||||||
// String btnName = "同意".tr;
|
String btnName = "同意".tr;
|
||||||
// String cancelName = "取消".tr;
|
String cancelName = "取消".tr;
|
||||||
// if (Platform.isAndroid) {
|
if (Platform.isAndroid) cancelName = "退出".tr;
|
||||||
// cancelName = "退出".tr;
|
|
||||||
// }
|
showCustomConfirmOfWebViewDialog(context, "隐私协议".tr, getPrivacy(1),
|
||||||
// showCustomConfirmOfWebViewDialog(context, "隐私协议".tr, getPrivacy(1),
|
btnName: btnName, showCancel: true, cancelName: cancelName)
|
||||||
// btnName: btnName, showCancel: true, cancelName: cancelName)
|
.then((e) {
|
||||||
// .then((e) {
|
if (e == "confirm") {
|
||||||
// if (e == "confirm") {
|
getStorage.write("isShowYingShiDialog", "true");
|
||||||
// getStorage.write("isShowYingShiDialog", "true");
|
} else {
|
||||||
// } else {
|
if (cancelName == "退出") SystemNavigator.pop();
|
||||||
// if (cancelName == "退出") {
|
}
|
||||||
// SystemNavigator.pop();
|
});
|
||||||
// }
|
}
|
||||||
// }
|
});
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: false,
|
canPop: false,
|
||||||
|
|
||||||
// onPopInvokedWithResult: (disposition, result) async {
|
|
||||||
// if (Platform.isAndroid) {
|
|
||||||
// var flag = await _handleBackPressed(context); // 自定义返回逻辑
|
|
||||||
// if (flag) {
|
|
||||||
// SystemNavigator.pop();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
onPopInvokedWithResult: (disposition, result) async {
|
onPopInvokedWithResult: (disposition, result) async {
|
||||||
UserInfoController userInfoController = Get.find();
|
UserInfoController userInfoController = Get.find();
|
||||||
if (userInfoController.model.isProgrammaticPop) {
|
if (userInfoController.model.isProgrammaticPop) {
|
||||||
// 如果是程序触发,重置标记并忽略
|
|
||||||
userInfoController.model.isProgrammaticPop = false;
|
userInfoController.model.isProgrammaticPop = false;
|
||||||
return; // 阻止处理
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
// var flag = await _handleBackPressed(context); // 自定义返回逻辑
|
|
||||||
// if (flag) {
|
|
||||||
// SystemNavigator.pop();
|
|
||||||
// }
|
|
||||||
Get.back();
|
Get.back();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Obx(
|
child: Obx(() {
|
||||||
() {
|
int currentIndex = controller.model.currentIndex;
|
||||||
if (globalController.model.hideBottomNavigationBar == true) {
|
|
||||||
return Scaffold(
|
// ✅ 防止 index 超出范围(例如测试账号少一个 tab)
|
||||||
// body: arr[controller.model.currentIndex],
|
if (currentIndex >= arr.length) {
|
||||||
body: IndexedStack(
|
currentIndex = 0;
|
||||||
// ✅ 改成 IndexedStack
|
controller.model.currentIndex = 0;
|
||||||
index: controller.model.currentIndex,
|
}
|
||||||
children:
|
|
||||||
arr.map((page) => SizedBox.expand(child: page)).toList(),
|
if (globalController.model.hideBottomNavigationBar == true) {
|
||||||
|
return Scaffold(
|
||||||
|
body: IndexedStack(
|
||||||
|
index: currentIndex,
|
||||||
|
children: arr.map((page) => SizedBox.expand(child: page)).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage('assets/img/bgImage.png'),
|
||||||
|
fit: BoxFit.fill,
|
||||||
),
|
),
|
||||||
floatingActionButtonAnimator:
|
),
|
||||||
FloatingActionButtonAnimator.noAnimation,
|
child: Scaffold(
|
||||||
floatingActionButton: Container(),
|
backgroundColor: Colors.transparent,
|
||||||
);
|
body: IndexedStack(
|
||||||
} else {
|
index: currentIndex,
|
||||||
return Container(
|
children: arr.map((page) => SizedBox.expand(child: page)).toList(),
|
||||||
decoration: BoxDecoration(
|
),
|
||||||
image: DecorationImage(
|
bottomNavigationBar: Theme(
|
||||||
image: AssetImage('assets/img/bgImage.png'), // 本地图片
|
data: Theme.of(context).copyWith(
|
||||||
fit: BoxFit.fill, // 填满整个 Container
|
splashFactory: NoSplash.splashFactory,
|
||||||
|
splashColor: Colors.transparent,
|
||||||
|
highlightColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
top: BorderSide(
|
||||||
|
color:
|
||||||
|
themeController.currentColor.sc4.withOpacity(0.5),
|
||||||
|
width: AppConstants().border_width,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: BottomNavigationBar(
|
||||||
|
unselectedItemColor: themeController.currentColor.sc4,
|
||||||
|
selectedItemColor: themeController.currentColor.sc1,
|
||||||
|
backgroundColor: themeController.currentColor.sc5,
|
||||||
|
selectedFontSize: 26.rpx,
|
||||||
|
unselectedFontSize: 26.rpx,
|
||||||
|
type: BottomNavigationBarType.fixed,
|
||||||
|
currentIndex: currentIndex,
|
||||||
|
onTap: (index) {
|
||||||
|
Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
|
UserInfoController userInfoController = Get.find();
|
||||||
|
bool isLoggedIn = userInfoController.model.login ==
|
||||||
|
LoginStatus.LOGIN.code;
|
||||||
|
|
||||||
|
// ✅ 仅非测试账号检查登录状态
|
||||||
|
if (!AppConstants.is_test_account &&
|
||||||
|
(index == 2) &&
|
||||||
|
!isLoggedIn) {
|
||||||
|
TopSlideNotification.show(
|
||||||
|
context,
|
||||||
|
text: "必须登录提示".tr,
|
||||||
|
textColor: themeController.currentColor.sc9,
|
||||||
|
);
|
||||||
|
Future.delayed(const Duration(milliseconds: 50), () {
|
||||||
|
if (Get.currentRoute == '/ePage' ||
|
||||||
|
Get.currentRoute == '/messagePage') {
|
||||||
|
Get.back();
|
||||||
|
}
|
||||||
|
Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
|
Get.toNamed("/otherLoginPage");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (controller.model.currentIndex != index) {
|
||||||
|
globalController.model.hideBottomNavigationBar = false;
|
||||||
|
globalController.updateAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
controller.model.currentIndex = index;
|
||||||
|
controller.updateAll();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
items: bottomItems,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Scaffold(
|
),
|
||||||
backgroundColor: Colors.transparent,
|
),
|
||||||
// body: arr[controller.model.currentIndex],
|
);
|
||||||
body: IndexedStack(
|
}
|
||||||
// ✅ 改成 IndexedStack
|
}),
|
||||||
index: controller.model.currentIndex??3,
|
|
||||||
children: arr
|
|
||||||
.map((page) => SizedBox.expand(child: page))
|
|
||||||
.toList(),
|
|
||||||
),
|
|
||||||
floatingActionButtonAnimator:
|
|
||||||
FloatingActionButtonAnimator.noAnimation,
|
|
||||||
floatingActionButtonLocation:
|
|
||||||
FloatingActionButtonLocation.centerDocked,
|
|
||||||
bottomNavigationBar: Theme(
|
|
||||||
data: Theme.of(context).copyWith(
|
|
||||||
splashFactory: NoSplash.splashFactory,
|
|
||||||
splashColor: Colors.transparent,
|
|
||||||
highlightColor: Colors.transparent,
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border(
|
|
||||||
top: BorderSide(
|
|
||||||
color: themeController.currentColor.sc4
|
|
||||||
.withOpacity(0.5),
|
|
||||||
width: AppConstants().border_width,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: BottomNavigationBar(
|
|
||||||
unselectedItemColor: themeController.currentColor.sc4,
|
|
||||||
selectedItemColor: themeController.currentColor.sc1,
|
|
||||||
backgroundColor: themeController.currentColor.sc5,
|
|
||||||
selectedFontSize: 26.rpx,
|
|
||||||
unselectedFontSize: 26.rpx,
|
|
||||||
type: BottomNavigationBarType.fixed,
|
|
||||||
currentIndex: controller.model.currentIndex,
|
|
||||||
onTap: (index) {
|
|
||||||
Future.delayed(const Duration(milliseconds: 100), () {
|
|
||||||
UserInfoController userInfoController = Get.find();
|
|
||||||
bool isLoggedIn = userInfoController.model.login ==
|
|
||||||
LoginStatus.LOGIN.code;
|
|
||||||
|
|
||||||
// if ((index == 1 || index == 2) && !isLoggedIn) {
|
|
||||||
if ((index == 2) && !isLoggedIn) {
|
|
||||||
TopSlideNotification.show(
|
|
||||||
context,
|
|
||||||
text: "必须登录提示".tr,
|
|
||||||
textColor: themeController.currentColor.sc9,
|
|
||||||
);
|
|
||||||
Future.delayed(Duration(milliseconds: 50), () {
|
|
||||||
if (Get.currentRoute == '/ePage' ||
|
|
||||||
Get.currentRoute == '/messagePage') {
|
|
||||||
Get.back();
|
|
||||||
}
|
|
||||||
Future.delayed(Duration(milliseconds: 100), () {
|
|
||||||
Get.toNamed("/otherLoginPage");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (controller.model.currentIndex != index) {
|
|
||||||
globalController.model.hideBottomNavigationBar =
|
|
||||||
false;
|
|
||||||
globalController.updateAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
controller.model.currentIndex = index;
|
|
||||||
controller.updateAll();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
items: [
|
|
||||||
getBottomNavigationBarItem("assets/img/menu/home.svg",
|
|
||||||
"assets/img/menu/n_home.svg", "菜单.首页".tr),
|
|
||||||
getBottomNavigationBarItem("assets/img/menu/e.svg",
|
|
||||||
"assets/img/menu/n_e.svg", "菜单.小e".tr),
|
|
||||||
getBottomNavigationBarItem(
|
|
||||||
"assets/img/menu/message.svg",
|
|
||||||
"assets/img/menu/n_message.svg",
|
|
||||||
"菜单.消息".tr,
|
|
||||||
showBadge: (messageController
|
|
||||||
.model.body_message_read ==
|
|
||||||
1 ||
|
|
||||||
messageController.model.system_message_read ==
|
|
||||||
1)),
|
|
||||||
getBottomNavigationBarItem("assets/img/menu/mine.svg",
|
|
||||||
"assets/img/menu/n_mine.svg", "菜单.我的".tr),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _handleBackPressed(BuildContext context) async {
|
Future<bool> _handleBackPressed(BuildContext context) async {
|
||||||
final currentTime = DateTime.now();
|
final currentTime = DateTime.now();
|
||||||
|
|
||||||
// 如果上次点击返回键时间为空,或者间隔超过 1 秒
|
|
||||||
if (_lastBackPressedTime == null ||
|
if (_lastBackPressedTime == null ||
|
||||||
currentTime.difference(_lastBackPressedTime!) > Duration(seconds: 2)) {
|
currentTime.difference(_lastBackPressedTime!) > const Duration(seconds: 2)) {
|
||||||
_lastBackPressedTime = currentTime;
|
_lastBackPressedTime = currentTime;
|
||||||
// showToast("再按一次退出程序", color: color_warning, closeTime: 2);
|
|
||||||
TopSlideNotification.show(context, text: "滑动退出提醒".tr);
|
TopSlideNotification.show(context, text: "滑动退出提醒".tr);
|
||||||
return false; // 阻止退出程序
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true; // 允许退出程序
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
import 'package:ef/ef.dart';
|
import 'package:ef/ef.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||||
import 'package:get_storage/get_storage.dart';
|
|
||||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||||
import 'package:vbvs_app/component/tool/CustomCard.dart';
|
|
||||||
import 'package:vbvs_app/controller/mh_controller/mh_language_controller.dart';
|
import 'package:vbvs_app/controller/mh_controller/mh_language_controller.dart';
|
||||||
import 'package:vbvs_app/controller/weather/weather_controller.dart';
|
import 'package:vbvs_app/controller/weather/weather_controller.dart';
|
||||||
import 'package:vbvs_app/enum/APPPackageType.dart';
|
|
||||||
import 'package:vbvs_app/language/AppLanguage.dart';
|
import 'package:vbvs_app/language/AppLanguage.dart';
|
||||||
import 'package:vbvs_app/pages/device_bind/componnet/FancyCircleCheckbox.dart';
|
import 'package:vbvs_app/pages/device_bind/componnet/FancyCircleCheckbox.dart';
|
||||||
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
||||||
|
|||||||
Reference in New Issue
Block a user