Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add logout function #30

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .github/reviewer-lottery.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/reviewer.yml

This file was deleted.

1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class MyApp extends StatelessWidget {
onVerificationSuccess: () {},
),
SplashSellingScreen.id: (context) => const SplashSellingScreen(),
ScreenController.id: (context) => const ScreenController(),
},
);
}
Expand Down
72 changes: 50 additions & 22 deletions lib/screens/mypage/setting.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:saphy/screens/mypage/setting_page/login_info.dart';
import 'package:saphy/screens/welcome/welcome_screen.dart';
import 'package:saphy/service/authentication/google_login_controller.dart';
import 'package:saphy/service/authentication/kakao_login_controller.dart';
import 'package:saphy/service/authentication/main_view_model.dart';
import 'package:saphy/utils/colors.dart';
import 'package:saphy/utils/log.dart';
import 'package:saphy/widgets/normal_button.dart';
import '../../widgets/setting_menu.dart';

class SettingPage extends StatefulWidget {
Expand All @@ -16,84 +23,105 @@ class _SettingPageState extends State<SettingPage> {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: const Text("설정", style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 20,fontFamily: "Pretendard")),
title: const Text("설정",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 20,
fontFamily: "Pretendard")),
backgroundColor: Colors.white,
centerTitle: true,
),
body: SingleChildScrollView(
physics: BouncingScrollPhysics(),
padding: EdgeInsets.all(20.0),
physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
const Text(
"일반",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
SizedBox(
const SizedBox(
height: 10,
),
SettingMenu(
title: "로그인 정보",
icon: Icons.info_outline,
onTap: (){
Navigator.of(context).push(
CupertinoPageRoute(
builder: (context) => const LoginInfo()
)
);
onTap: () {
Navigator.of(context).push(CupertinoPageRoute(
builder: (context) => const LoginInfo()));
},
),
SettingMenu(
const SettingMenu(
title: "주소록",
icon: Icons.list_alt,
onTap: null,
),
SettingMenu(
const SettingMenu(
title: "결제 정보",
icon: Icons.credit_card,
onTap: null,
),
SettingMenu(
const SettingMenu(
title: "판매 정산 계좌",
icon: Icons.monetization_on_outlined,
onTap: null,
),
SettingMenu(
const SettingMenu(
title: "현금영수증 정보",
icon: Icons.receipt_long,
onTap: null,
),
SettingMenu(
const SettingMenu(
title: "알림",
icon: Icons.notifications_none,
onTap: null,
),
SizedBox(
const SizedBox(
height: 20,
),
Text(
const Text(
"정보",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
SizedBox(
const SizedBox(
height: 10,
),
SettingMenu(
const SettingMenu(
title: "이용약관",
icon: Icons.list_alt_sharp,
onTap: null,
),
SettingMenu(
const SettingMenu(
title: "개인정보처리방침",
icon: Icons.security,
onTap: null,
),
SettingMenu(
const SettingMenu(
title: "오픈소스 라이선스",
icon: Icons.code_rounded,
onTap: null,
),
NormalButton(
title: '로그아웃',
bgColor: systemColorRed300,
txtColor: white,
onTap: () {
logger.i("로그아웃 시작");
final googleViewModel = MainViewModel(GoogleLoginController());
googleViewModel.logout();
final kakaoViewModel = MainViewModel(KakaoLoginController());
googleViewModel.logout();
kakaoViewModel.logout();
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => const WelcomeScreen(),
),
);
},
flag: true,
),
],
),
),
Expand Down
1 change: 1 addition & 0 deletions lib/screens/screen_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:saphy/screens/mypage/mypage.dart';
// }

class ScreenController extends StatefulWidget {
static String id = 'screen_controller';
const ScreenController({super.key});

@override
Expand Down
49 changes: 23 additions & 26 deletions lib/screens/welcome/signup_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,36 +83,33 @@ class _SignupScreenState extends State<SignupScreen> {
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
padding:
const EdgeInsets.symmetric(horizontal: 20.0, vertical: 40.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(height: 30.0),
formWidget(context),
Padding(
padding: const EdgeInsets.only(bottom: 20.0),
child: NormalButton(
title: '사피 시작하기',
bgColor: phoneAuth ? mainPrimary : gray400,
txtColor: black,
flag: phoneAuth,
onTap: () async {
logger.i(
'${_nameController.text} / ${_emailController.text} / ${_phoneController.text} / ${widget.userPhotoUrl} /',
);
final code = await joinService(
widget.socialType!,
_emailController.text,
_nameController.text,
_phoneController.text,
);
if (code == 200) {
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (context) => const ScreenController(),
));
}
},
),
NormalButton(
title: '사피 시작하기',
bgColor: phoneAuth ? mainPrimary : gray400,
txtColor: black,
flag: phoneAuth,
onTap: () async {
logger.i(
'${_nameController.text} / ${_emailController.text} / ${_phoneController.text} / ${widget.userPhotoUrl} /',
);
final code = await joinService(
widget.socialType!,
_emailController.text,
_nameController.text,
_phoneController.text,
);
if (code == 200) {
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (context) => const ScreenController(),
));
}
},
)
],
),
Expand Down
5 changes: 5 additions & 0 deletions lib/service/authentication/main_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:saphy/service/authentication/google_login_controller.dart';
import 'package:saphy/service/authentication/kakao_login_controller.dart';
import 'package:saphy/service/authentication/secure_storage.dart';
import 'package:saphy/service/social_login.dart';
import 'package:saphy/utils/log.dart';

class MainViewModel {
final SocialLogin _socialLogin;
Expand Down Expand Up @@ -42,8 +43,12 @@ class MainViewModel {

Future logout() async {
deleteLoginInfo();
deleteAccessToke();
deleteRefreshToke();
deleteJwt();
await _socialLogin.logout(); //로그아웃 실행
isLogined = false; //로그인되어 있는지를 저장하는 변수 false값 저장
user = null; //user 객체 null
logger.i("Logout 성공");
}
}
2 changes: 1 addition & 1 deletion lib/widgets/normal_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NormalButton extends StatelessWidget {
final Color bgColor;
final Color txtColor;
final bool flag;
final Function() onTap;
final VoidCallback onTap;

@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/sign_up_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SignUpForm extends StatelessWidget {
Widget build(BuildContext context) {
textEditingController.text = initialValue;
return Padding(
padding: const EdgeInsets.only(bottom: 10.0),
padding: const EdgeInsets.only(bottom: 20.0),
child: Container(
decoration: BoxDecoration(
shape: BoxShape.rectangle,
Expand Down
Loading