更新分享设备权限
This commit is contained in:
@@ -203,9 +203,12 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
|
||||
}
|
||||
|
||||
// 标签切换回调
|
||||
void _onTabChanged(int index) {
|
||||
Future<void> _onTabChanged(int index) async {
|
||||
_pageController.animateToPage(index,
|
||||
duration: const Duration(milliseconds: 300), curve: Curves.easeInOut);
|
||||
BodyDeviceController deviceController = Get.find();
|
||||
await deviceController.getDeviceList();
|
||||
await deviceController.getSleepReport();
|
||||
}
|
||||
|
||||
// 页面切换回调
|
||||
|
||||
@@ -106,8 +106,12 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
// 计算弹窗需要的实际高度(估算)
|
||||
final estimatedItemHeight = 66.rpx; // 每个菜单项的估算高度
|
||||
//todo 更新菜单项,需要在此添加数量
|
||||
final itemCount =
|
||||
widget.device['bind_type'] == BindType.active.code ? 9 : 5;
|
||||
// final itemCount =
|
||||
// widget.device['bind_type'] == BindType.active.code ? 9 : 5;
|
||||
final itemCount = widget.device['bind_type'] == BindType.active.code
|
||||
? 9
|
||||
: (getWifiPermissionByOpType(widget.device) ? 6 : 5);
|
||||
|
||||
final estimatedPopupHeight =
|
||||
(itemCount * estimatedItemHeight) + 40.rpx; // 加上padding
|
||||
|
||||
@@ -288,59 +292,129 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
),
|
||||
];
|
||||
|
||||
if (widget.device['bind_type'] == BindType.active.code &&
|
||||
!AppConstants.is_test_account) {
|
||||
items.addAll([
|
||||
_buildMenuItem(
|
||||
text: "WIFI配置".tr,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_isPopupOpen = false;
|
||||
});
|
||||
_popupEntry?.remove();
|
||||
_popupEntry = null;
|
||||
dealWifi(widget.device);
|
||||
},
|
||||
),
|
||||
_buildMenuItem(
|
||||
text: "设备校准".tr,
|
||||
onTap: () async {
|
||||
setState(() {
|
||||
_isPopupOpen = false;
|
||||
});
|
||||
_popupEntry?.remove();
|
||||
_popupEntry = null;
|
||||
BlueteethBindController blueteethBindController = Get.find();
|
||||
blueteethBindController.currentDeviceMac?.value =
|
||||
widget.device['mac'];
|
||||
await Get.toNamed("/calibrationPersonPage", arguments: 2);
|
||||
},
|
||||
),
|
||||
_buildMenuItem(
|
||||
text: "分享设备".tr,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_isPopupOpen = false;
|
||||
});
|
||||
_popupEntry?.remove();
|
||||
_popupEntry = null;
|
||||
Get.toNamed("/deviceSharePage", arguments: widget.device);
|
||||
},
|
||||
),
|
||||
_buildMenuItem(
|
||||
text: "消息设置".tr,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_isPopupOpen = false;
|
||||
});
|
||||
_popupEntry?.remove();
|
||||
_popupEntry = null;
|
||||
// Get.toNamed("/deviceDetail", arguments: widget.device);
|
||||
Get.toNamed("/messageSettingPage", arguments: widget.device);
|
||||
// TopSlideNotification.show(context, text: "待开发功能".tr);
|
||||
},
|
||||
),
|
||||
]);
|
||||
// if ((widget.device['bind_type'] == BindType.active.code &&
|
||||
// !AppConstants.is_test_account) ||
|
||||
// (getWifiPermissionByOpType(widget.device))) {
|
||||
// items.addAll([
|
||||
// _buildMenuItem(
|
||||
// text: "WIFI配置".tr,
|
||||
// onTap: () {
|
||||
// setState(() {
|
||||
// _isPopupOpen = false;
|
||||
// });
|
||||
// _popupEntry?.remove();
|
||||
// _popupEntry = null;
|
||||
// dealWifi(widget.device);
|
||||
// },
|
||||
// ),
|
||||
// _buildMenuItem(
|
||||
// text: "设备校准".tr,
|
||||
// onTap: () async {
|
||||
// setState(() {
|
||||
// _isPopupOpen = false;
|
||||
// });
|
||||
// _popupEntry?.remove();
|
||||
// _popupEntry = null;
|
||||
// BlueteethBindController blueteethBindController = Get.find();
|
||||
// blueteethBindController.currentDeviceMac?.value =
|
||||
// widget.device['mac'];
|
||||
// await Get.toNamed("/calibrationPersonPage", arguments: 2);
|
||||
// },
|
||||
// ),
|
||||
// _buildMenuItem(
|
||||
// text: "分享设备".tr,
|
||||
// onTap: () {
|
||||
// setState(() {
|
||||
// _isPopupOpen = false;
|
||||
// });
|
||||
// _popupEntry?.remove();
|
||||
// _popupEntry = null;
|
||||
// Get.toNamed("/deviceSharePage", arguments: widget.device);
|
||||
// },
|
||||
// ),
|
||||
// _buildMenuItem(
|
||||
// text: "消息设置".tr,
|
||||
// onTap: () {
|
||||
// setState(() {
|
||||
// _isPopupOpen = false;
|
||||
// });
|
||||
// _popupEntry?.remove();
|
||||
// _popupEntry = null;
|
||||
// // Get.toNamed("/deviceDetail", arguments: widget.device);
|
||||
// Get.toNamed("/messageSettingPage", arguments: widget.device);
|
||||
// // TopSlideNotification.show(context, text: "待开发功能".tr);
|
||||
// },
|
||||
// ),
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// 是否有基础操作权限(除 WIFI 外)
|
||||
bool hasBasePermission =
|
||||
widget.device['bind_type'] == BindType.active.code &&
|
||||
!AppConstants.is_test_account;
|
||||
|
||||
// 是否有 WIFI 权限
|
||||
bool hasWifiPermission = getWifiPermissionByOpType(widget.device);
|
||||
|
||||
// WIFI 配置 —— 单独判断
|
||||
if (hasBasePermission || hasWifiPermission) {
|
||||
if (hasWifiPermission) {
|
||||
items.add(
|
||||
_buildMenuItem(
|
||||
text: "WIFI配置".tr,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_isPopupOpen = false;
|
||||
});
|
||||
_popupEntry?.remove();
|
||||
_popupEntry = null;
|
||||
dealWifi(widget.device);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 下面这些 **只受 hasBasePermission 影响**
|
||||
if (hasBasePermission) {
|
||||
items.addAll([
|
||||
_buildMenuItem(
|
||||
text: "设备校准".tr,
|
||||
onTap: () async {
|
||||
setState(() {
|
||||
_isPopupOpen = false;
|
||||
});
|
||||
_popupEntry?.remove();
|
||||
_popupEntry = null;
|
||||
BlueteethBindController blueteethBindController = Get.find();
|
||||
blueteethBindController.currentDeviceMac?.value =
|
||||
widget.device['mac'];
|
||||
await Get.toNamed("/calibrationPersonPage", arguments: 2);
|
||||
},
|
||||
),
|
||||
_buildMenuItem(
|
||||
text: "分享设备".tr,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_isPopupOpen = false;
|
||||
});
|
||||
_popupEntry?.remove();
|
||||
_popupEntry = null;
|
||||
Get.toNamed("/deviceSharePage", arguments: widget.device);
|
||||
},
|
||||
),
|
||||
_buildMenuItem(
|
||||
text: "消息设置".tr,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_isPopupOpen = false;
|
||||
});
|
||||
_popupEntry?.remove();
|
||||
_popupEntry = null;
|
||||
Get.toNamed("/messageSettingPage", arguments: widget.device);
|
||||
},
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
items.addAll([
|
||||
@@ -1620,4 +1694,12 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
personController.updateAll();
|
||||
}
|
||||
}
|
||||
|
||||
getWifiPermissionByOpType(Map<String, dynamic> device) {
|
||||
int opType = device['op_type'] ?? 2;
|
||||
if (opType != null && opType == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user