Skip to content

Commit

Permalink
Merge branch 'develop-front' of https://github.com/kookmin-sw/capston…
Browse files Browse the repository at this point in the history
…e-2024-30 into feature/fe/#109-chatting
  • Loading branch information
ji-hunc committed May 8, 2024
2 parents 93ca865 + dd20f06 commit 640ea3b
Show file tree
Hide file tree
Showing 15 changed files with 219 additions and 95 deletions.
2 changes: 1 addition & 1 deletion front/capstone_front/assets/translations/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"chatbot": "챗봇",
"textfield_hint": "궁금한 내용을 입력해주세요",
"loading": "답변을 생성중입니다...",
"init": "안녕하세요! 국민대학교 전용 챗봇 KUKU입니다. 국민대학교에 대한 건 모든 질문해주세요!"
"init": "안녕하세요! 국민대학교 전용 챗봇 KUKU입니다. 국민대학교에 대한 건 무엇이든 질문해주세요!"
},
"helper": {
"helper": "헬퍼",
Expand Down
2 changes: 1 addition & 1 deletion front/capstone_front/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ late CafeteriaMenuModel menus;
Future<void> setSetting() async {
const storage = FlutterSecureStorage();
String? language = await storage.read(key: 'language');
if (language == 'english') {
if (language == 'EN') {
languageSetting = ['en', 'US'];
} else {
languageSetting = ['ko', 'KR'];
Expand Down
6 changes: 2 additions & 4 deletions front/capstone_front/lib/screens/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class _HomeScreenState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F7F9),
appBar: AppBar(
title: const Text(
"외국민",
Expand Down Expand Up @@ -351,15 +350,14 @@ class _HomeScreenState extends State<HomeScreen> {
IconButton(
icon: const Text("\u{1f1f0}\u{1f1f7}"), // 한국어
onPressed: () async {
await storage.write(key: 'language', value: 'korean');
await storage.write(key: 'language', value: 'KO');
restartDialog(context);
},
),
IconButton(
icon: const Text("\u{1f1fa}\u{1f1f8}"), // 영어
onPressed: () async {
await storage.write(
key: 'language', value: 'english');
await storage.write(key: 'language', value: 'EN');
restartDialog(context);
}),
],
Expand Down
54 changes: 50 additions & 4 deletions front/capstone_front/lib/screens/notice/notice_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class _NoticeScreenState extends State<NoticeScreen> {
var hasNext = true;
var itemCount = 0;
var language = 'KO';
bool isSearchMode = false;

void loadNotices(int lastCursor, String language) async {
try {
Expand All @@ -42,6 +43,24 @@ class _NoticeScreenState extends State<NoticeScreen> {
}
}

void loadNoticesByWord(int lastCursor, String language, String word) async {
try {
NoticesResponse res = await NoticeService.getNoticesByWord(
lastCursor, selectedItem, language, word);
setState(() {
hasNext = res.hasNext;
if (hasNext) {
cursor = res.lastCursorId!;
}
notices.addAll(res.notices);
itemCount += res.notices.length;
});
} catch (e) {
print(e);
throw Exception('error');
}
}

void initLanguageAndLoadNotices() async {
const storage = FlutterSecureStorage();
String? storedLanguage = await storage.read(key: 'language');
Expand Down Expand Up @@ -72,7 +91,11 @@ class _NoticeScreenState extends State<NoticeScreen> {
title: TextField(
controller: _controller,
onChanged: (text) {
setState(() {});
if (text.trim() == "") {
setState(() {
isSearchMode = false;
});
}
},
decoration: InputDecoration(
hintText: "검색어를 입력하세요",
Expand All @@ -84,7 +107,16 @@ class _NoticeScreenState extends State<NoticeScreen> {
? IconButton(
onPressed: () {
_controller.clear();
setState(() {});
setState(() {
setState(() {
cursor = 0;
hasNext = true;
itemCount = 0;
notices = [];
isSearchMode = false;
});
loadNotices(cursor, language);
});
},
icon: const Icon(
Icons.cancel,
Expand All @@ -104,7 +136,16 @@ class _NoticeScreenState extends State<NoticeScreen> {
Icons.search,
color: Theme.of(context).primaryColor,
),
onPressed: () => {},
onPressed: () {
setState(() {
cursor = 0;
hasNext = true;
itemCount = 0;
notices = [];
isSearchMode = true;
});
loadNoticesByWord(cursor, language, _controller.text);
},
),
],
),
Expand Down Expand Up @@ -190,7 +231,12 @@ class _NoticeScreenState extends State<NoticeScreen> {
Expanded(
child: RefreshIndicator(
onRefresh: () async {
loadNotices(0, language);
setState(() {
notices = [];
});
isSearchMode
? loadNoticesByWord(0, language, _controller.text)
: loadNotices(0, language);
},
child: ListView.separated(
itemCount: notices.length,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ class _QnaListScreenState extends State<QnaListScreen> {
title: TextField(
controller: _controller,
onChanged: (text) {
setState(() {});
if (text.trim() == "") {
setState(() {
word = "";
});
}
setState(() {
word = text;
});
},
decoration: InputDecoration(
hintText: "검색어를 입력하세요",
Expand All @@ -71,6 +78,9 @@ class _QnaListScreenState extends State<QnaListScreen> {
? IconButton(
onPressed: () {
_controller.clear();
setState(() {
word = "";
});
},
icon: const Icon(
Icons.cancel,
Expand All @@ -90,7 +100,15 @@ class _QnaListScreenState extends State<QnaListScreen> {
Icons.search,
color: Theme.of(context).primaryColor,
),
onPressed: () => {},
onPressed: () {
setState(() {
qnas = [];
cursor = 0;
hasNext = true;
itemCount = 0;
});
loadQnas(0, tag, word);
},
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Future<String> isEmailAuth(String email, String pw) async {
if (user!.emailVerified) {
user = credential.user;
userInfo['uuid'] = user!.uid;
await storage.write(key: 'uuid', value: user.uid);

return "success";
} else {
return "email";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,23 @@ class _SpeechCustomSentenceScreenState
FocusScope.of(context).unfocus();
},
child: Scaffold(
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Column(
children: [
Container(
body: Column(
children: [
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 15.0, vertical: 5),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: const Color(0xffd2d7dd),
width: 2,
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.15),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3),
),
],
),
padding: const EdgeInsets.all(10),
child: TextField(
Expand All @@ -51,16 +56,19 @@ class _SpeechCustomSentenceScreenState
),
),
),
const Spacer(),
BasicButton(
),
const Spacer(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15.0),
child: BasicButton(
text: tr('speech.speech_practice'),
onPressed: () {
context.push('/speech/practice',
extra: [_textController.text, '']);
}),
const SizedBox(height: 15),
],
),
),
const SizedBox(height: 15),
],
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ class _SpeechPracitceCardState extends State<SpeechPracticeCard> {
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: const Color(0xffd2d7dd),
width: 1.5,
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.15),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3),
),
],
),
child: Padding(
padding: EdgeInsets.symmetric(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,15 @@ class _SpeechSentenceScreenState extends State<SpeechSentenceScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: ListView.builder(
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.only(bottom: 10),
child: SpeechSentenceCard(
index: index,
canTap: true,
verticalPadding: 0,
),
);
},
itemCount: sentences.length,
),
body: ListView.builder(
itemBuilder: (BuildContext context, int index) {
return SpeechSentenceCard(
index: index,
canTap: true,
verticalPadding: 0,
);
},
itemCount: sentences.length,
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,56 @@ class _SpeechSentenceCardState extends State<SpeechSentenceCard> {

@override
Widget build(BuildContext context) {
return InkWell(
onTap: _canTap
? () async {
var status = await Permission.microphone.request();
if (status != PermissionStatus.granted) {
permssionNotice(context);
} else {
context.push('/speech/practice',
extra: [sentences[_index][0], sentences[_index][1]]);
return Padding(
padding: const EdgeInsets.only(left: 15.0, right: 15, top: 5, bottom: 10),
child: InkWell(
onTap: _canTap
? () async {
var status = await Permission.microphone.request();
if (status != PermissionStatus.granted) {
permssionNotice(context);
} else {
context.push('/speech/practice',
extra: [sentences[_index][0], sentences[_index][1]]);
}
}
}
: null,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: const Color(0xffd2d7dd),
width: 1.5,
: null,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.15),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3),
),
],
),
),
child: Padding(
padding: EdgeInsets.symmetric(
vertical: 10.0 + _verticalPadding, horizontal: 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
sentences[_index][0],
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
child: Padding(
padding: EdgeInsets.symmetric(
vertical: 10.0 + _verticalPadding, horizontal: 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
sentences[_index][0],
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
overflow: TextOverflow.ellipsis,
),
),
Text(
sentences[_index][1],
style: Theme.of(context).textTheme.bodySmall,
overflow: TextOverflow.ellipsis,
),
),
Text(
sentences[_index][1],
style: Theme.of(context).textTheme.bodySmall,
overflow: TextOverflow.ellipsis,
),
],
],
),
),
),
),
Expand Down
Loading

0 comments on commit 640ea3b

Please sign in to comment.