更新
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user