223 lines
9.1 KiB
Dart
223 lines
9.1 KiB
Dart
import 'package:flutter/cupertino.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter/src/widgets/framework.dart';
|
||
import 'package:flutter/widgets.dart';
|
||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
import 'package:get/get.dart';
|
||
import 'package:starwork_flutter/common/constant/app_colors.dart';
|
||
import 'package:starwork_flutter/common/constant/app_images.dart';
|
||
import 'package:starwork_flutter/common/constant/app_view_parameter_keys.dart';
|
||
import 'package:starwork_flutter/common/widgets/custom_cell_list_widget.dart';
|
||
import 'package:starwork_flutter/common/widgets/custom_cell_widget.dart';
|
||
import 'package:starwork_flutter/common/widgets/custome_app_bar_wdiget.dart';
|
||
import 'package:starwork_flutter/extension/function_extension.dart';
|
||
import 'package:starwork_flutter/routes/app_routes.dart';
|
||
import 'package:starwork_flutter/views/device/deviceSetting/device_setting_controller.dart';
|
||
|
||
class DeviceSettingView extends GetView<DeviceSettingController> {
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
// 即使不使用,只是引用一下 controller 就能触发初始化
|
||
final _ = controller; // 添加这一行
|
||
|
||
return Scaffold(
|
||
appBar: CustomAppBarWidget(
|
||
title: '设置'.tr,
|
||
),
|
||
backgroundColor: AppColors.scaffoldBackgroundColor,
|
||
body: SafeArea(
|
||
child: Padding(
|
||
padding: EdgeInsets.symmetric(
|
||
horizontal: 10.w,
|
||
vertical: 10.h,
|
||
),
|
||
child: Column(
|
||
children: [
|
||
GestureDetector(
|
||
onTap: () {
|
||
Get.toNamed(AppRoutes.deviceBasisInfo, arguments: {
|
||
AppViewParameterKeys.lockInfo: controller.lockInfo?.toJson(),
|
||
});
|
||
},
|
||
child: Container(
|
||
decoration: BoxDecoration(
|
||
color: Colors.white,
|
||
borderRadius: BorderRadius.circular(8.r),
|
||
),
|
||
padding: EdgeInsets.symmetric(
|
||
horizontal: 10.w,
|
||
vertical: 10.h,
|
||
),
|
||
child: Row(
|
||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
Row(
|
||
children: [
|
||
Image(
|
||
image: const AssetImage(AppImages.iconLockTypeDoorLock),
|
||
width: 38.w,
|
||
height: 38.w,
|
||
fit: BoxFit.contain,
|
||
gaplessPlayback: true,
|
||
// 防止闪烁
|
||
filterQuality: FilterQuality.medium,
|
||
// 优化过滤质量
|
||
errorBuilder: (context, error, stackTrace) {
|
||
return Icon(
|
||
Icons.image_not_supported,
|
||
size: 26.sp,
|
||
color: Colors.grey,
|
||
);
|
||
},
|
||
),
|
||
SizedBox(
|
||
width: 10.w,
|
||
),
|
||
Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Obx(
|
||
() => Text(
|
||
controller.lockName.value,
|
||
style: TextStyle(
|
||
fontSize: 16.sp,
|
||
fontWeight: FontWeight.w400,
|
||
),
|
||
),
|
||
),
|
||
SizedBox(
|
||
height: 4.h,
|
||
),
|
||
Text(
|
||
'设备名称、序列号、版本等',
|
||
style: TextStyle(fontSize: 12.sp, fontWeight: FontWeight.w400, color: Colors.grey),
|
||
)
|
||
],
|
||
),
|
||
],
|
||
),
|
||
Icon(
|
||
Icons.arrow_forward_ios_rounded,
|
||
size: 16.sp,
|
||
color: Colors.grey,
|
||
)
|
||
],
|
||
),
|
||
),
|
||
),
|
||
SizedBox(
|
||
height: 10.h,
|
||
),
|
||
Obx(
|
||
() => CustomCellListWidget(
|
||
children: [
|
||
CustomCellWidget(
|
||
leftText: '远程开锁'.tr,
|
||
onTap: () {},
|
||
visible: controller.lockFeatureMap['remoteUnlock'] == 1 && controller.lockFeatureMap['wifi'] == 1,
|
||
rightWidget: Row(
|
||
crossAxisAlignment: CrossAxisAlignment.center,
|
||
children: [
|
||
CupertinoSwitch(
|
||
value: controller.lockSettingMap['remoteUnlock'] == 1,
|
||
onChanged: (bool value) {
|
||
controller.enableRemoteUnlock(value);
|
||
},
|
||
activeColor: Colors.blue, // 可选:打开时的颜色(iOS 默认为系统蓝色,可自定义)
|
||
trackColor: Colors.grey, // 可选:关闭时的背景轨道颜色
|
||
),
|
||
],
|
||
),
|
||
),
|
||
CustomCellWidget(
|
||
leftText: '网络配置'.tr,
|
||
onTap: () {
|
||
Get.toNamed(AppRoutes.deviceSearchNetwork, arguments: {
|
||
AppViewParameterKeys.lockInfo: controller.lockInfo?.toJson(),
|
||
});
|
||
},
|
||
visible: controller.lockFeatureMap['wifi'] == 1,
|
||
rightWidget: Row(
|
||
crossAxisAlignment: CrossAxisAlignment.center,
|
||
children: [
|
||
Icon(
|
||
Icons.arrow_forward_ios_rounded,
|
||
size: 16.sp,
|
||
color: Colors.grey,
|
||
)
|
||
],
|
||
),
|
||
),
|
||
CustomCellWidget(
|
||
leftText: '自动闭锁'.tr,
|
||
onTap: () {
|
||
Get.toNamed(AppRoutes.deviceSettingAutoCloseLock, arguments: {
|
||
AppViewParameterKeys.lockInfo: controller.lockInfo?.toJson(),
|
||
});
|
||
},
|
||
visible: controller.lockFeatureMap['autoLock'] == 1,
|
||
rightWidget: Row(
|
||
crossAxisAlignment: CrossAxisAlignment.center,
|
||
children: [
|
||
Icon(
|
||
Icons.arrow_forward_ios_rounded,
|
||
size: 16.sp,
|
||
color: Colors.grey,
|
||
)
|
||
],
|
||
),
|
||
),
|
||
CustomCellWidget(
|
||
leftText: '音量设置'.tr,
|
||
onTap: () {
|
||
Get.toNamed(AppRoutes.deviceSettingVolumeSetting, arguments: {
|
||
AppViewParameterKeys.lockInfo: controller.lockInfo?.toJson(),
|
||
});
|
||
},
|
||
visible: controller.lockFeatureMap['autoLock'] == 1,
|
||
rightWidget: Row(
|
||
crossAxisAlignment: CrossAxisAlignment.center,
|
||
children: [
|
||
Icon(
|
||
Icons.arrow_forward_ios_rounded,
|
||
size: 16.sp,
|
||
color: Colors.grey,
|
||
)
|
||
],
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
SizedBox(
|
||
height: 10.h,
|
||
),
|
||
SizedBox(
|
||
width: double.infinity,
|
||
child: ElevatedButton(
|
||
onPressed: () {
|
||
controller.removeDevice();
|
||
}.debounce(),
|
||
style: ElevatedButton.styleFrom(
|
||
backgroundColor: Colors.red,
|
||
padding: EdgeInsets.symmetric(vertical: 12.h),
|
||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.r)),
|
||
),
|
||
child: Text(
|
||
'删除设备'.tr,
|
||
style: TextStyle(
|
||
fontSize: 16.sp,
|
||
color: Colors.white,
|
||
fontWeight: FontWeight.w500,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
}
|