Skip to content

Commit

Permalink
#12 코드 구조 변경, 오류 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
codeJiwon committed Nov 27, 2023
1 parent f641ec6 commit 6779f79
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 38 deletions.
Binary file added unibond/auth-jwt-0.0.1-SNAPSHOT.jar
Binary file not shown.
7 changes: 2 additions & 5 deletions unibond/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:unibond/view/screens/community/post_detail_screen.dart';
import 'package:unibond/view/screens/user/login_screen.dart';
import 'package:unibond/view/screens/letter/letter_write_screen.dart';

void main() {
runApp(const MaterialApp(
Expand All @@ -20,9 +19,7 @@ class MyApp extends StatelessWidget {
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blueAccent),
useMaterial3: true,
),
home: DetailScreen(
id: 0,
), // 임시 스플래시화면
home: LetterWriteScreen(), // 임시 스플래시화면
);
}
}
2 changes: 1 addition & 1 deletion unibond/lib/view/screens/community/post_write_screen.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:unibond/view/screens/home_screen.dart';
import 'package:unibond/util/validator_util.dart';
import 'package:unibond/view/screens/home_screen.dart';
import 'package:unibond/view/widgets/custom_text_form_field.dart';
import 'package:unibond/view/widgets/custom_textarea.dart';
import 'package:unibond/view/widgets/custon_elevated_button.dart';
Expand Down
60 changes: 33 additions & 27 deletions unibond/lib/view/screens/letter/letter_write_screen.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:unibond/util/validator_util.dart';
import 'package:unibond/view/screens/home_screen.dart';
import 'package:unibond/view/widgets/custom_letter_area.dart';
import 'package:unibond/view/widgets/custom_letter_elevated_button.dart';
import 'package:unibond/view/widgets/custom_letter_form_field.dart';

class LetterWriteScreen extends StatefulWidget {
const LetterWriteScreen({super.key});
LetterWriteScreen({super.key});

@override
_LetterWriteScreenState createState() => _LetterWriteScreenState();
}

class _LetterWriteScreenState extends State<LetterWriteScreen> {
final _formKey = GlobalKey<FormState>();
final TextEditingController _titleController = TextEditingController();
final TextEditingController _contentController = TextEditingController();

Expand All @@ -29,39 +36,38 @@ class _LetterWriteScreenState extends State<LetterWriteScreen> {
Navigator.pop(context);
},
),
actions: [
IconButton(
icon: const Icon(Icons.send),
onPressed: () {
// 편지 전송하는 코드 추가
},
)
],
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
TextField(
controller: _titleController,
decoration: const InputDecoration(
labelText: "제목",
border: OutlineInputBorder(),
),
),
const SizedBox(height: 16),
Expanded(
child: TextField(
controller: _contentController,
maxLines: null,
expands: true,
child: Form(
key: _formKey,
child: ListView(
children: [
CustomLetterFormField(
hint: '제목을 입력하세요',
controller: _titleController,
decoration: const InputDecoration(
hintText: "내용을 입력하세요...",
labelText: "제목",
border: OutlineInputBorder(),
),
funvalidator: validateTitle,
),
const SizedBox(height: 16),
CustomLetterArea(
hint: '내용을 입력하세요',
controller: _contentController,
funvalidator: validateContent,
),
CustomLetterElevatedButton(
text: '전송하기',
funPageRoute: () {
if (_formKey.currentState!.validate()) {
Get.off(HomeScreen());
}
},
),
),
],
],
),
),
),
);
Expand Down
43 changes: 43 additions & 0 deletions unibond/lib/view/widgets/custom_letter_area.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import 'package:flutter/material.dart';

class CustomLetterArea extends StatelessWidget {
final String hint;
final TextEditingController controller;
final funvalidator;
final String? value;

const CustomLetterArea({
super.key,
required this.hint,
required this.controller,
required this.funvalidator,
this.value,
});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 5.0),
child: TextFormField(
controller: controller,
maxLines: null,
expands: true,
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),
),
),
),
);
}
}
28 changes: 28 additions & 0 deletions unibond/lib/view/widgets/custom_letter_elevated_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/material.dart';

class CustomLetterElevatedButton extends StatelessWidget {
final String text;
final Null Function() funPageRoute;

const CustomLetterElevatedButton({
Key? key,
required this.text,
required this.funPageRoute,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: const Size(double.infinity, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
),
onPressed: funPageRoute,
child: Text("$text"),
);
}
}
45 changes: 45 additions & 0 deletions unibond/lib/view/widgets/custom_letter_form_field.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';

class CustomLetterFormField extends StatelessWidget {
final String hint;
final TextEditingController controller;
final funvalidator;
final String? value;

const CustomLetterFormField({
super.key,
required this.hint,
required this.controller,
required this.funvalidator,
this.value,
required InputDecoration decoration,
});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 5.0),
child: TextFormField(
initialValue: value ?? "",
validator: funvalidator,
controller: controller,
decoration: InputDecoration(
// ignore: unnecessary_string_interpolations
hintText: hint == "이메일" ? "$hint을 입력하세요" : "$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),
),
),
),
);
}
}
9 changes: 6 additions & 3 deletions unibond/lib/view/widgets/custom_text_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ class CustomTextFormField extends StatelessWidget {
final funvalidator;
final String? value;

const CustomTextFormField(
{super.key, required this.hint, required this.funvalidator, this.value});
const CustomTextFormField({
super.key,
required this.hint,
required this.funvalidator,
this.value,
});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 5.0),
child: TextFormField(
initialValue: value ?? "",
validator: funvalidator,
obscureText: hint == "비밀번호" ? true : false,
style: const TextStyle(fontSize: 14),
Expand Down
2 changes: 0 additions & 2 deletions unibond/lib/view/widgets/custon_elevated_button.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: unnecessary_string_interpolations

import 'package:flutter/material.dart';

class CustomElevatedButton extends StatelessWidget {
Expand Down

0 comments on commit 6779f79

Please sign in to comment.