Skip to content

Commit

Permalink
Merge pull request #170 from kookmin-sw/refactor/fe/#169-modify-login…
Browse files Browse the repository at this point in the history
…-logic

refactor:#169/로그인 로직 수정
  • Loading branch information
ji-hunc authored May 8, 2024
2 parents 8ce0dc9 + 873c356 commit fa6b239
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 87 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 @@ -58,7 +58,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
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
17 changes: 14 additions & 3 deletions front/capstone_front/lib/services/chatbot_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@ import 'dart:convert';

import 'package:capstone_front/models/api_fail_response.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:http/http.dart' as http;

Future<String> getChatbotAnswer(String question) async {
final String baseUrl = dotenv.get('CHATBOT_URL');
final String baseUrl = dotenv.get('BASE_URL');
final url = Uri.parse('$baseUrl/chatbot');

Map data = {"query": question};
FlutterSecureStorage storage = const FlutterSecureStorage();
final accessToken = await storage.read(key: "accessToken");
final language = await storage.read(key: "language");

Map data = {
"query": question,
"target_lang": "KO",
};
var body = json.encode(data);

final response = await http.post(
url,
headers: {'Content-Type': "application/json"},
headers: {
'Content-Type': "application/json",
'Authorization': 'Bearer $accessToken',
},
body: body,
);

Expand Down
4 changes: 3 additions & 1 deletion front/capstone_front/lib/services/login_service.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';

Future<String> login(String email, String pw) async {
try {
Expand All @@ -10,7 +11,8 @@ Future<String> login(String email, String pw) async {
user = FirebaseAuth.instance.currentUser;

if (user!.emailVerified) {
user = credential.user;
FlutterSecureStorage storage = const FlutterSecureStorage();
await storage.write(key: 'uuid', value: user.uid);
return "success";
} else {
return "email";
Expand Down
8 changes: 4 additions & 4 deletions front/capstone_front/lib/utils/white_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class _WhiteBoxState extends State<WhiteBox> {
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.3),
spreadRadius: 0,
blurRadius: 2.0,
offset: const Offset(0, 3), // changes position of shadow
color: Colors.black.withOpacity(0.15),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3),
),
],
),
Expand Down

0 comments on commit fa6b239

Please sign in to comment.