更新城市选择

This commit is contained in:
wyf
2025-11-21 10:34:18 +08:00
parent b2a621c2d3
commit 991bf97fd1
27 changed files with 79242 additions and 467 deletions

View File

@@ -283,6 +283,7 @@ 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/setting/language/language_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/APPPackageType.dart';
@@ -302,6 +303,7 @@ class MainPageBottomChange extends GetView<MainPageController> {
late final List<Widget> arr;
late final List<BottomNavigationBarItem> bottomItems;
DateTime? _lastBackPressedTime;
LanguageController languageController = Get.find();
MainPageBottomChange({super.key}) {
// ✅ 根据是否测试账号动态生成页面
@@ -408,122 +410,133 @@ class MainPageBottomChange extends GetView<MainPageController> {
});
}
return PopScope(
canPop: false,
onPopInvokedWithResult: (disposition, result) async {
UserInfoController userInfoController = Get.find();
if (userInfoController.model.isProgrammaticPop) {
userInfoController.model.isProgrammaticPop = false;
return;
}
return Obx(() {
final currentLanguage =
languageController.selectLanguage.value; // 监听此变量变化
return PopScope(
canPop: false,
onPopInvokedWithResult: (disposition, result) async {
UserInfoController userInfoController = Get.find();
if (userInfoController.model.isProgrammaticPop) {
userInfoController.model.isProgrammaticPop = false;
return;
}
if (Platform.isAndroid) {
Get.back();
}
},
child: Obx(() {
int currentIndex = controller.model.currentIndex;
// if (Platform.isAndroid) {
// Get.back();
// }
if (Platform.isAndroid) {
var flag = await _handleBackPressed(context);
if (flag) {
SystemNavigator.pop();
}
}
},
child: Obx(() {
int currentIndex = controller.model.currentIndex;
// ✅ 防止 index 超出范围(例如测试账号少一个 tab
if (currentIndex >= arr.length) {
currentIndex = 0;
controller.model.currentIndex = 0;
}
// ✅ 防止 index 超出范围(例如测试账号少一个 tab
if (currentIndex >= arr.length) {
currentIndex = 0;
controller.model.currentIndex = 0;
}
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,
),
),
child: Scaffold(
backgroundColor: Colors.transparent,
if (globalController.model.hideBottomNavigationBar == true) {
return Scaffold(
body: IndexedStack(
index: currentIndex,
children:
arr.map((page) => SizedBox.expand(child: page)).toList(),
),
bottomNavigationBar: Theme(
data: Theme.of(context).copyWith(
splashFactory: NoSplash.splashFactory,
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
);
} else {
return Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/img/bgImage.png'),
fit: BoxFit.fill,
),
child: Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color:
themeController.currentColor.sc4.withOpacity(0.5),
width: AppConstants().border_width,
),
child: Scaffold(
backgroundColor: Colors.transparent,
body: IndexedStack(
index: currentIndex,
children:
arr.map((page) => SizedBox.expand(child: page)).toList(),
),
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: currentIndex,
onTap: (index) {
Future.delayed(const Duration(milliseconds: 100), () {
UserInfoController userInfoController = Get.find();
bool isLoggedIn = userInfoController.model.login ==
LoginStatus.LOGIN.code;
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),
// ✅ 仅非测试账号检查登录状态
if (!AppConstants.is_test_account &&
(index == 2) &&
!isLoggedIn) {
TopSlideNotification.show(
context,
text: "必须登录提示".tr,
textColor: themeController.currentColor.sc9,
);
Future.delayed(const Duration(milliseconds: 50),
() {
Get.toNamed("/otherLoginPage");
if (Get.currentRoute == '/ePage' ||
Get.currentRoute == '/messagePage') {
Get.back();
}
Future.delayed(const Duration(milliseconds: 100),
() {
Get.toNamed("/otherLoginPage");
});
});
});
return;
}
return;
}
if (controller.model.currentIndex != index) {
globalController.model.hideBottomNavigationBar =
false;
globalController.updateAll();
}
if (controller.model.currentIndex != index) {
globalController.model.hideBottomNavigationBar =
false;
globalController.updateAll();
}
controller.model.currentIndex = index;
controller.updateAll();
});
},
items: bottomItems,
controller.model.currentIndex = index;
controller.updateAll();
});
},
items: bottomItems,
),
),
),
),
),
);
}
}),
);
);
}
}),
);
});
}
Future<bool> _handleBackPressed(BuildContext context) async {