MY 화면에 로그아웃(확인 후 로그인 화면으로 복귀) 추가

This commit is contained in:
Sn-Kinos
2026-10-11 00:29:44 +09:00
parent bc19797158
commit 897dff950d
4 changed files with 73 additions and 3 deletions
+1 -1
View File
@@ -136,7 +136,7 @@ GoRouter buildRouter(AuthRepository auth, {FeatureFlags? flags}) {
routes: [
GoRoute(
path: appTabs[4].path,
builder: (_, _) => const MyScreen(),
builder: (_, _) => MyScreen(auth: auth),
),
],
),
+8
View File
@@ -13,6 +13,7 @@ class TabPlaceholder extends StatelessWidget {
required this.tab,
required this.screenId,
required this.screenName,
this.footer,
});
/// 계약 고정 탭 라벨(견적서 v2.1 5탭).
@@ -20,6 +21,9 @@ class TabPlaceholder extends StatelessWidget {
final String screenId;
final String screenName;
/// 자리표시 아래에 붙는 동작(예: MY 의 로그아웃). 없으면 그리지 않는다.
final Widget? footer;
@override
Widget build(BuildContext context) {
final text = Theme.of(context).textTheme;
@@ -55,6 +59,10 @@ class TabPlaceholder extends StatelessWidget {
],
),
),
if (footer != null) ...[
const SizedBox(height: AppSpace.s5),
footer!,
],
],
),
),
+35 -2
View File
@@ -1,15 +1,48 @@
import 'package:flutter/material.dart';
import '../../core/ui/tab_placeholder.dart';
import '../auth/auth_repository.dart';
/// MY 탭 루트 — S-M-HOME 마이 페이지.
///
/// 화면 구현 전이라도 로그아웃은 여기서 할 수 있어야 한다 — 다른 계정 · 다른 로그인
/// 방법으로 다시 들어가 볼 길이 없으면 소셜 로그인 4종을 한 기기에서 확인할 수 없다.
/// 로그아웃하면 인증 상태가 바뀌고 라우터가 로그인 화면으로 보낸다.
class MyScreen extends StatelessWidget {
const MyScreen({super.key});
const MyScreen({super.key, required this.auth});
final AuthRepository auth;
Future<void> _logout(BuildContext context) async {
final ok = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
content: const Text('로그아웃 하시겠습니까?'),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text('취소'),
),
FilledButton(
onPressed: () => Navigator.of(context).pop(true),
child: const Text('로그아웃'),
),
],
),
);
if (ok == true) await auth.signOut();
}
@override
Widget build(BuildContext context) => const TabPlaceholder(
Widget build(BuildContext context) => TabPlaceholder(
tab: 'MY',
screenId: 'S-M-HOME',
screenName: '마이 페이지',
footer: Builder(
builder: (context) => OutlinedButton(
onPressed: () => _logout(context),
child: const Text('로그아웃'),
),
),
);
}