allscore_app/lib/dialogs/settings_dialog.dart

129 lines
4.6 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'; // 마이페이지 임포트 (상위 디렉토리로 이동)
2025-01-20 05:45:55 +00:00
import '../views/inquiry/inquiry_to_manager_page.dart'; // 문의하기 페이지 임포트 (상위 디렉토리로 이동)
2025-01-07 13:38:36 +00:00
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.1,
2025-01-07 13:38:36 +00:00
child: const Text(
'',
// 공백 (디자인용)
2025-01-07 13:38:36 +00:00
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
Container(
width: MediaQuery.of(context).size.width * 0.3,
2025-01-07 13:38:36 +00:00
child: const Text(
'Settings',
// '설정'
2025-01-07 13:38:36 +00:00
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: () {
// Navigate to My Page
// '내 정보 관리' 페이지로 이동
2025-01-07 13:38:36 +00:00
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => const MyPage()),
2025-01-07 13:38:36 +00:00
);
},
style: ButtonStyle(
side: MaterialStateProperty.all(const BorderSide(color: Colors.black)),
foregroundColor: MaterialStateProperty.all(Colors.black),
),
child: const Text(
'Manage My Info',
// '내 정보 관리'
),
2025-01-07 13:38:36 +00:00
),
),
const SizedBox(height: 10),
SizedBox(
width: double.infinity,
2025-01-20 05:45:55 +00:00
child: TextButton(
onPressed: () {
// Navigate to Inquiry Page
// '문의하기' 페이지로 이동
2025-01-20 05:45:55 +00:00
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => const InquiryToManagerPage()),
2025-01-20 05:45:55 +00:00
);
},
style: ButtonStyle(
side: MaterialStateProperty.all(const BorderSide(color: Colors.black)),
foregroundColor: MaterialStateProperty.all(Colors.black),
),
child: const Text(
'Contact Us',
// '문의하기'
),
2025-01-20 05:45:55 +00:00
),
),
const SizedBox(height: 10),
SizedBox(
width: double.infinity,
2025-01-07 13:38:36 +00:00
child: TextButton(
onPressed: () async {
// Logout
// '로그아웃' 클릭 시 동작
2025-01-07 13:38:36 +00:00
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString('auth_token', '');
// auth_token 초기화
await prefs.setBool('auto_login', false);
// auto_login 초기화
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) => const LoginPage()),
// 로그인 페이지로 이동
(route) => false,
2025-01-07 13:38:36 +00:00
);
},
style: ButtonStyle(
side: MaterialStateProperty.all(const BorderSide(color: Colors.black)),
foregroundColor: MaterialStateProperty.all(Colors.black),
),
child: const Text(
'Logout',
// '로그아웃'
),
2025-01-07 13:38:36 +00:00
),
),
],
),
);
},
);
}