更新
This commit is contained in:
@@ -24,10 +24,25 @@ class _DeviceShareInfoWidgetState extends State<DeviceShareInfoWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool selected = false;
|
||||
final key = deviceShareListController.model.accountKey;
|
||||
|
||||
final matchedValues = [];
|
||||
for (final item in widget.data) {
|
||||
if (item is Map && item.containsKey(key)) {
|
||||
final value = item[key];
|
||||
if (value != null) {
|
||||
final strValue = value.toString();
|
||||
if (strValue.isNotEmpty) {
|
||||
matchedValues.add(strValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ClickableContainer(
|
||||
backgroundColor: themeController.currentColor.sc5,
|
||||
highlightColor: themeController.currentColor.sc3,
|
||||
highlightColor: themeController.currentColor.sc4,
|
||||
borderRadius: 20.rpx,
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0.rpx, 33.rpx, 0.rpx, 33.rpx),
|
||||
onTap: () {},
|
||||
@@ -35,6 +50,11 @@ class _DeviceShareInfoWidgetState extends State<DeviceShareInfoWidget> {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Obx(() {
|
||||
// 判断当前项是否被选中
|
||||
var aa = deviceShareListController.selectedShareInfo;
|
||||
print(aa);
|
||||
final isSelected = matchedValues.any((v) =>
|
||||
deviceShareListController.selectedShareInfo.value.contains(v));
|
||||
return Theme(
|
||||
data: ThemeData(
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
@@ -47,18 +67,52 @@ class _DeviceShareInfoWidgetState extends State<DeviceShareInfoWidget> {
|
||||
unselectedWidgetColor: Color(0xFFD3D3D3),
|
||||
),
|
||||
child: Checkbox(
|
||||
value: deviceShareListController.selectedShareInfo.value
|
||||
.contains(widget.data[0]['k']),
|
||||
value: isSelected,
|
||||
onChanged: (newValue) async {
|
||||
if (newValue != null) {
|
||||
if (newValue == true) {
|
||||
deviceShareListController.selectedShareInfo.value
|
||||
.add(widget.data[0]['k']);
|
||||
} else {
|
||||
deviceShareListController.selectedShareInfo.value
|
||||
.remove(widget.data[0]['k']);
|
||||
final key = deviceShareListController.model.accountKey;
|
||||
// 提取包含指定 key 的 value
|
||||
final List<String> matchedValues = [];
|
||||
for (final item in widget.data) {
|
||||
if (item is Map && item.containsKey(key)) {
|
||||
final value = item[key];
|
||||
if (value != null) {
|
||||
final strValue = value.toString();
|
||||
if (strValue.isNotEmpty) {
|
||||
matchedValues.add(strValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newValue == true) {
|
||||
// 添加匹配值到已选列表中(避免重复)
|
||||
for (final v in matchedValues) {
|
||||
if (!deviceShareListController.selectedShareInfo.value
|
||||
.contains(v)) {
|
||||
deviceShareListController.selectedShareInfo.value
|
||||
.add(v);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 从已选列表中移除匹配值
|
||||
deviceShareListController.selectedShareInfo.value
|
||||
.removeWhere((v) => matchedValues.contains(v));
|
||||
}
|
||||
|
||||
// 刷新 UI 和全选状态
|
||||
final selectedCount =
|
||||
deviceShareListController.selectedShareInfo.length;
|
||||
final totalCount =
|
||||
deviceShareListController.shareInfoList.length;
|
||||
|
||||
deviceShareListController.model.all =
|
||||
(selectedCount == totalCount) ? 1 : 0;
|
||||
|
||||
deviceShareListController.selectedShareInfo.refresh();
|
||||
deviceShareListController.updateAll();
|
||||
}
|
||||
|
||||
final selectedCount =
|
||||
deviceShareListController.selectedShareInfo.length;
|
||||
final totalCount =
|
||||
@@ -66,8 +120,7 @@ class _DeviceShareInfoWidgetState extends State<DeviceShareInfoWidget> {
|
||||
|
||||
deviceShareListController.model.all =
|
||||
(selectedCount == totalCount) ? 1 : 0;
|
||||
deviceShareListController.selectedShareInfo
|
||||
.refresh(); // ✅ 关键代码
|
||||
deviceShareListController.selectedShareInfo.refresh();
|
||||
deviceShareListController.updateAll();
|
||||
},
|
||||
side: BorderSide(
|
||||
@@ -91,22 +144,52 @@ class _DeviceShareInfoWidgetState extends State<DeviceShareInfoWidget> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: List.generate(widget.data.length, (index) {
|
||||
final item = widget.data[index];
|
||||
if (item is Map &&
|
||||
item.containsKey('show') &&
|
||||
item['show'] == false) {
|
||||
return Container();
|
||||
}
|
||||
return Container(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: 62.rpx,
|
||||
),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional(-1, 0),
|
||||
child: Text(
|
||||
"${item['k']}" + ":" + "${item['v']}",
|
||||
style:
|
||||
FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 105.rpx,
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional(-1, 0),
|
||||
child: Text(
|
||||
"${item['k']}",
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"${item['v']}",
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
].divide(SizedBox(
|
||||
width: 34.rpx,
|
||||
)),
|
||||
),
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/component/tool/cmd.dart';
|
||||
import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/model/BleDeviceData.dart';
|
||||
@@ -86,7 +85,8 @@ class _SingleBlueteethDeviceCompoentWidgetState
|
||||
TopSlideNotification.show(context, text: response.msg!);
|
||||
if (response.code == HttpStatusCodes.ok) {
|
||||
// showLoadingDialog(context); // 显示 loading
|
||||
Get.toNamed("/personPage");
|
||||
// Get.toNamed("/personPage");
|
||||
Get.toNamed("/wifiPage");
|
||||
THapp bledevice = THapp(device: widget.bleDevice.device);
|
||||
blueteethBindController.currentDevice = bledevice;
|
||||
// await bledevice.device.connect();
|
||||
|
||||
@@ -530,9 +530,9 @@ void showConfirmDialog(
|
||||
CustomCard(
|
||||
borderRadius: AppConstants().button_container_radius,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
onConfirm();
|
||||
// await Future.delayed(Duration(milliseconds: 300));
|
||||
Get.back();
|
||||
},
|
||||
colors: [
|
||||
themeController.currentColor.sc1,
|
||||
|
||||
Reference in New Issue
Block a user