allscore_app/lib/dialogs/settings_dialog.dart

88 lines
3.2 KiB
Dart
Raw Normal View History

2025-01-07 13:38:36 +00:00
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart'; // SharedPreferences 임포트
import '../views/login/login_page.dart'; // 로그인 페이지 임포트 (상위 디렉토리로 이동)
import '../views/user/my_page.dart'; // 마이페이지 임포트 (상위 디렉토리로 이동)
void showSettingsDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: Colors.white,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: MediaQuery.of(context).size.width * 0.2,
child: const Text(
'',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
Container(
width: MediaQuery.of(context).size.width * 0.2,
child: const Text(
'설정',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
IconButton(
icon: const Icon(Icons.close, color: Colors.black),
onPressed: () {
Navigator.of(context).pop();
},
),
],
),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 10),
SizedBox(
width: double.infinity,
child: TextButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => const MyPage()), // 마이페이지로 이동
);
},
style: ButtonStyle(
side: MaterialStateProperty.all(const BorderSide(color: Colors.black)),
foregroundColor: MaterialStateProperty.all(Colors.black),
),
child: const Text('내 정보 관리'),
),
),
const SizedBox(height: 10),
SizedBox(
width: double.infinity,
child: TextButton(
onPressed: () async {
// 로그아웃 클릭 시 동작
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString('auth_token', ''); // auth_token 초기화
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => const LoginPage()), // 로그인 페이지로 이동
);
},
style: ButtonStyle(
side: MaterialStateProperty.all(const BorderSide(color: Colors.black)),
foregroundColor: MaterialStateProperty.all(Colors.black),
),
child: const Text('로그아웃'),
),
),
],
),
);
},
);
}