扫码无权限优化,司机预约多弹窗

This commit is contained in:
2025-12-25 10:40:26 +08:00
parent f2f2348b54
commit bfa615a7f4
6 changed files with 128 additions and 46 deletions

View File

@@ -17,6 +17,7 @@ import 'package:ln_jq_app/pages/qr_code/view.dart';
import 'package:ln_jq_app/storage_service.dart';
import '../../../common/styles/theme.dart';
import 'reservation_list_bottomsheet.dart';
/// Helper class for managing time slots
class TimeSlot {
@@ -547,6 +548,10 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
num maxHydrogen = 0;
String difference = "";
//用来管理查看预约的弹窗
Worker? _sheetWorker;
bool init = false;
@override
bool get listenLifecycleEvent => true;
@@ -555,6 +560,32 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
super.onInit();
getUserBindCarInfo();
getSiteList();
if (!init) {
_setupListener();
init = true;
}
}
@override
void dispose() {
_sheetWorker?.dispose();
super.dispose();
}
void _setupListener() {
_sheetWorker = ever(shouldShowReservationList, (bool shouldShow) {
if (shouldShow) {
Get.bottomSheet(
const ReservationListBottomSheet(),
isScrollControlled: true, // 允许弹窗使用更多屏幕高度
backgroundColor: Colors.transparent,
);
// 重要:显示后立即将信号重置为 false防止不必要的重复弹出
shouldShowReservationList.value = false;
}
});
}
void getUserBindCarInfo() {
@@ -628,6 +659,11 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
final leftHydrogenNum = double.tryParse(leftHydrogen) ?? 0.0;
difference = (maxHydrogen - leftHydrogenNum).toStringAsFixed(2);
int flooredDifference = (maxHydrogen - leftHydrogenNum).floor();
if (flooredDifference > 0) {
amountController.text = flooredDifference.toString();
}
updateUi();
} catch (e) {
} finally {

View File

@@ -13,7 +13,7 @@ import 'reservation_list_bottomsheet.dart';
class ReservationPage extends GetView<C_ReservationController> {
ReservationPage({super.key});
bool init = false;
@override
Widget build(BuildContext context) {
@@ -21,10 +21,7 @@ class ReservationPage extends GetView<C_ReservationController> {
init: C_ReservationController(),
id: 'reservation',
builder: (_) {
if (!init) {
_setupListener(context);
init = true;
}
return Scaffold(
backgroundColor: Colors.grey[100],
body: GestureDetector(
@@ -335,20 +332,7 @@ class ReservationPage extends GetView<C_ReservationController> {
);
}
void _setupListener(BuildContext context) {
ever(controller.shouldShowReservationList, (bool shouldShow) {
if (shouldShow) {
Get.bottomSheet(
const ReservationListBottomSheet(),
isScrollControlled: true, // 允许弹窗使用更多屏幕高度
backgroundColor: Colors.transparent,
);
// 重要:显示后立即将信号重置为 false防止不必要的重复弹出
controller.shouldShowReservationList.value = false;
}
});
}
// 表单中的可点击行 (用于日期和时间选择)
Widget _buildPickerRow({