From 0850c38ccdb57b2a6787bb45803a0ed6187a58d8 Mon Sep 17 00:00:00 2001 From: bunju20 <85238126+bunju20@users.noreply.github.com> Date: Wed, 21 Feb 2024 14:44:08 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=9D=8C=EC=86=8C=20=EC=9D=B8=EC=8B=9D?= =?UTF-8?q?=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/viewModels/record/record_viewmodel.dart | 17 ++++++++++++----- lib/views/word/widget/word_sentence_widget.dart | 7 ++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/viewModels/record/record_viewmodel.dart b/lib/viewModels/record/record_viewmodel.dart index d12cf9b..07e8dc9 100644 --- a/lib/viewModels/record/record_viewmodel.dart +++ b/lib/viewModels/record/record_viewmodel.dart @@ -65,9 +65,17 @@ class RecordViewModel extends GetxController { } Future sendTextAndAudio(String content, int type) async { + + isRecording.value ? await _stopRecording() : await _startRecording(); + update(); + if(isRecording.value == true) { + return; + } + print("들어오긴 함?"); String url = '${dotenv.env['API_URL']!}/study/${type == 0 ? 'syllable' : (type == 1 ? 'word' : 'sentence')}'; + print(audioFilePath.value); if (audioFilePath.value.isEmpty) { return; @@ -85,14 +93,13 @@ class RecordViewModel extends GetxController { final jsonResponse = json.decode(respStr); // this.response.value = jsonResponse; - } else {} + print(jsonResponse); + } else { + print('Failed to upload'); + } } catch (e) {} } - void toggleRecording() async { - isRecording.value ? await _stopRecording() : await _startRecording(); - update(); - } @override void onClose() { diff --git a/lib/views/word/widget/word_sentence_widget.dart b/lib/views/word/widget/word_sentence_widget.dart index 3e47ee3..4e5e752 100644 --- a/lib/views/word/widget/word_sentence_widget.dart +++ b/lib/views/word/widget/word_sentence_widget.dart @@ -37,18 +37,15 @@ class WordSentenceWidget extends StatelessWidget { borderRadius: BorderRadius.circular(40), onTap: () async { if (model.isRecording.value) { - // 녹음 토글 버튼 print('녹음 종료'); - model.toggleRecording(); - await model.sendTextAndAudio( wordDataList[wordViewModel.currentIndex.value] .wordCard .word, type); + // Handle the response here, e.g., show it in a dialog Get.dialog( - // height AlertDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), @@ -182,7 +179,7 @@ class WordSentenceWidget extends StatelessWidget { } else { // Start recording print('녹음 시작'); - model.toggleRecording(); + model.sendTextAndAudio('content', 0); } }, child: Padding(