feat: 增加自动闭锁、音量设置对应的页面和设置流程
This commit is contained in:
parent
3cc225c762
commit
e09eddd6f5
@ -1,3 +1,9 @@
|
|||||||
class LockFunctionNumber {
|
class LockFunctionNumber {
|
||||||
static const int remoteUnlocking = 28;
|
static const int remoteUnlocking = 28;
|
||||||
|
static const int autoCloseLock = 29;
|
||||||
|
static const int antiPrySwitch = 30;
|
||||||
|
static const int resetSwitch = 31;
|
||||||
|
static const int lockSwitch = 32;
|
||||||
|
static const int volumeSetting = 33;
|
||||||
|
static const int normallyOpenMode = 50;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,8 +10,12 @@ import 'package:starwork_flutter/views/device/deviceManage/device_manage_binding
|
|||||||
import 'package:starwork_flutter/views/device/deviceManage/device_manage_view.dart';
|
import 'package:starwork_flutter/views/device/deviceManage/device_manage_view.dart';
|
||||||
import 'package:starwork_flutter/views/device/deviceSearchNetwork/device_search_network_binding.dart';
|
import 'package:starwork_flutter/views/device/deviceSearchNetwork/device_search_network_binding.dart';
|
||||||
import 'package:starwork_flutter/views/device/deviceSearchNetwork/device_search_network_view.dart';
|
import 'package:starwork_flutter/views/device/deviceSearchNetwork/device_search_network_view.dart';
|
||||||
|
import 'package:starwork_flutter/views/device/deviceSetting/autoCloseLock/auto_close_lock_binding.dart';
|
||||||
|
import 'package:starwork_flutter/views/device/deviceSetting/autoCloseLock/auto_close_lock_view.dart';
|
||||||
import 'package:starwork_flutter/views/device/deviceSetting/device_setting_binding.dart';
|
import 'package:starwork_flutter/views/device/deviceSetting/device_setting_binding.dart';
|
||||||
import 'package:starwork_flutter/views/device/deviceSetting/device_setting_view.dart';
|
import 'package:starwork_flutter/views/device/deviceSetting/device_setting_view.dart';
|
||||||
|
import 'package:starwork_flutter/views/device/deviceSetting/volumeSetting/volume_setting_binding.dart';
|
||||||
|
import 'package:starwork_flutter/views/device/deviceSetting/volumeSetting/volume_setting_view.dart';
|
||||||
import 'package:starwork_flutter/views/device/removeDevice/remove_device_binding.dart';
|
import 'package:starwork_flutter/views/device/removeDevice/remove_device_binding.dart';
|
||||||
import 'package:starwork_flutter/views/device/removeDevice/remove_device_view.dart';
|
import 'package:starwork_flutter/views/device/removeDevice/remove_device_view.dart';
|
||||||
import 'package:starwork_flutter/views/device/searchDevice/search_device_binding.dart';
|
import 'package:starwork_flutter/views/device/searchDevice/search_device_binding.dart';
|
||||||
@ -165,5 +169,15 @@ class AppPages {
|
|||||||
page: () => DeviceBasisInfoView(),
|
page: () => DeviceBasisInfoView(),
|
||||||
binding: DeviceBasisInfoBinding(),
|
binding: DeviceBasisInfoBinding(),
|
||||||
),
|
),
|
||||||
|
GetPage(
|
||||||
|
name: AppRoutes.deviceSettingAutoCloseLock,
|
||||||
|
page: () => AutoCloseLockView(),
|
||||||
|
binding: AutoCloseLockBinding(),
|
||||||
|
),
|
||||||
|
GetPage(
|
||||||
|
name: AppRoutes.deviceSettingVolumeSetting,
|
||||||
|
page: () => VolumeSettingView(),
|
||||||
|
binding: VolumeSettingBinding(),
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,4 +23,6 @@ class AppRoutes{
|
|||||||
static const String deviceConfigureNetwork = '/device/configureNetwork';
|
static const String deviceConfigureNetwork = '/device/configureNetwork';
|
||||||
static const String deviceSetting = '/device/deviceSetting';
|
static const String deviceSetting = '/device/deviceSetting';
|
||||||
static const String deviceBasisInfo = '/device/deviceBasisInfo';
|
static const String deviceBasisInfo = '/device/deviceBasisInfo';
|
||||||
|
static const String deviceSettingAutoCloseLock = '/device/deviceSetting/autoCloseLock';
|
||||||
|
static const String deviceSettingVolumeSetting = '/device/deviceSetting/volumeSetting';
|
||||||
}
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:starwork_flutter/views/device/deviceSetting/autoCloseLock/auto_close_lock_controller.dart';
|
||||||
|
|
||||||
|
class AutoCloseLockBinding implements Bindings {
|
||||||
|
@override
|
||||||
|
void dependencies() {
|
||||||
|
Get.lazyPut(() => AutoCloseLockController());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,100 @@
|
|||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:starcloud/entity/star_cloud_lock_list.dart';
|
||||||
|
import 'package:starcloud/net/entity/api_response.dart';
|
||||||
|
import 'package:starcloud/sdk/entity/entity_sender/auto_close_lock_config.dart';
|
||||||
|
import 'package:starcloud/sdk/entity/entity_sender/enable_lock_settings.dart';
|
||||||
|
import 'package:starcloud/sdk/sdk_lock_setting_operate_extension.dart';
|
||||||
|
import 'package:starcloud/sdk/starcloud.dart';
|
||||||
|
import 'package:starwork_flutter/base/app_logger.dart';
|
||||||
|
import 'package:starwork_flutter/base/base_controller.dart';
|
||||||
|
import 'package:starwork_flutter/common/constant/app_view_parameter_keys.dart';
|
||||||
|
import 'package:starwork_flutter/common/constant/lock_function_number.dart';
|
||||||
|
|
||||||
|
class AutoCloseLockController extends BaseController {
|
||||||
|
// 锁信息
|
||||||
|
StarCloudLock? lockInfo;
|
||||||
|
|
||||||
|
// 定义一个可观察的 Map
|
||||||
|
final lockFeatureMap = <String, dynamic>{}.obs;
|
||||||
|
final lockSettingMap = <String, dynamic>{}.obs;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onReady() {
|
||||||
|
super.onReady();
|
||||||
|
|
||||||
|
// 读取参数
|
||||||
|
final args = Get.arguments;
|
||||||
|
if (args != null && args.containsKey(AppViewParameterKeys.lockInfo)) {
|
||||||
|
final json = args[AppViewParameterKeys.lockInfo];
|
||||||
|
lockInfo = StarCloudLock.fromJson(json, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
_readLockSetting();
|
||||||
|
_readLockFeature();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _readLockSetting() async {
|
||||||
|
showLoading();
|
||||||
|
await StarCloudSDK.instance.readLockSetting(
|
||||||
|
lockId: lockInfo?.lockId ?? 0,
|
||||||
|
onSuccess: (response) {
|
||||||
|
if (response is ApiResponse) {
|
||||||
|
final resultData = response as ApiResponse;
|
||||||
|
if (resultData.isSuccess) {
|
||||||
|
lockSettingMap.value = resultData.data['lockSetting'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hideLoading();
|
||||||
|
},
|
||||||
|
onError: (err) {
|
||||||
|
AppLogger.error('读取锁设置失败:${err}');
|
||||||
|
hideLoading();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _readLockFeature() async {
|
||||||
|
showLoading();
|
||||||
|
await StarCloudSDK.instance.readLockFeature(
|
||||||
|
lockId: lockInfo?.lockId ?? 0,
|
||||||
|
onSuccess: (response) {
|
||||||
|
if (response is ApiResponse) {
|
||||||
|
final resultData = response as ApiResponse;
|
||||||
|
if (resultData.isSuccess) {
|
||||||
|
lockFeatureMap.value = resultData.data['lockFeature'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hideLoading();
|
||||||
|
},
|
||||||
|
onError: (err) {
|
||||||
|
AppLogger.error('读取锁设置失败:${err}');
|
||||||
|
hideLoading();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateLockSetting({
|
||||||
|
required bool isOpen,
|
||||||
|
required int second,
|
||||||
|
}) async {
|
||||||
|
showLoading();
|
||||||
|
await StarCloudSDK.instance.updateLockSetting(
|
||||||
|
lockId: lockInfo?.lockId ?? 0,
|
||||||
|
lockSettings: EnableLockSettings(
|
||||||
|
featureBit: LockFunctionNumber.autoCloseLock,
|
||||||
|
featureEnable: isOpen,
|
||||||
|
parameter: AutoCloseLockConfig(
|
||||||
|
autoCloseLockSecond: second,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSuccess: () {
|
||||||
|
_readLockSetting();
|
||||||
|
hideLoading();
|
||||||
|
},
|
||||||
|
onError: (err) {
|
||||||
|
AppLogger.error('开启/关闭自动闭锁失败:${err}');
|
||||||
|
hideLoading();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,139 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/src/widgets/framework.dart';
|
||||||
|
import 'package:flutter_picker/flutter_picker.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:starwork_flutter/common/constant/app_colors.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/views/device/deviceSetting/autoCloseLock/auto_close_lock_controller.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
class AutoCloseLockView extends GetView<AutoCloseLockController> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppColors.scaffoldBackgroundColor,
|
||||||
|
appBar: CustomAppBarWidget(title: '自动闭锁设置'.tr),
|
||||||
|
body: SafeArea(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.h),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Obx(
|
||||||
|
() => CustomCellListWidget(
|
||||||
|
children: [
|
||||||
|
CustomCellWidget(
|
||||||
|
leftText: '自动闭锁'.tr,
|
||||||
|
onTap: () {},
|
||||||
|
rightWidget: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
CupertinoSwitch(
|
||||||
|
value: controller.lockSettingMap['autoLock'] == 1,
|
||||||
|
onChanged: (bool value) {
|
||||||
|
controller.updateLockSetting(
|
||||||
|
isOpen: value,
|
||||||
|
second: controller.lockSettingMap['autoLockSecond'] == 0
|
||||||
|
? 5
|
||||||
|
: controller.lockSettingMap['autoLockSecond'],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
activeColor: Colors.blue, // 可选:打开时的颜色(iOS 默认为系统蓝色,可自定义)
|
||||||
|
trackColor: Colors.grey, // 可选:关闭时的背景轨道颜色
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
CustomCellWidget(
|
||||||
|
leftText: '自动闭锁'.tr,
|
||||||
|
onTap: () {
|
||||||
|
showNumberPicker(context);
|
||||||
|
},
|
||||||
|
visible: controller.lockSettingMap['autoLock'] == 1,
|
||||||
|
rightWidget: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
controller.lockSettingMap['autoLockSecond'].toString() + ' 秒'.tr,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14.sp,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: Colors.black87,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Icon(
|
||||||
|
Icons.arrow_forward_ios_rounded,
|
||||||
|
size: 16.sp,
|
||||||
|
color: Colors.grey,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10.h,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'设定时间后锁将自动关闭,开启或修改设置后,请手动开一次锁使设置生效'.tr,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12.sp,
|
||||||
|
color: Colors.grey,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void showNumberPicker(BuildContext context) {
|
||||||
|
Picker(
|
||||||
|
height: 0.3.sh,
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 16.sp,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
confirmText: '确认'.tr,
|
||||||
|
cancelText: '取消'.tr,
|
||||||
|
itemExtent: 0.05.sh,
|
||||||
|
selectedTextStyle: TextStyle(
|
||||||
|
fontSize: 18.sp,
|
||||||
|
color: Colors.blue,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
confirmTextStyle: TextStyle(
|
||||||
|
fontSize: 16.sp,
|
||||||
|
color: Colors.blue,
|
||||||
|
),
|
||||||
|
cancelTextStyle: TextStyle(
|
||||||
|
fontSize: 16.sp,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
headerColor: Colors.white,
|
||||||
|
adapter: NumberPickerAdapter(
|
||||||
|
data: [
|
||||||
|
NumberPickerColumn(
|
||||||
|
begin: 5,
|
||||||
|
end: 120,
|
||||||
|
jump: 5,
|
||||||
|
initValue:
|
||||||
|
controller.lockSettingMap['autoLockSecond'] == 0 ? 5 : controller.lockSettingMap['autoLockSecond']),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
title: Text('选择时间'.tr),
|
||||||
|
onConfirm: (Picker picker, List<int> value) {
|
||||||
|
controller.updateLockSetting(
|
||||||
|
isOpen: true,
|
||||||
|
second: picker.getSelectedValues()[0],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).showModal(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -114,7 +114,7 @@ class DeviceSettingView extends GetView<DeviceSettingController> {
|
|||||||
CustomCellWidget(
|
CustomCellWidget(
|
||||||
leftText: '远程开锁'.tr,
|
leftText: '远程开锁'.tr,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
visible: controller.lockFeatureMap['remoteUnlock'] == 1,
|
visible: controller.lockFeatureMap['remoteUnlock'] == 1 && controller.lockFeatureMap['wifi'] == 1,
|
||||||
rightWidget: Row(
|
rightWidget: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -148,6 +148,44 @@ class DeviceSettingView extends GetView<DeviceSettingController> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
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,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:starwork_flutter/views/device/deviceSetting/volumeSetting/volume_setting_controller.dart';
|
||||||
|
|
||||||
|
class VolumeSettingBinding extends Bindings {
|
||||||
|
@override
|
||||||
|
void dependencies() {
|
||||||
|
Get.lazyPut(() => VolumeSettingController());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,107 @@
|
|||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:starcloud/entity/star_cloud_lock_list.dart';
|
||||||
|
import 'package:starcloud/net/entity/api_response.dart';
|
||||||
|
import 'package:starcloud/sdk/entity/entity_sender/enable_lock_settings.dart';
|
||||||
|
import 'package:starcloud/sdk/entity/entity_sender/lock_sound_config.dart';
|
||||||
|
import 'package:starcloud/sdk/sdk_lock_setting_operate_extension.dart';
|
||||||
|
import 'package:starcloud/sdk/starcloud.dart';
|
||||||
|
import 'package:starwork_flutter/base/app_logger.dart';
|
||||||
|
import 'package:starwork_flutter/base/base_controller.dart';
|
||||||
|
import 'package:starwork_flutter/common/constant/app_view_parameter_keys.dart';
|
||||||
|
import 'package:starwork_flutter/common/constant/lock_function_number.dart';
|
||||||
|
|
||||||
|
class VolumeSettingController extends BaseController {
|
||||||
|
// 锁信息
|
||||||
|
StarCloudLock? lockInfo;
|
||||||
|
|
||||||
|
// 定义一个可观察的 Map
|
||||||
|
final lockFeatureMap = <String, dynamic>{}.obs;
|
||||||
|
final lockSettingMap = <String, dynamic>{}.obs;
|
||||||
|
|
||||||
|
// 当前选中的音量等级索引(默认 -1 未选,或 2 表示“中”)
|
||||||
|
final selectedVolumeIndex = (-1).obs; // 使用 RxInt
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onReady() {
|
||||||
|
super.onReady();
|
||||||
|
|
||||||
|
// 读取参数
|
||||||
|
final args = Get.arguments;
|
||||||
|
if (args != null && args.containsKey(AppViewParameterKeys.lockInfo)) {
|
||||||
|
final json = args[AppViewParameterKeys.lockInfo];
|
||||||
|
lockInfo = StarCloudLock.fromJson(json, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
_readLockSetting();
|
||||||
|
_readLockFeature();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _readLockSetting() async {
|
||||||
|
showLoading();
|
||||||
|
await StarCloudSDK.instance.readLockSetting(
|
||||||
|
lockId: lockInfo?.lockId ?? 0,
|
||||||
|
onSuccess: (response) {
|
||||||
|
if (response is ApiResponse) {
|
||||||
|
final resultData = response as ApiResponse;
|
||||||
|
if (resultData.isSuccess) {
|
||||||
|
lockSettingMap.value = resultData.data['lockSetting'];
|
||||||
|
selectedVolumeIndex.value = (lockSettingMap['lockSoundVolume'] - 1) ?? 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hideLoading();
|
||||||
|
},
|
||||||
|
onError: (err) {
|
||||||
|
AppLogger.error('读取锁设置失败:${err}');
|
||||||
|
hideLoading();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _readLockFeature() async {
|
||||||
|
showLoading();
|
||||||
|
await StarCloudSDK.instance.readLockFeature(
|
||||||
|
lockId: lockInfo?.lockId ?? 0,
|
||||||
|
onSuccess: (response) {
|
||||||
|
if (response is ApiResponse) {
|
||||||
|
final resultData = response as ApiResponse;
|
||||||
|
if (resultData.isSuccess) {
|
||||||
|
lockFeatureMap.value = resultData.data['lockFeature'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hideLoading();
|
||||||
|
},
|
||||||
|
onError: (err) {
|
||||||
|
AppLogger.error('读取锁设置失败:${err}');
|
||||||
|
hideLoading();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateLockSetting({
|
||||||
|
required bool isOpen,
|
||||||
|
required int volumeLevel,
|
||||||
|
}) async {
|
||||||
|
showLoading();
|
||||||
|
await StarCloudSDK.instance.updateLockSetting(
|
||||||
|
lockId: lockInfo?.lockId ?? 0,
|
||||||
|
lockSettings: EnableLockSettings(
|
||||||
|
featureBit: LockFunctionNumber.volumeSetting,
|
||||||
|
featureEnable: isOpen,
|
||||||
|
parameter: LockSoundConfig(lockSoundVolume: isOpen ? volumeLevel : 1),
|
||||||
|
),
|
||||||
|
onSuccess: () {
|
||||||
|
_readLockSetting();
|
||||||
|
hideLoading();
|
||||||
|
},
|
||||||
|
onError: (err) {
|
||||||
|
AppLogger.error('开启/关闭 锁声音设置失败:${err}');
|
||||||
|
hideLoading();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateVolumeSelection(int index) {
|
||||||
|
selectedVolumeIndex.value = index;
|
||||||
|
updateLockSetting(isOpen: true, volumeLevel: selectedVolumeIndex.value + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,101 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/src/widgets/framework.dart';
|
||||||
|
import 'package:flutter_picker/flutter_picker.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/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/views/device/deviceSetting/device_setting_controller.dart';
|
||||||
|
import 'package:starwork_flutter/views/device/deviceSetting/volumeSetting/volume_setting_controller.dart';
|
||||||
|
|
||||||
|
class VolumeSettingView extends GetView<VolumeSettingController> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppColors.scaffoldBackgroundColor,
|
||||||
|
appBar: CustomAppBarWidget(
|
||||||
|
title: '音量设置'.tr,
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 10.w,
|
||||||
|
vertical: 10.h,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Obx(
|
||||||
|
() => CustomCellListWidget(
|
||||||
|
children: [
|
||||||
|
CustomCellWidget(
|
||||||
|
leftText: '锁声音'.tr,
|
||||||
|
onTap: () {},
|
||||||
|
rightWidget: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
CupertinoSwitch(
|
||||||
|
value: controller.lockSettingMap['lockSound'] == 1,
|
||||||
|
onChanged: (bool value) {
|
||||||
|
controller.updateLockSetting(
|
||||||
|
isOpen: value,
|
||||||
|
volumeLevel: controller.lockSettingMap['lockSoundVolume'] == 0
|
||||||
|
? 4
|
||||||
|
: controller.lockSettingMap['lockSoundVolume'],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
activeColor: Colors.blue, // 可选:打开时的颜色(iOS 默认为系统蓝色,可自定义)
|
||||||
|
trackColor: Colors.grey, // 可选:关闭时的背景轨道颜色
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (controller.lockSettingMap['lockSound'] == 1) ..._buildOptions(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10.h,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'关闭锁声音后任会保留部分基础语音'.tr,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12.sp,
|
||||||
|
color: Colors.grey,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_buildOptions() {
|
||||||
|
List<String> options = ['低'.tr, '较低'.tr, '中'.tr, '较高'.tr, '高'.tr];
|
||||||
|
|
||||||
|
return options.asMap().entries.map((entry) {
|
||||||
|
int index = entry.key;
|
||||||
|
String label = entry.value;
|
||||||
|
return CustomCellWidget(
|
||||||
|
leftText: label,
|
||||||
|
onTap: () {
|
||||||
|
controller.updateVolumeSelection(index);
|
||||||
|
},
|
||||||
|
rightWidget: SizedBox(
|
||||||
|
width: 18.w,
|
||||||
|
height: 18.w,
|
||||||
|
child: Radio<int>(
|
||||||
|
value: index,
|
||||||
|
groupValue: controller.selectedVolumeIndex.value, // 使用 Rx 值
|
||||||
|
onChanged: (int? value) {
|
||||||
|
controller.updateVolumeSelection(value!);
|
||||||
|
},
|
||||||
|
activeColor: Colors.blue, // 选中颜色
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -60,6 +60,8 @@ class MainController extends BaseController {
|
|||||||
/// 请求团队信息
|
/// 请求团队信息
|
||||||
requestAllTeamInfoList();
|
requestAllTeamInfoList();
|
||||||
|
|
||||||
|
/// 请求设备列表
|
||||||
|
_requestTeamDeviceList();
|
||||||
// 监听刷新设备列表事件
|
// 监听刷新设备列表事件
|
||||||
_refreshDeviceListSubscription = EventBusUtil().instance.on<RefreshDeviceListEvent>().listen((event) {
|
_refreshDeviceListSubscription = EventBusUtil().instance.on<RefreshDeviceListEvent>().listen((event) {
|
||||||
_requestTeamDeviceList();
|
_requestTeamDeviceList();
|
||||||
|
|||||||
@ -235,6 +235,14 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_picker:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_picker
|
||||||
|
sha256: "2f94c6eefba8697b07e3cd008b75f06b4ba7053cb26d23ae0fcd5932b7dc75af"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
flutter_screenutil:
|
flutter_screenutil:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -38,6 +38,8 @@ dependencies:
|
|||||||
super_tooltip: ^2.0.8
|
super_tooltip: ^2.0.8
|
||||||
# 事件总线
|
# 事件总线
|
||||||
event_bus: ^2.0.1
|
event_bus: ^2.0.1
|
||||||
|
# 选择器
|
||||||
|
flutter_picker: ^2.1.0
|
||||||
# 星云sdk
|
# 星云sdk
|
||||||
starcloud:
|
starcloud:
|
||||||
path: ../starcloud-sdk-flutter
|
path: ../starcloud-sdk-flutter
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user