import 'package:flutter/material.dart'; import 'package:fis_ui/index.dart'; import 'package:fis_ui/base_define/page.dart'; import 'package:get/get.dart'; import '../index.dart'; import 'widgets.dart'; /// 麦克风检测 class MicrophoneDetection extends GetView implements FPage { MicrophoneDetection({Key? key}) : super(key: key); @override String get pageName => "device_detection"; final smallTitleStyle = TextStyle( fontSize: 14, fontWeight: FontWeight.bold, height: 1, ); /// 副标题行高:[摄像头]、[麦克风]、[扬声器] static const _subTitleRowHright = 30.0; @override Widget build(BuildContext context) { return Row( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( width: 250, height: _subTitleRowHright, child: Row( children: [ Text("麦克风", style: smallTitleStyle), SizedBox(width: 10), Obx(() { if (controller.state.microphoneAvailable == null) return Container(); return controller.state.microphoneAvailable! ? CommonWidgets.deviceAvailableTip() : CommonWidgets.deviceUnavailableTip(); }), Expanded(child: Container()), InkWell( onTap: controller.refreshMicrophoneList, child: Icon( Icons.refresh, size: 18, ), ) ], ), ), _microphoneSelector(), ], ), SizedBox(width: 20), DetectButton( deviceType: HardwareDeviceType.microphone, subTitleRowHright: _subTitleRowHright, ), ], ); } /// 麦克风选择器 Widget _microphoneSelector() { return Obx( () { List source = controller.state.microphoneList; bool noMicrophone = source.isEmpty; return noMicrophone ? Container( width: 250, height: 30, child: Center( child: CommonWidgets.deviceNotFoundTip(), ), ) : FSelect( source: source, height: 30, width: 250, value: controller.state.currentMicrophone?.id, optionValueExtractor: (value) { return value.id; }, optionLabelExtractor: (value) { return value.name; }, onSelectChanged: (value, index) { if (value == null) return; controller.selectMicrophoneById(value); }, fontSize: 14, ); }, ); } }