Skip to content

Commit

Permalink
Merge pull request #42 from UniBond-jijijin/feature/#8-Home
Browse files Browse the repository at this point in the history
#8 Feat: 화면 UI, 라우팅
  • Loading branch information
codeJiwon authored Nov 19, 2023
2 parents c83697b + f90075f commit dd44270
Show file tree
Hide file tree
Showing 12 changed files with 535 additions and 91 deletions.
7 changes: 3 additions & 4 deletions unibond/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:unibond/screens/user/join_screen.dart';
import 'package:unibond/screens/user/join_screen.dart';
import 'package:unibond/screens/user/profile_screen.dart';
import 'package:unibond/screens/home_screen.dart';

void main() {
runApp(const MaterialApp(
Expand All @@ -21,7 +19,8 @@ class MyApp extends StatelessWidget {
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blueAccent),
useMaterial3: true,
),
home: ProfileScreen(), // 임시 스플래시화면

home: const HomeScreen(), // 임시 스플래시화면
);
}
}
2 changes: 1 addition & 1 deletion unibond/lib/resources/app_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
12 changes: 12 additions & 0 deletions unibond/lib/resources/size.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';

double getScreenWidth(BuildContext context) {
return MediaQuery.of(context).size.width;
}

class FontSize {
// 전부 임시값들임
static const double primary = menuName;
static const double content = 18;
static const double menuName = 22;
}
125 changes: 103 additions & 22 deletions unibond/lib/screens/community/post_detail_screen.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:unibond/resources/size.dart';
import 'package:unibond/screens/community/post_update_screen.dart';
import 'package:unibond/screens/home_screen.dart';

class DetailScreen extends StatelessWidget {
const DetailScreen({super.key});
final int id;

const DetailScreen({super.key, required this.id});

@override
Widget build(BuildContext context) {
Expand All @@ -13,40 +18,89 @@ class DetailScreen extends StatelessWidget {
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios),
onPressed: () {
Get.back();
Get.offAll(() => const HomeScreen());
},
),
actions: [
IconButton(
icon: const Icon(Icons.more_vert),
onPressed: () {
_showReportConfirmationDialog(context);
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return SizedBox(
height: 200,
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
// TODO: 내 게시물/ 남의 게시물에 따라 다른 버튼 보이기
TextButton(
child: const Text(
'게시물 삭제',
style: TextStyle(fontSize: FontSize.menuName),
),
onPressed: () {
Get.back();
_showDeleteConfirmationDialog(context);
}),
TextButton(
child: const Text(
'게시물 수정',
style: TextStyle(fontSize: FontSize.menuName),
),
onPressed: () {
Navigator.of(context).pop();
Get.to(() => UpdateScreen());
}),
TextButton(
child: const Text(
'게시물 신고',
style: TextStyle(fontSize: FontSize.menuName),
),
onPressed: () {
Get.back();
_showReportConfirmationDialog(context);
}),
],
),
),
);
},
);
},
),
],
),
body: Column(
children: [
// 게시물 영역
Expanded(
flex: 2,
child: Container(
width: double.infinity,
color: Colors.amber,
// TODO: 게시물 영역 UI 구성
// 사용자 기본정보 영역, 게시글 내용 영역 등을 구성
),
),
// 댓글 확인 영역
Expanded(
flex: 3,
child: Container(
width: double.infinity,
color: Colors.blue,
// TODO: 작성된 댓글 영역 구현
// ListView.builder 사용
// 각 댓글은 사용자 기본정보, 댓글 내용, 대댓글 및 삭제 버튼으로 구성
// 스크롤 가능한 영역임: SingleChildScrollView or ListView 활용
flex: 6,
child: SingleChildScrollView(
child: Column(
children: [
// 게시물 영역
Container(
width: double.infinity,
color: Colors.amber,
// TODO: 게시물 영역 UI 구성
// 사용자 기본정보 영역, 게시글 내용 영역 등을 구성
child: Text("$id번 게시물 상세 내용이다!" * 50),
),
// 댓글 확인 영역
Container(
width: double.infinity,
color: Colors.blue,
// TODO: 작성된 댓글 영역 구현
// ListView.builder 사용
// 각 댓글은 사용자 기본정보, 댓글 내용, 대댓글 및 삭제 버튼으로 구성
// 스크롤 가능한 영역임: SingleChildScrollView or ListView 활용
child: Text("$id번 댓글들이다!" * 40),
),
],
),
),
),
// 댓글 작성 영역
Expand All @@ -64,6 +118,33 @@ class DetailScreen extends StatelessWidget {
);
}

void _showDeleteConfirmationDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('게시물 삭제 확인'),
content: const Text('이 게시물을 삭제하시겠습니까?'),
actions: [
TextButton(
onPressed: () {
Get.off(() => const HomeScreen());
Navigator.of(context).pop();
},
child: const Text('확인'),
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('취소'),
),
],
);
},
);
}

void _showReportConfirmationDialog(BuildContext context) {
showDialog(
context: context,
Expand Down
56 changes: 56 additions & 0 deletions unibond/lib/screens/community/post_update_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:get/get.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 UpdateScreen extends StatelessWidget {
final _formKey = GlobalKey<FormState>();
UpdateScreen({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();
},
),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: ListView(
children: [
CustomTextFormField(
hint: "제목",
funvalidator: validateTitle,
value: "하하 이것은 나중에 서버에서 받아올 제목이야.",
),
CustomTextArea(
hint: "내용",
funvalidator: validateContent,
value: "나중에 서버에서 받아올 내용. 나는 배가 고파요. " * 10,
),
CustomElevatedButton(
text: "수정 완료",
screenRoute: () {
if (isValid(_formKey)) {
// TODO: 추후 GetX Obs 기능 사용해서 이전 화면 갱신하기
Get.back();
}
},
),
],
),
),
),
);
}
}
48 changes: 48 additions & 0 deletions unibond/lib/screens/community/post_write_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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 {
final _formKey = GlobalKey<FormState>();
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();
},
),
),
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());
}
},
),
],
),
),
),
);
}
}
Loading

0 comments on commit dd44270

Please sign in to comment.