Skip to content

Commit

Permalink
feat: #57-qna리스트 스크린 및 카드 제작
Browse files Browse the repository at this point in the history
  • Loading branch information
ji-hunc committed Apr 7, 2024
1 parent 519534c commit bb75497
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 1 deletion.
6 changes: 6 additions & 0 deletions front/capstone_front/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:capstone_front/screens/login/login_screen.dart';
import 'package:capstone_front/screens/login/signup_screen.dart';
import 'package:capstone_front/screens/notice/notice_screen.dart';
import 'package:capstone_front/screens/notice_detail/notice_detail_screen.dart';
import 'package:capstone_front/screens/qna_list_screen/qna_list_screen.dart';
import 'package:capstone_front/screens/speeking_practice/pronunciation_practice_screen.dart';
import 'package:capstone_front/screens/speeking_practice/pronunciation_select_sentence_screen.dart';
import 'package:capstone_front/utils/page_animation.dart';
Expand Down Expand Up @@ -124,6 +125,11 @@ final GoRouter router = GoRouter(
const {"title": "temp", "date": "temp", "kind": "temp"},
),
),
GoRoute(
name: 'qnalist',
path: '/qnalist',
builder: (context, state) => const QnaListScreen(),
),
],
);

Expand Down
2 changes: 1 addition & 1 deletion front/capstone_front/lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class _HomeScreenState extends State<HomeScreen> {
MenuButton(
title: tr("mainScreen.qna"),
icon: Icons.question_answer_outlined,
routeCallbackFun: () => context.push("/login"),
routeCallbackFun: () => context.push("/qnalist"),
),
MenuButton(
title: tr("mainScreen.faq"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import 'package:capstone_front/screens/qna_list_screen/question_card.dart';
import 'package:capstone_front/screens/qna_list_screen/test_question_data.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

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

@override
State<QnaListScreen> createState() => _QnaListScreenState();
}

class _QnaListScreenState extends State<QnaListScreen> {
final _controller = TextEditingController();

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: TextField(
controller: _controller,
onChanged: (text) {
setState(() {});
},
decoration: InputDecoration(
hintText: "검색어를 입력하세요",
border: InputBorder.none,
hintStyle: const TextStyle(
color: Color(0XFFd7d7d7),
),
suffixIcon: _controller.text.isNotEmpty
? IconButton(
onPressed: () {
_controller.clear();
setState(() {});
},
icon: const Icon(
Icons.cancel,
color: Colors.grey,
),
)
: null,
),
style: const TextStyle(
color: Colors.black,
fontSize: 18.0,
),
),
actions: [
IconButton(
icon: Icon(
Icons.search,
color: Theme.of(context).primaryColor,
),
onPressed: () => {},
),
],
),
body: Container(
color: const Color(0xFFF8F8F8),
child: Expanded(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
children: [
...questionDatas.map(
(item) => Column(
children: [
QuestionCard(
title: item['title'],
content: item['content'],
name: item['name'],
country: item['country'],
tag: item['tag'],
),
const SizedBox(
height: 20,
)
],
),
),
],
),
),
),
),
),
);
}
}
117 changes: 117 additions & 0 deletions front/capstone_front/lib/screens/qna_list_screen/question_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import 'package:flutter/material.dart';

class QuestionCard extends StatelessWidget {
final String title, content, name, country, tag;

const QuestionCard({
super.key,
required this.title,
required this.content,
required this.name,
required this.country,
required this.tag,
});

@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3),
),
]),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: const Color(0xfff3f1fe),
),
padding: const EdgeInsets.symmetric(
vertical: 4,
horizontal: 6,
),
child: Text(
tag,
style: const TextStyle(
color: Color(0xFF9375e6),
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(
height: 16,
),
Row(
children: [
Text(
"Q. ",
style: TextStyle(
fontSize: 20,
color: Theme.of(context).primaryColor,
),
),
Expanded(
child: Text(
title,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
),
overflow: TextOverflow.ellipsis,
),
),
],
),
const SizedBox(
height: 20,
),
Text(
content,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
const SizedBox(
height: 20,
),
Row(
children: [
Text(
name,
style: const TextStyle(
fontSize: 16,
color: Color(0xff7b7b89),
),
),
const SizedBox(
width: 10,
),
Text(
country,
style: const TextStyle(
fontSize: 16,
color: Color(0xFFa1a1ad),
),
),
],
)
],
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
final List<Map<String, dynamic>> questionDatas = [
{
'title': '가상대학 로그인 어떻게 하나요?',
'content': '가상대학에 로그인을 하려고 하는데 어떻게 하는지 모르겠습니다. 도와주세요. 나는 북조선에서 온 사람입니다.',
'name': '최지훈',
'country': '북한',
'tag': '대학생활',
},
{
'title': '도서관 대출 규정이 궁금해요',
'content': '도서관 책을 얼마나 오래 대출할 수 있나요? 연체 시 벌금은 어떻게 되나요?',
'name': '김서영',
'country': '아제르바이잔',
'tag': '대학생활',
},
{
'title': '식당 운영시간 알려주세요',
'content': '캠퍼스 내 식당의 운영시간이 어떻게 되나요? 주말에도 열어요?',
'name': '박준혁',
'country': '대한민국',
'tag': '학사안내',
},
{
'title': '체육시설 이용 방법',
'content': '학교 체육시설을 이용하고 싶은데, 예약은 어떻게 하나요? 이용 요금은 있나요?',
'name': '이하늘',
'country': '대한민국',
'tag': '학사안내',
},
{
'title': '수강신청 팁 좀 알려주세요',
'content': '수강신청 잘하는 방법이 있나요? 매번 원하는 수업을 못 듣게 되네요.',
'name': '정민수',
'country': '남아프리카공화국',
'tag': '대학생활',
},
];

0 comments on commit bb75497

Please sign in to comment.