From 23d337fd3d6f6292d93db6bddc5addd51a77c126 Mon Sep 17 00:00:00 2001 From: Nyeong Date: Sun, 19 Nov 2023 16:10:30 +0900 Subject: [PATCH 1/2] =?UTF-8?q?#4=20Feat:=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=ED=99=94=EB=A9=B4=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Feat: Home floatingActionButton 생성 - Design: contentColorPink 색상 사용 --- unibond/lib/resources/app_colors.dart | 2 +- .../screens/community/post_write_screen.dart | 22 +++++++++++++++++++ unibond/lib/screens/home_screen.dart | 13 +++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 unibond/lib/screens/community/post_write_screen.dart diff --git a/unibond/lib/resources/app_colors.dart b/unibond/lib/resources/app_colors.dart index b53a8d5..f91f20e 100644 --- a/unibond/lib/resources/app_colors.dart +++ b/unibond/lib/resources/app_colors.dart @@ -19,7 +19,7 @@ class AppColors { static const Color contentColorOrange = Color(0xFFFF8080); static const Color contentColorGreen = Color(0xFF3BD79D); static const Color contentColorPurple = Color.fromARGB(255, 122, 69, 214); - static const Color contentColorPink = Color(0xFFFF3AF2); + static const Color contentColorPink = Color(0xFFFF6292); static const Color contentColorRed = Color(0xFFE80054); static const Color contentColorLightBlue = Color(0xFF7091CF); } diff --git a/unibond/lib/screens/community/post_write_screen.dart b/unibond/lib/screens/community/post_write_screen.dart new file mode 100644 index 0000000..c687f1c --- /dev/null +++ b/unibond/lib/screens/community/post_write_screen.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class WriteScreen extends StatelessWidget { + const WriteScreen({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + centerTitle: true, + title: const Text('게시물 작성'), + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios), + onPressed: () { + Get.back(); + }, + ), + ), + ); + } +} diff --git a/unibond/lib/screens/home_screen.dart b/unibond/lib/screens/home_screen.dart index 10bd0eb..0ad3e04 100644 --- a/unibond/lib/screens/home_screen.dart +++ b/unibond/lib/screens/home_screen.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:unibond/resources/app_colors.dart'; import 'package:unibond/screens/community/post_detail_screen.dart'; +import 'package:unibond/screens/community/post_write_screen.dart'; import 'package:unibond/screens/letter/letter_box_screen.dart'; import 'package:unibond/screens/user/profile_screen.dart'; import 'package:unibond/widgets/navigator.dart'; @@ -160,6 +162,17 @@ class HomeScreen extends StatelessWidget { } }, ), + floatingActionButton: FloatingActionButton.extended( + onPressed: () { + Get.to(() => const WriteScreen()); + }, + elevation: 4, + label: const Text('글쓰기'), + icon: const Icon(Icons.mode_edit_outlined), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)), + foregroundColor: Colors.white, + backgroundColor: AppColors.contentColorPink, + ), ); } } From f73d0bbd66d19a613f58bf519461761b26124ec6 Mon Sep 17 00:00:00 2001 From: Nyeong Date: Sun, 19 Nov 2023 17:26:41 +0900 Subject: [PATCH 2/2] =?UTF-8?q?#4=20Feat:=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=ED=99=94=EB=A9=B4=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - validator새로 생성 - textarea를 위한 위젯생성 - Fix: overflow view수정 --- .../screens/community/post_write_screen.dart | 28 ++++- unibond/lib/screens/home_screen.dart | 116 +++++++++--------- unibond/lib/util/validator_util.dart | 20 +++ unibond/lib/widgets/custom_textarea.dart | 36 ++++++ 4 files changed, 142 insertions(+), 58 deletions(-) create mode 100644 unibond/lib/widgets/custom_textarea.dart diff --git a/unibond/lib/screens/community/post_write_screen.dart b/unibond/lib/screens/community/post_write_screen.dart index c687f1c..f00f7c8 100644 --- a/unibond/lib/screens/community/post_write_screen.dart +++ b/unibond/lib/screens/community/post_write_screen.dart @@ -1,8 +1,14 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:unibond/screens/home_screen.dart'; +import 'package:unibond/util/validator_util.dart'; +import 'package:unibond/widgets/custom_text_form_field.dart'; +import 'package:unibond/widgets/custom_textarea.dart'; +import 'package:unibond/widgets/custon_elevated_button.dart'; class WriteScreen extends StatelessWidget { - const WriteScreen({super.key}); + final _formKey = GlobalKey(); + WriteScreen({super.key}); @override Widget build(BuildContext context) { @@ -17,6 +23,26 @@ class WriteScreen extends StatelessWidget { }, ), ), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: Form( + key: _formKey, + child: ListView( + children: [ + CustomTextFormField(hint: "제목", funvalidator: validateTitle), + CustomTextArea(hint: "내용", funvalidator: validateContent), + CustomElevatedButton( + text: "작성 완료", + screenRoute: () { + if (isValid(_formKey)) { + Get.off(() => const HomeScreen()); + } + }, + ), + ], + ), + ), + ), ); } } diff --git a/unibond/lib/screens/home_screen.dart b/unibond/lib/screens/home_screen.dart index 0ad3e04..8226a1a 100644 --- a/unibond/lib/screens/home_screen.dart +++ b/unibond/lib/screens/home_screen.dart @@ -37,71 +37,73 @@ class HomeScreen extends StatelessWidget { end: Alignment.bottomCenter, ), ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - const SizedBox(height: 100), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - height: 120, - width: 170, - decoration: BoxDecoration( - gradient: const LinearGradient( - colors: [Color(0xFF7A34AC), Color(0xFF87ADFF)], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - ), - border: Border.all( - width: 5, - color: Colors.white, - ), - borderRadius: BorderRadius.circular(30), - ), - child: const Padding( - padding: EdgeInsets.all(12.0), - child: Text( - "질문", - style: TextStyle( + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const SizedBox(height: 100), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + height: 120, + width: 170, + decoration: BoxDecoration( + gradient: const LinearGradient( + colors: [Color(0xFF7A34AC), Color(0xFF87ADFF)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + border: Border.all( + width: 5, color: Colors.white, - fontSize: 18, ), + borderRadius: BorderRadius.circular(30), ), - ), - ), - const SizedBox(width: 20), - Container( - height: 120, - width: 170, - decoration: BoxDecoration( - gradient: const LinearGradient( - colors: [Color(0xFFFF6292), Color(0xFFFFF1DF)], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, + child: const Padding( + padding: EdgeInsets.all(12.0), + child: Text( + "질문", + style: TextStyle( + color: Colors.white, + fontSize: 18, + ), + ), ), - // border: Border.all( - // width: 0, - // ), - borderRadius: BorderRadius.circular(30), ), - child: const Padding( - padding: EdgeInsets.all(12.0), - child: Text( - "경험기록", - style: TextStyle( - color: Colors.white, - fontSize: 18, + const SizedBox(width: 20), + Container( + height: 120, + width: 170, + decoration: BoxDecoration( + gradient: const LinearGradient( + colors: [Color(0xFFFF6292), Color(0xFFFFF1DF)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + // border: Border.all( + // width: 0, + // ), + borderRadius: BorderRadius.circular(30), + ), + child: const Padding( + padding: EdgeInsets.all(12.0), + child: Text( + "경험기록", + style: TextStyle( + color: Colors.white, + fontSize: 18, + ), ), ), ), - ), - ], + ], + ), ), - ), - ], + ], + ), ), ), ), @@ -164,7 +166,7 @@ class HomeScreen extends StatelessWidget { ), floatingActionButton: FloatingActionButton.extended( onPressed: () { - Get.to(() => const WriteScreen()); + Get.to(() => WriteScreen()); }, elevation: 4, label: const Text('글쓰기'), diff --git a/unibond/lib/util/validator_util.dart b/unibond/lib/util/validator_util.dart index 747df5d..13f1c22 100644 --- a/unibond/lib/util/validator_util.dart +++ b/unibond/lib/util/validator_util.dart @@ -37,3 +37,23 @@ Function validatePassword = (String? value) { return null; } }; + +Function validateTitle = (String? value) { + if (value == null || value.isEmpty) { + return "값을 입력해주세요."; + } else if (value.length > 30) { + return "제목은 30자 이하로 입력해주세요."; + } else { + return null; + } +}; + +Function validateContent = (String? value) { + if (value == null || value.isEmpty) { + return "값을 입력해주세요."; + } else if (value.length > 500) { + return "내용은 500자 이하로 입력해주세요."; + } else { + return null; + } +}; diff --git a/unibond/lib/widgets/custom_textarea.dart b/unibond/lib/widgets/custom_textarea.dart new file mode 100644 index 0000000..24620ef --- /dev/null +++ b/unibond/lib/widgets/custom_textarea.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; + +class CustomTextArea extends StatelessWidget { + final String hint; + final funvalidator; + + const CustomTextArea( + {super.key, required this.hint, required this.funvalidator}); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 5.0), + child: TextFormField( + maxLines: 14, + validator: funvalidator, + style: const TextStyle(fontSize: 14), + decoration: InputDecoration( + hintText: "$hint을(를) 입력하세요", + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(20), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(20), + ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(20), + ), + focusedErrorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(20), + ), + ), + ), + ); + } +}