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(