speaker_detection.dart 3.1 KB

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