|
- import 'package:get/get.dart';
- import 'package:flutter/material.dart';
- import 'TranslateLogic.dart';
- import 'TranslateState.dart';
-
- /*
- 录音测试场景
- */
- class TranslateScene extends StatelessWidget {
- final TranslateLogic logic = Get.put(TranslateLogic());
- final TranslateState state = Get.find<TranslateLogic>().state;
- TranslateScene({super.key});
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(title: Text("录音测试")),
- // body: ListView.builder(
- // itemCount: _records.length,
- // itemBuilder: (context, index) {
- // var audio = _records[index];
- // return _buildAudioMessage(audio);
- // },
- // ),
- bottomNavigationBar: Padding(
- padding: const EdgeInsets.all(20.0),
- child: InkWell(
- onTap: logic.toggleCallStatus,
- child: Obx(() => Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(30), // 圆角按钮
- color: state.isRecording.value
- ? Colors.red
- : Colors.green, // 通话状态红色,非通话状态绿色
- ),
- padding: EdgeInsets.symmetric(
- vertical: 15, horizontal: 40), // 调整按钮大小
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(
- state.isRecording.value
- ? Icons.call_end
- : Icons.mic, // 图标变化
- color: Colors.white,
- size: 30,
- ),
- SizedBox(width: 10),
- Text(
- state.isRecording.value ? '挂断' : '开始通话', // 状态文字变化
- style: TextStyle(
- color: Colors.white,
- fontSize: 18,
- ),
- ),
- ],
- ),
- )))),
- );
- }
-
- // 构建语音消息
- // Widget _buildAudioMessage(RecordData data) {
- // Color buttColor = data.state == 0 ? Colors.red : Colors.green;
- // return Padding(
- // padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
- // child: Column(
- // crossAxisAlignment: CrossAxisAlignment.start,
- // children: [
- // // 音频播放按钮
- // GestureDetector(
- // onTap: () {
- // // _playRecording(data);
- // },
- // child: Container(
- // padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
- // decoration: BoxDecoration(
- // color: buttColor,
- // borderRadius: BorderRadius.circular(30),
- // ),
- // child: Row(
- // children: [
- // Icon(
- // Icons.play_arrow,
- // color: Colors.white,
- // ),
- // SizedBox(width: 10),
- // Text(
- // '播放音频',
- // style: TextStyle(color: Colors.white),
- // ),
- // ],
- // ),
- // ),
- // ),
- // SizedBox(height: 5),
- // // 文字内容
- // // Text(
- // // message['text'],
- // // style: TextStyle(fontSize: 16),
- // // ),
- // ],
- // ),
- // );
- // }
- }
|