microphone_detection.dart 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import 'package:flutter/material.dart';
  2. import 'package:fis_ui/index.dart';
  3. import 'package:fis_ui/base_define/page.dart';
  4. import 'package:get/get.dart';
  5. import '../index.dart';
  6. import 'widgets.dart';
  7. /// 麦克风检测
  8. class MicrophoneDetection extends GetView<HardwareDetectionController>
  9. implements FPage {
  10. MicrophoneDetection({Key? key}) : super(key: key);
  11. @override
  12. String get pageName => "device_detection";
  13. final smallTitleStyle = TextStyle(
  14. fontSize: 14,
  15. fontWeight: FontWeight.bold,
  16. height: 1,
  17. );
  18. /// 副标题行高:[摄像头]、[麦克风]、[扬声器]
  19. static const _subTitleRowHright = 30.0;
  20. @override
  21. Widget build(BuildContext context) {
  22. return Row(
  23. children: [
  24. Column(
  25. crossAxisAlignment: CrossAxisAlignment.start,
  26. children: [
  27. Container(
  28. width: 250,
  29. height: _subTitleRowHright,
  30. child: Row(
  31. children: [
  32. Text("麦克风", style: smallTitleStyle),
  33. SizedBox(width: 10),
  34. Obx(() {
  35. if (controller.state.microphoneAvailable == null)
  36. return Container();
  37. return controller.state.microphoneAvailable!
  38. ? CommonWidgets.deviceAvailableTip()
  39. : CommonWidgets.deviceUnavailableTip();
  40. }),
  41. Expanded(child: Container()),
  42. InkWell(
  43. onTap: controller.refreshMicrophoneList,
  44. child: Icon(
  45. Icons.refresh,
  46. size: 18,
  47. ),
  48. )
  49. ],
  50. ),
  51. ),
  52. _microphoneSelector(),
  53. ],
  54. ),
  55. SizedBox(width: 20),
  56. DetectButton(
  57. deviceType: HardwareDeviceType.microphone,
  58. subTitleRowHright: _subTitleRowHright,
  59. ),
  60. ],
  61. );
  62. }
  63. /// 麦克风选择器
  64. Widget _microphoneSelector() {
  65. return Obx(
  66. () {
  67. List<HardwareDevice> source = controller.state.microphoneList;
  68. bool noMicrophone = source.isEmpty;
  69. return noMicrophone
  70. ? Container(
  71. width: 250,
  72. height: 30,
  73. child: Center(
  74. child: CommonWidgets.deviceNotFoundTip(),
  75. ),
  76. )
  77. : FSelect<HardwareDevice, String>(
  78. source: source,
  79. height: 30,
  80. width: 250,
  81. value: controller.state.currentMicrophone?.id,
  82. optionValueExtractor: (value) {
  83. return value.id;
  84. },
  85. optionLabelExtractor: (value) {
  86. return value.name;
  87. },
  88. onSelectChanged: (value, index) {
  89. if (value == null) return;
  90. controller.selectMicrophoneById(value);
  91. },
  92. fontSize: 14,
  93. );
  94. },
  95. );
  96. }
  97. }