import 'package:get/get.dart';
import 'package:vitalapp/architecture/defines.dart';
import 'package:vitalapp/managers/interfaces/device.dart';
import 'package:vitalapp/managers/interfaces/models/device.dart';

class DeviceController extends FControllerBase {
  final _deviceManager = Get.find<IDeviceManager>();

  Future<DeviceModel?> getDevice(String type) async {
    List<DeviceModel> devices = await _deviceManager.getDeviceList();

    return devices.firstWhereOrNull((element) => element.type == type);
  }

  /// 是否有设备权限
  Future<bool> isAccessTypeAuth(String type) async {
    List<String> accessTypes = await _deviceManager.getCacheAccessTypes();
    return accessTypes.contains(type);
  }
}
