From f32ce1f25bc1090a8bde81930f9da5453a046477 Mon Sep 17 00:00:00 2001 From: bunju20 Date: Thu, 11 Apr 2024 00:19:40 +0900 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8Frefactor=20:=20#53=20userscri?= =?UTF-8?q?pt=20createScript=20=EC=8A=A4=ED=81=AC=EB=A6=B0=20=EB=B3=91?= =?UTF-8?q?=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../realtime/real_create_script_screen.dart | 34 ++--- lib/views/script/create_script_screen.dart | 26 +++- lib/views/script/learning_session_screen.dart | 5 +- lib/views/script/user_script_screen.dart | 130 ------------------ 4 files changed, 43 insertions(+), 152 deletions(-) delete mode 100644 lib/views/script/user_script_screen.dart diff --git a/lib/views/realtime/real_create_script_screen.dart b/lib/views/realtime/real_create_script_screen.dart index 3379e1b..c09e8f2 100644 --- a/lib/views/realtime/real_create_script_screen.dart +++ b/lib/views/realtime/real_create_script_screen.dart @@ -17,23 +17,26 @@ class RealCreateScriptPage extends BaseScreen { centerTitle: true, leading: IconButton( icon: const Icon(Icons.arrow_back), - onPressed: () => Get.back(), - ), - ), - body: Stack( - children: [ - Padding( + onPressed: (){ + Get.back(); + speechController.clearText(); + }, + ), + ), + body: Stack( + children: [ + Padding( padding: const EdgeInsets.fromLTRB(25, 20, 25, 100), child: Obx(() => TextField( - controller: TextEditingController(text: speechController.text.value), - expands: true, - maxLines: null, - decoration: InputDecoration( - hintText: 'voice_recognition'.tr, - fillColor: Colors.white, - filled: true, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(15.0), + controller: TextEditingController(text: speechController.text.value), + expands: true, + maxLines: null, + decoration: InputDecoration( + hintText: 'voice_recognition'.tr, + fillColor: Colors.white, + filled: true, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide.none, ), ), @@ -55,7 +58,6 @@ class RealCreateScriptPage extends BaseScreen { borderRadius: BorderRadius.circular(40), onTap: (){ speechController.toggleRecording(); - speechController.clearText(); }, child: Padding( padding: const EdgeInsets.all(20), diff --git a/lib/views/script/create_script_screen.dart b/lib/views/script/create_script_screen.dart index 09a2473..7536c23 100644 --- a/lib/views/script/create_script_screen.dart +++ b/lib/views/script/create_script_screen.dart @@ -4,7 +4,11 @@ import 'package:earlips/viewModels/script/create_script_viewmodel.dart'; import 'package:get/get.dart'; class CreateScriptPage extends StatelessWidget { - const CreateScriptPage({super.key}); + final String? title; // 선택적으로 제목을 받음 + final String? text; // 선택적으로 텍스트를 받음 + + const CreateScriptPage({super.key, this.title, this.text}); + @override Widget build(BuildContext context) { @@ -14,7 +18,7 @@ class CreateScriptPage extends StatelessWidget { builder: (context, model, child) => Scaffold( appBar: AppBar( title: Text( - 'home_script_subtitle'.tr, + title ?? 'home_script_subtitle'.tr, // 제목이 제공되면 사용, 아니면 기본값 ), centerTitle: true, actions: [ @@ -40,7 +44,23 @@ class CreateScriptPage extends StatelessWidget { flex: 1, child: Padding( padding: const EdgeInsets.all(10.0), - child: TextField( + child: text != null + ? // 텍스트가 제공되면 이를 사용하여 Container를 구성 + Container( + width: Get.width - 40, + margin: const EdgeInsets.all(10.0), + padding: const EdgeInsets.all(20.0), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15.0), + color: Colors.white, + ), + child: Text( + text!, + style: const TextStyle(fontSize: 16), + ), + ) + : // 텍스트가 제공되지 않으면 기본 TextField를 사용 + TextField( controller: model.writedTextController, expands: true, maxLines: null, diff --git a/lib/views/script/learning_session_screen.dart b/lib/views/script/learning_session_screen.dart index 8934748..7c6adf4 100644 --- a/lib/views/script/learning_session_screen.dart +++ b/lib/views/script/learning_session_screen.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:earlips/views/script/widget/small_card.dart'; import 'package:earlips/views/script/create_script_screen.dart'; -import 'package:earlips/views/script/user_script_screen.dart'; import 'package:earlips/viewModels/script/learning_session_screen_viewmodel.dart'; import 'package:intl/intl.dart'; // DateFormat을 사용하기 위해 추가 @@ -41,7 +40,7 @@ class _LearningSessionScreenState extends State { appBar: PreferredSize( preferredSize: const Size.fromHeight(kToolbarHeight), child: DefaultBackAppbar( - title: 'live_script_title'.tr, + title: 'home_script_title'.tr, ), ), body: Obx(() { @@ -127,7 +126,7 @@ class _LearningSessionScreenState extends State { ), ), onTap: () { - Get.to(() => UserScriptScreen( + Get.to(() => CreateScriptPage( title: paragraph.title, text: paragraph.text)); }, ), diff --git a/lib/views/script/user_script_screen.dart b/lib/views/script/user_script_screen.dart deleted file mode 100644 index 5e6ee16..0000000 --- a/lib/views/script/user_script_screen.dart +++ /dev/null @@ -1,130 +0,0 @@ -import 'package:earlips/utilities/style/color_system.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:earlips/viewModels/script/create_script_viewmodel.dart'; -import 'package:get/get.dart'; - -class UserScriptScreen extends StatelessWidget { - final String title; - final String text; - const UserScriptScreen({ - super.key, - required this.title, - required this.text, - }); - - @override - Widget build(BuildContext context) { - return ChangeNotifierProvider( - create: (_) => CreateScriptViewModel(), - child: Consumer( - builder: (context, model, child) => Scaffold( - appBar: AppBar( - title: Text(title), - centerTitle: true, - actions: [ - TextButton( - onPressed: model.complete, - child: Text( - 'appbar_done'.tr, - style: const TextStyle( - color: Colors.black, - fontSize: 20, - ), - ), - ), - ], - ), - body: Stack( - // Stack 위젯을 사용하여 Positioned를 올바르게 배치합니다. - children: [ - Column( - // 기존의 Column 구조를 Stack 내에 배치합니다. - children: [ - Expanded( - flex: 1, - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(0.0), - child: Container( - margin: const EdgeInsets.all(10.0), - padding: const EdgeInsets.all(20.0), - //가장자리 둥글게 - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15.0), - color: Colors.white, - ), - - child: Text( - text, - style: const TextStyle( - fontSize: 16, fontWeight: FontWeight.bold), - ), - ), - ), - ), - ), - Expanded( - flex: 1, - child: Padding( - padding: const EdgeInsets.fromLTRB(25, 20, 25, 100), - child: Container( - padding: const EdgeInsets.all(20.0), - width: Get.width * 0.8, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 1, - blurRadius: 6, - offset: const Offset(0, 3), - ), - ], - ), - child: SingleChildScrollView( - child: Text( - model.voicedTextController.text, - style: const TextStyle(fontSize: 16), - ), - ), - ), - ), - ), - ], - ), - Positioned( - // Positioned 위젯으로 사용자 정의 FloatingActionButton을 배치합니다. - bottom: 20, - left: 0, - right: 0, - child: Align( - alignment: Alignment.bottomCenter, - child: Ink( - decoration: BoxDecoration( - color: model.isRecording ? Colors.red : Colors.blue, - borderRadius: BorderRadius.circular(40), - ), - child: InkWell( - borderRadius: BorderRadius.circular(40), - onTap: model.toggleRecording, - child: Padding( - padding: const EdgeInsets.all(20), - child: Icon( - model.isRecording ? Icons.stop : Icons.mic, - size: 30, - color: Colors.white, - ), - ), - ), - ), - ), - ), - ], - ), - ), - ), - ); - } -}