This commit is contained in:
wyf
2025-06-06 09:23:23 +08:00
parent bc86cf7d78
commit 54ad7c18e6
7 changed files with 543 additions and 244 deletions

View File

@@ -300,5 +300,6 @@ class _DoubleBlueteethDeviceCompoentWidgetState
),
),
);
}
}

View File

@@ -53,206 +53,267 @@ class _SingleBlueteethDeviceCompoentWidgetState
return Container();
}
device = match;
return ClickableContainer(
backgroundColor: themeController.currentColor.sc5,
highlightColor: themeController.currentColor.sc21,
borderRadius: 20.rpx,
padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 36.rpx, 0, 52.rpx),
onTap: () async {
try {
//1.先判斷当前是否有别的设备处于连接中,没有处于连接,判断是否绑定;
//2.如果没有绑定,直接连接;如果绑定,弹出提示框,提示是否解绑
if (blueteethBindController.currentDeviceMac?.value != null &&
blueteethBindController.currentDeviceMac!.value.isNotEmpty) {
if (blueteethBindController.currentDeviceMac?.value != device.mac) {
showConfirmDialog(
context, Container(), "其他设备正在绑定中,是否终止其他设备绑定?".tr,
onConfirm: () {
blueteethBindController.currentDeviceMac.value = "";
blueteethBindController.updateAll();
}, onCancel: () {});
}
} else {
blueteethBindController.currentDeviceMac?.value = device.mac!;
blueteethBindController.updateAll();
}
if (device.bind == true) {
await showHaveBindDialog(context);
blueteethBindController.currentDeviceMac.value = "";
blueteethBindController.updateAll();
} else {
showConfirmDialog(
context,
Container(),
'蓝牙绑定.确定绑定提示'.tr,
onConfirm: () async {
ApiResponse response =
await blueteethBindController.bindDeviceAndMAC(device);
TopSlideNotification.show(context, text: response.msg!);
if (response.code == HttpStatusCodes.ok) {
//更新设备绑定流程
updateDeviceBindStatus(device);
Get.toNamed("/wifiPage");
THapp bledevice = THapp(device: widget.bleDevice.device);
blueteethBindController.currentDevice = bledevice;
// blueteethBindController.currentDeviceMac.value = "";
} else {
if (device.slave == null) {
return ClickableContainer(
backgroundColor: themeController.currentColor.sc5,
highlightColor: themeController.currentColor.sc21,
borderRadius: 20.rpx,
padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 36.rpx, 0, 52.rpx),
onTap: () async {
try {
//1.先判斷当前是否有别的设备处于连接中,没有处于连接,判断是否绑定
//2.如果没有绑定,直接连接;如果绑定,弹出提示框,提示是否解绑;
if (blueteethBindController.currentDeviceMac?.value != null &&
blueteethBindController.currentDeviceMac!.value.isNotEmpty) {
if (blueteethBindController.currentDeviceMac?.value !=
device.mac) {
showConfirmDialog(
context, Container(), "其他设备正在绑定中,是否终止其他设备绑定?".tr,
onConfirm: () {
blueteethBindController.currentDeviceMac.value = "";
blueteethBindController.updateAll();
TopSlideNotification.show(
context,
text: response.msg ?? "蓝牙绑定.连接异常".tr,
textColor: themeController.currentColor.sc9,
);
}
},
onCancel: () {
print('用户点击了取消');
blueteethBindController.currentDeviceMac.value = "";
blueteethBindController.updateAll();
},
}, onCancel: () {});
}
} else {
blueteethBindController.currentDeviceMac?.value = device.mac!;
blueteethBindController.updateAll();
}
if (device.bind == true) {
await showHaveBindDialog(context);
blueteethBindController.currentDeviceMac.value = "";
blueteethBindController.updateAll();
} else {
showConfirmDialog(
context,
Container(),
'蓝牙绑定.确定绑定提示'.tr,
onConfirm: () async {
ApiResponse response =
await blueteethBindController.bindDeviceAndMAC(device);
TopSlideNotification.show(context, text: response.msg!);
if (response.code == HttpStatusCodes.ok) {
//更新设备绑定流程
updateDeviceBindStatus(device);
Get.toNamed("/wifiPage");
THapp bledevice = THapp(device: widget.bleDevice.device);
blueteethBindController.currentDevice = bledevice;
// blueteethBindController.currentDeviceMac.value = "";
} else {
blueteethBindController.currentDeviceMac.value = "";
blueteethBindController.updateAll();
TopSlideNotification.show(
context,
text: response.msg ?? "蓝牙绑定.连接异常".tr,
textColor: themeController.currentColor.sc9,
);
}
},
onCancel: () {
print('用户点击了取消');
blueteethBindController.currentDeviceMac.value = "";
blueteethBindController.updateAll();
},
);
}
} catch (e) {
Navigator.pop(context);
TopSlideNotification.show(
context,
text: "蓝牙绑定.连接异常".tr,
textColor: themeController.currentColor.sc9,
);
edm.EasyDartModule.logger.info("蓝牙绑定.连接异常: $e");
DailyLogUtils.writeLog("蓝牙绑定.连接异常: $e");
}
} catch (e) {
Navigator.pop(context);
TopSlideNotification.show(
context,
text: "蓝牙绑定.连接异常".tr,
textColor: themeController.currentColor.sc9,
);
edm.EasyDartModule.logger.info("蓝牙绑定.连接异常: $e");
DailyLogUtils.writeLog("蓝牙绑定.连接异常: $e");
}
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
device.name ?? '蓝牙绑定.默认设备名称'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),
fontSize: 30.rpx,
letterSpacing: 0.0,
),
),
Obx(() {
if (blueteethBindController.currentDeviceMac.value ==
device.mac) {
return SizedBox(
width: 24.rpx,
height: 24.rpx,
child: CircularProgressIndicator(
strokeWidth: 1,
valueColor:
AlwaysStoppedAnimation<Color>(Colors.white),
),
);
}
return Container();
}),
],
),
),
Row(
children: [
Text(
device.name ?? '蓝牙绑定.默认设备名称'.tr,
"蓝牙绑定.信号强度".tr + '${device.rssi ?? '-'}dBm',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),
fontSize: 30.rpx,
color: const Color(0xFFEBF2F8),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
Obx(() {
if (blueteethBindController.currentDeviceMac.value ==
device.mac) {
return SizedBox(
width: 24.rpx,
height: 24.rpx,
child: CircularProgressIndicator(
strokeWidth: 1,
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
SizedBox(width: 40.rpx),
Text(
"蓝牙绑定.SN".tr + '${device.sn ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF5F9FD),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
);
}
return Container();
}),
),
],
),
),
Row(
children: [
Text(
"蓝牙绑定.信号强度".tr + '${device.rssi ?? '-'}dBm',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFEBF2F8),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
SizedBox(width: 40.rpx),
Text(
"蓝牙绑定.SN".tr + '${device.sn ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF5F9FD),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
],
),
Text(
"蓝牙绑定.蓝牙地址".tr + '${device.deviceId ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
Text(
"蓝牙绑定.mac".tr + '${device.mac ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
Row(
children: [
Text(
"蓝牙绑定.网络".tr +
'${device.isOnline == true ? '蓝牙绑定.在线'.tr : '蓝牙绑定.离线'.tr}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFEBF2F8),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
SizedBox(width: 145.rpx),
Row(
children: [
Text(
"蓝牙绑定.传感器".tr + "",
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFEBF2F8),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
Text(
"蓝牙绑定.蓝牙地址".tr + '${device.deviceId ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
Text(
device.bind == false ? '蓝牙绑定.可绑定'.tr : '蓝牙绑定.已被绑定'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: device.bind == false
? const Color(0xFF1AD2B5)
: themeController.currentColor.sc9,
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
Text(
"蓝牙绑定.mac".tr + '${device.mac ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
],
),
],
),
Text(
"版本".tr + '${device.version ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
Row(
children: [
Text(
"蓝牙绑定.网络".tr +
'${device.isOnline == true ? '蓝牙绑定.在线'.tr : '蓝牙绑定.离线'.tr}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFEBF2F8),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
),
].divide(SizedBox(height: 37.rpx)),
),
);
SizedBox(width: 145.rpx),
Row(
children: [
Text(
"蓝牙绑定.传感器".tr + "",
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFEBF2F8),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
Text(
device.bind == false ? '蓝牙绑定.可绑定'.tr : '蓝牙绑定.已被绑定'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: device.bind == false
? const Color(0xFF1AD2B5)
: themeController.currentColor.sc9,
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
],
),
],
),
Text(
"版本".tr + '${device.version ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
].divide(SizedBox(height: 37.rpx)),
),
);
} else {
List<BleDeviceData> devices = [];
devices.add(device);
devices.add(device.slave!);
return ClickableContainer(
backgroundColor: themeController.currentColor.sc5,
highlightColor: themeController.currentColor.sc21,
borderRadius: 20.rpx,
padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 36.rpx, 30.rpx, 52.rpx),
onTap: () async {
showBindDoubleDialog(
context,
devices,
onConfirm: (int selectedIndex) {
// selectedIndex 是 0全选或 1或 2
bool flag1 = devices[0].bind!;
bool flag2 = devices[1].bind!;
if (selectedIndex == 0) {
// 全选
if (flag1 == true || flag2 == true) {
showHaveBindDialog(context);
return;
} else {}
} else if (selectedIndex == 1) {
// 主
if (flag1 == true) {
showHaveBindDialog(context);
return;
} else {}
} else if (selectedIndex == 2) {
if (flag2 == true) {
showHaveBindDialog(context);
return;
} else {}
}
TopSlideNotification.show(context,text: "双人版绑定修复中");
print('选中了设备索引:$selectedIndex');
//配置wifi
},
onCancel: () {
print("用户取消绑定");
},
);
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
_buildDeviceInfoSection(device, context),
Divider(
thickness: 1.rpx,
color: themeController.currentColor.sc3,
),
_buildDeviceInfoSection(device.slave!, context),
].divide(SizedBox(height: 37.rpx)),
),
);
}
}
//更新设备绑定状态
@@ -280,4 +341,134 @@ class _SingleBlueteethDeviceCompoentWidgetState
onFailure: (res) {},
);
}
Widget _buildDeviceInfoSection(device, BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
device.name ?? '蓝牙绑定.默认设备名称'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),
fontSize: 30.rpx,
letterSpacing: 0.0,
),
),
Obx(() {
if (blueteethBindController.currentDeviceMac.value ==
device.mac) {
return SizedBox(
width: 24.rpx,
height: 24.rpx,
child: CircularProgressIndicator(
strokeWidth: 1,
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
),
);
}
return Container();
}),
],
),
),
Row(
children: [
Text(
"蓝牙绑定.信号强度".tr + '${device.rssi ?? '-'}dBm',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFEBF2F8),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
SizedBox(width: 40.rpx),
Text(
"蓝牙绑定.SN".tr + '${device.sn ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF5F9FD),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
],
),
Text(
"蓝牙绑定.蓝牙地址".tr + '${device.deviceId ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
Text(
"蓝牙绑定.mac".tr + '${device.mac ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
Row(
children: [
Text(
"蓝牙绑定.网络".tr +
'${device.isOnline == true ? '蓝牙绑定.在线'.tr : '蓝牙绑定.离线'.tr}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFEBF2F8),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
SizedBox(width: 145.rpx),
Row(
children: [
Text(
"蓝牙绑定.传感器".tr + "",
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFEBF2F8),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
Text(
device.bind == false ? '蓝牙绑定.可绑定'.tr : '蓝牙绑定.已被绑定'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: device.bind == false
? const Color(0xFF1AD2B5)
: themeController.currentColor.sc9,
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
],
),
],
),
Text(
"版本".tr + '${device.version ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
),
].divide(SizedBox(
height: 37.rpx,
)),
);
}
}

View File

@@ -14,10 +14,16 @@ import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
import 'package:vbvs_app/model/BleDeviceData.dart';
import 'package:vbvs_app/pages/device_bind/componnet/FancyCircleCheckbox.dart';
void showBindDoubleDialog(BuildContext context, List<BleDeviceData> devices) {
void showBindDoubleDialog(
BuildContext context,
List<BleDeviceData> devices, {
required void Function(int selectedIndex) onConfirm,
required VoidCallback onCancel,
}) {
ThemeController themeController = Get.find();
BlueteethBindController blueteethBindController = Get.find();
// 初始化默认选中 deviceIndex0 为 true
blueteethBindController.model.deviceIndex0 = true;
blueteethBindController.model.deviceIndex1 = false;
blueteethBindController.model.deviceIndex2 = false;
@@ -25,7 +31,7 @@ void showBindDoubleDialog(BuildContext context, List<BleDeviceData> devices) {
showDialog(
context: context,
barrierDismissible: true,
barrierColor: Colors.black.withOpacity(0.5), // 建议加个背景模糊色
barrierColor: Colors.black.withOpacity(0.5),
builder: (BuildContext context) {
return FrostedDialog(
blurSigma: 3.0,
@@ -34,7 +40,7 @@ void showBindDoubleDialog(BuildContext context, List<BleDeviceData> devices) {
color: themeController.currentColor.sc17,
borderRadius: BorderRadius.circular(20.0),
),
padding: EdgeInsetsDirectional.fromSTEB(60.rpx, 0, 60.rpx, 0),
padding: EdgeInsetsDirectional.fromSTEB(0.rpx, 0, 0.rpx, 0),
child: Container(
width: double.infinity,
constraints: BoxConstraints(
@@ -47,8 +53,7 @@ void showBindDoubleDialog(BuildContext context, List<BleDeviceData> devices) {
Align(
alignment: AlignmentDirectional(0, 0),
child: Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 93.rpx, 0, 0),
padding: EdgeInsetsDirectional.fromSTEB(0.rpx, 93.rpx, 0, 0),
child: Text(
'蓝牙绑定.双人版绑定标题'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
@@ -67,9 +72,9 @@ void showBindDoubleDialog(BuildContext context, List<BleDeviceData> devices) {
value: () => blueteethBindController.model.deviceIndex0!,
onChanged: (v) {
if (!blueteethBindController.model.deviceIndex0!) {
blueteethBindController.model.deviceIndex0 = v;
blueteethBindController.model.deviceIndex1 = !v;
blueteethBindController.model.deviceIndex2 = !v;
blueteethBindController.model.deviceIndex0 = true;
blueteethBindController.model.deviceIndex1 = false;
blueteethBindController.model.deviceIndex2 = false;
blueteethBindController.updateAll();
}
},
@@ -77,13 +82,15 @@ void showBindDoubleDialog(BuildContext context, List<BleDeviceData> devices) {
// 主设备
_buildCheckboxRow(
context,
title: '蓝牙绑定.主设备'.tr + "asasasasasas(已被绑定)",
title: '蓝牙绑定.主设备'.tr +
"${devices[0].mac}" +
(devices[0].bind == false ? "可绑定".tr : "已被绑定".tr),
value: () => blueteethBindController.model.deviceIndex1!,
onChanged: (v) {
if (!blueteethBindController.model.deviceIndex1!) {
blueteethBindController.model.deviceIndex1 = v;
blueteethBindController.model.deviceIndex0 = !v;
blueteethBindController.model.deviceIndex2 = !v;
blueteethBindController.model.deviceIndex0 = false;
blueteethBindController.model.deviceIndex1 = true;
blueteethBindController.model.deviceIndex2 = false;
blueteethBindController.updateAll();
}
},
@@ -91,36 +98,46 @@ void showBindDoubleDialog(BuildContext context, List<BleDeviceData> devices) {
// 从设备
_buildCheckboxRow(
context,
title: '蓝牙绑定.从设备'.tr,
title: '蓝牙绑定.从设备'.tr +
"${devices[1].mac}" +
(devices[1].bind == false ? "可绑定".tr : "已被绑定".tr),
value: () => blueteethBindController.model.deviceIndex2!,
onChanged: (v) {
if (!blueteethBindController.model.deviceIndex2!) {
blueteethBindController.model.deviceIndex2 = v;
blueteethBindController.model.deviceIndex0 = !v;
blueteethBindController.model.deviceIndex1 = !v;
blueteethBindController.model.deviceIndex0 = false;
blueteethBindController.model.deviceIndex1 = false;
blueteethBindController.model.deviceIndex2 = true;
blueteethBindController.updateAll();
}
},
),
// 确定按钮
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 100.rpx, 0, 0),
padding: EdgeInsetsDirectional.fromSTEB(60.rpx, 100.rpx, 60.rpx, 0),
child: _buildActionButton(
context,
text: '蓝牙绑定.确定'.tr,
onTap: () {
Get.back();
int selectedIndex = blueteethBindController.model.deviceIndex0!
? 0
: (blueteethBindController.model.deviceIndex1! ? 1 : 2);
onConfirm(selectedIndex);
},
),
),
// 取消按钮
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 19.rpx, 0, 60.rpx),
padding: EdgeInsetsDirectional.fromSTEB(60.rpx, 19.rpx, 60.rpx, 60.rpx),
child: _buildActionButton(
context,
text: '蓝牙绑定.取消'.tr,
onTap: () {
Get.back();
onCancel();
},
),
),
@@ -133,6 +150,7 @@ void showBindDoubleDialog(BuildContext context, List<BleDeviceData> devices) {
);
}
Future<void> showHaveBindDialog(BuildContext context) async {
ThemeController themeController = Get.find();
@@ -339,7 +357,7 @@ Widget _buildCheckboxRow(
}) {
ThemeController themeController = Get.find();
return Padding(
padding: EdgeInsetsDirectional.fromSTEB(20.rpx, 64.rpx, 0.rpx, 0.rpx),
padding: EdgeInsetsDirectional.fromSTEB(60.rpx, 64.rpx, 0.rpx, 0.rpx),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
@@ -350,14 +368,47 @@ Widget _buildCheckboxRow(
onChanged: onChanged,
)),
Expanded(
child: Text(
title,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
letterSpacing: 0.0,
fontSize: AppConstants().normal_text_fontSize,
color: themeController.currentColor.sc3,
child: Builder(
builder: (_) {
final bool isBindable = title.contains('可绑定'.tr);
final bool isBound = title.contains('已被绑定'.tr);
// 提取主文本部分
final String mainText =
title.replaceAll('可绑定'.tr, '').replaceAll('已被绑定'.tr, '');
return RichText(
text: TextSpan(
children: [
TextSpan(
text: mainText,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
letterSpacing: 0.0,
fontSize: AppConstants().normal_text_fontSize,
color: themeController.currentColor.sc3,
),
),
if (isBindable)
TextSpan(
text: "(" + '可绑定'.tr + ")",
style: TextStyle(
fontSize: AppConstants().normal_text_fontSize,
color: themeController.currentColor.sc1,
),
),
if (isBound)
TextSpan(
text: "(" + '已被绑定'.tr + ")",
style: TextStyle(
fontSize: AppConstants().normal_text_fontSize,
color: themeController.currentColor.sc9,
),
),
],
),
);
},
),
),
].divide(SizedBox(width: 21.rpx)),
@@ -374,10 +425,12 @@ Widget _buildActionButton(
return CustomCard(
borderRadius: AppConstants().button_container_radius,
onTap: onTap,
colors: [
themeController.currentColor.sc1,
themeController.currentColor.sc2,
],
colors: '蓝牙绑定.确定'.tr == text
? [
themeController.currentColor.sc1,
themeController.currentColor.sc2,
]
: [Colors.transparent],
child: Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height * 0.055,
@@ -385,6 +438,15 @@ Widget _buildActionButton(
minWidth: 500.rpx,
minHeight: 90.rpx,
),
decoration: '蓝牙绑定.确定'.tr == text
? BoxDecoration()
: BoxDecoration(
border: Border.all(
color: themeController.currentColor.sc3, // 你可以换成指定颜色
width: 1.0.rpx,
),
borderRadius: BorderRadius.circular(50.rpx), // 可选:加圆角
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,