import 'package:get/get.dart'; class HardwareDetectionState { /// *** 数据层状态 *** /// /// 数据层状态是指在 [Controller] 中的状态,用于控制数据的获取和存储。 /// 设备列表 List _deviceList = []; set deviceList(List value) => _deviceList = value; List get deviceList => _deviceList; /// *** UI 层状态 *** /// /// UI 层状态是指在 [View] 中的状态,用于控制页面的显示效果。 /// UI 层状态通常是通过 [Rx] 类型的变量来实现的。 /// 摄像头初始化完成 RxBool _isDisplayCameraWindow = RxBool(false); /// 扬声器初始化完成 RxBool _isDisplaySpeakerWave = RxBool(false); /// 麦克风初始化完成 RxBool _isDisplayMicrophoneWave = RxBool(false); /// 摄像头列表 RxList _cameraList = RxList([]); /// 麦克风列表 RxList _microphoneList = RxList([]); /// 扬声器列表 RxList _speakerList = RxList([]); /// 当前选中的摄像头 Rx _currentCamera = Rx(null); /// 当前选中的麦克风 Rx _currentMicrophone = Rx(null); /// 当前选中的扬声器 Rx _currentSpeaker = Rx(null); /// 当前摄像头可用性 Rx _cameraAvailable = Rx(null); /// 当前麦克风可用性 Rx _microphoneAvailable = Rx(null); /// 当前扬声器可用性 Rx _speakerAvailable = Rx(null); /// 是否正在检测摄像头 RxBool _detectingCamera = RxBool(false); /// 是否正在检测麦克风 RxBool _detectingMicrophone = RxBool(false); /// 是否正在检测扬声器 RxBool _detectingSpeaker = RxBool(false); set isDisplayMicrophoneWave(bool value) => _isDisplayMicrophoneWave.value = value; bool get isDisplayMicrophoneWave => _isDisplayMicrophoneWave.value; set isDisplaySpeakerWave(bool value) => _isDisplaySpeakerWave.value = value; bool get isDisplaySpeakerWave => _isDisplaySpeakerWave.value; set isDisplayCameraWindow(bool value) => _isDisplayCameraWindow.value = value; bool get isDisplayCameraWindow => _isDisplayCameraWindow.value; set cameraList(List value) => _cameraList.value = value; List get cameraList => _cameraList; set currentCamera(HardwareDevice? value) => _currentCamera = Rx(value); HardwareDevice? get currentCamera => _currentCamera.value; set microphoneList(List value) => _microphoneList.value = value; List get microphoneList => _microphoneList; set currentMicrophone(HardwareDevice? value) => _currentMicrophone = Rx(value); HardwareDevice? get currentMicrophone => _currentMicrophone.value; set speakerList(List value) => _speakerList.value = value; List get speakerList => _speakerList; set currentSpeaker(HardwareDevice? value) => _currentSpeaker = Rx(value); HardwareDevice? get currentSpeaker => _currentSpeaker.value; set cameraAvailable(bool? value) => _cameraAvailable.value = value; bool? get cameraAvailable => _cameraAvailable.value; set microphoneAvailable(bool? value) => _microphoneAvailable.value = value; bool? get microphoneAvailable => _microphoneAvailable.value; set speakerAvailable(bool? value) => _speakerAvailable.value = value; bool? get speakerAvailable => _speakerAvailable.value; set detectingCamera(bool value) => _detectingCamera.value = value; bool get detectingCamera => _detectingCamera.value; set detectingMicrophone(bool value) => _detectingMicrophone.value = value; bool get detectingMicrophone => _detectingMicrophone.value; set detectingSpeaker(bool value) => _detectingSpeaker.value = value; bool get detectingSpeaker => _detectingSpeaker.value; } class HardwareDevice { /// 设备名称 String name; /// 设备id String id; /// 设备类型 HardwareDeviceType type; HardwareDevice({required this.name, required this.id, required this.type}); } enum HardwareDeviceType { /// 摄像头 camera, /// 扬声器 speaker, /// 麦克风 microphone, }