123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import '../index.dart';
- import 'widgets.dart';
- /// 摄像头检测
- class CameraDetection extends GetView<HardwareDetectionController> {
- CameraDetection({Key? key}) : super(key: key);
- final smallTitleStyle = TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.bold,
- height: 1,
- );
- /// 副标题行高:[摄像头]、[麦克风]、[扬声器]
- static const _subTitleRowHright = 30.0;
- @override
- Widget build(BuildContext context) {
- return Container(
- width: 300,
- child: Column(
- children: [
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- width: 300,
- height: _subTitleRowHright,
- child: Row(
- children: [
- // Text("i18nBook.setting.camera.t", style: smallTitleStyle),
- Text("摄像头", style: smallTitleStyle),
- SizedBox(width: 10),
- Obx(() {
- if (controller.state.cameraAvailable == null)
- return Container();
- return controller.state.cameraAvailable!
- ? CommonWidgets.deviceAvailableTip()
- : CommonWidgets.deviceUnavailableTip();
- }),
- Expanded(child: Container()),
- InkWell(
- onTap: controller.refreshCameraList,
- child: Icon(
- Icons.refresh,
- size: 18,
- ),
- )
- ],
- ),
- ),
- Container(width: 300, child: _cameraSelector()),
- ],
- ),
- DetectButton(
- deviceType: HardwareDeviceType.camera,
- subTitleRowHright: _subTitleRowHright,
- ),
- ],
- ),
- );
- }
- /// 摄像头选择器
- Widget _cameraSelector() {
- return Obx(
- () {
- List<HardwareDevice> source = controller.state.cameraList;
- bool noCamera =
- source.isEmpty || controller.state.currentCameraId.isEmpty;
- if (controller.state.searchingCamera)
- return CommonWidgets.deviceFindingTip();
- return noCamera
- ? CommonWidgets.deviceNotFoundTip()
- : DropdownButton<String>(
- isExpanded: true,
- value: controller.state.currentCameraId,
- items: source.map((HardwareDevice device) {
- return DropdownMenuItem<String>(
- value: device.id,
- child: Text(device.name),
- );
- }).toList(),
- onChanged: (String? value) {
- if (value == null) return;
- controller.selectCameraById(value);
- },
- style: TextStyle(
- fontSize: 14,
- ),
- dropdownColor: Colors.white,
- underline: Container(
- height: 1,
- color: Colors.grey,
- ),
- );
- // : FSelect<HardwareDevice, String>(
- // source: source,
- // height: 30,
- // width: 300,
- // value: controller.state.currentCamera?.id,
- // optionValueExtractor: (value) {
- // return value.id;
- // },
- // optionLabelExtractor: (value) {
- // return value.name;
- // },
- // onSelectChanged: (value, index) {
- // if (value == null) return;
- // controller.selectCameraById(value);
- // },
- // fontSize: 14,
- // );
- },
- );
- }
- }
|