Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

106 řádky
3.6 KiB

  1. import 'package:get/get.dart';
  2. import 'package:flutter/material.dart';
  3. import 'TranslateLogic.dart';
  4. import 'TranslateState.dart';
  5. /*
  6. 录音测试场景
  7. */
  8. class TranslateScene extends StatelessWidget {
  9. final TranslateLogic logic = Get.put(TranslateLogic());
  10. final TranslateState state = Get.find<TranslateLogic>().state;
  11. TranslateScene({super.key});
  12. @override
  13. Widget build(BuildContext context) {
  14. return Scaffold(
  15. appBar: AppBar(title: Text("录音测试")),
  16. // body: ListView.builder(
  17. // itemCount: _records.length,
  18. // itemBuilder: (context, index) {
  19. // var audio = _records[index];
  20. // return _buildAudioMessage(audio);
  21. // },
  22. // ),
  23. bottomNavigationBar: Padding(
  24. padding: const EdgeInsets.all(20.0),
  25. child: InkWell(
  26. onTap: logic.toggleCallStatus,
  27. child: Obx(() => Container(
  28. decoration: BoxDecoration(
  29. borderRadius: BorderRadius.circular(30), // 圆角按钮
  30. color: state.isRecording.value
  31. ? Colors.red
  32. : Colors.green, // 通话状态红色,非通话状态绿色
  33. ),
  34. padding: EdgeInsets.symmetric(
  35. vertical: 15, horizontal: 40), // 调整按钮大小
  36. child: Row(
  37. mainAxisAlignment: MainAxisAlignment.center,
  38. children: [
  39. Icon(
  40. state.isRecording.value
  41. ? Icons.call_end
  42. : Icons.mic, // 图标变化
  43. color: Colors.white,
  44. size: 30,
  45. ),
  46. SizedBox(width: 10),
  47. Text(
  48. state.isRecording.value ? '挂断' : '开始通话', // 状态文字变化
  49. style: TextStyle(
  50. color: Colors.white,
  51. fontSize: 18,
  52. ),
  53. ),
  54. ],
  55. ),
  56. )))),
  57. );
  58. }
  59. // 构建语音消息
  60. // Widget _buildAudioMessage(RecordData data) {
  61. // Color buttColor = data.state == 0 ? Colors.red : Colors.green;
  62. // return Padding(
  63. // padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
  64. // child: Column(
  65. // crossAxisAlignment: CrossAxisAlignment.start,
  66. // children: [
  67. // // 音频播放按钮
  68. // GestureDetector(
  69. // onTap: () {
  70. // // _playRecording(data);
  71. // },
  72. // child: Container(
  73. // padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
  74. // decoration: BoxDecoration(
  75. // color: buttColor,
  76. // borderRadius: BorderRadius.circular(30),
  77. // ),
  78. // child: Row(
  79. // children: [
  80. // Icon(
  81. // Icons.play_arrow,
  82. // color: Colors.white,
  83. // ),
  84. // SizedBox(width: 10),
  85. // Text(
  86. // '播放音频',
  87. // style: TextStyle(color: Colors.white),
  88. // ),
  89. // ],
  90. // ),
  91. // ),
  92. // ),
  93. // SizedBox(height: 5),
  94. // // 文字内容
  95. // // Text(
  96. // // message['text'],
  97. // // style: TextStyle(fontSize: 16),
  98. // // ),
  99. // ],
  100. // ),
  101. // );
  102. // }
  103. }