- 프로필 꾸미기: 미리보기 중인 큰 타일의 테두리도 테마 색으로 바뀌게 수정, 미구매 템플릿에 "체험하기" 버튼을 따로 둬서 사기 전에도 눌러볼 수 있게 함 - 앱 전반의 확인/삭제/저장 같은 다이얼로그 기본 액션 버튼에 autofocus를 줘서 엔터 키로도 눌리게 함 (텍스트 입력이 있는 다이얼로그는 입력창 쪽에 autofocus + onSubmitted를 달아 입력 중 바로 엔터로 제출되게 처리) - HoldToRevealPasswordField 위젯 추가 - 눈 아이콘을 누르고 있는 동안만 비밀번호가 평문으로 보임. 로그인/간편인증/초기 비밀번호 변경 화면에 적용
161 lines
5.5 KiB
Dart
161 lines
5.5 KiB
Dart
// 🛠️ 시스템 관리자 대시보드 (UI 전용). 출석 DB 전체 초기화 버튼을 그린다.
|
|
// 서버 통신/상태는 lib/function/admin_controller.dart가 담당한다.
|
|
import 'package:flutter/material.dart';
|
|
import '../function/admin_controller.dart';
|
|
import '../theme/app_palette.dart';
|
|
import 'app_notice.dart';
|
|
import 'login_screen.dart';
|
|
import 'title_pill.dart';
|
|
|
|
// ==========================================
|
|
// 🛠️ 5. 관리자 대시보드 (DB 초기화 암호 파라미터 보정 완료)
|
|
// ==========================================
|
|
class AdminDashboard extends StatefulWidget {
|
|
const AdminDashboard({super.key});
|
|
|
|
@override
|
|
State<AdminDashboard> createState() => _AdminDashboardState();
|
|
}
|
|
|
|
class _AdminDashboardState extends State<AdminDashboard> {
|
|
final AdminController _controller = AdminController();
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
Future<void> _resetDatabase() async {
|
|
final message = await _controller.resetDatabase();
|
|
if (!mounted) return;
|
|
AppNotice.show(context, message);
|
|
}
|
|
|
|
void _showResetConfirmDialog() {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext dialogContext) {
|
|
return AlertDialog(
|
|
title: const Text(
|
|
'DB 초기화 경고',
|
|
style: TextStyle(
|
|
color: AppPalette.danger,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
content: const Text(
|
|
'모든 학생의 출석 및 휴대폰 제출 데이터가 영구적으로 삭제됩니다.\n\n정말 초기화하시겠습니까?',
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(dialogContext),
|
|
child: const Text('취소', style: TextStyle(color: Colors.grey)),
|
|
),
|
|
ElevatedButton(
|
|
autofocus: true,
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: AppPalette.danger,
|
|
),
|
|
onPressed: () {
|
|
Navigator.pop(dialogContext);
|
|
_resetDatabase();
|
|
},
|
|
child: const Text(
|
|
'초기화 실행',
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListenableBuilder(
|
|
listenable: _controller,
|
|
builder: (context, _) {
|
|
return Scaffold(
|
|
backgroundColor: AppPalette.mist,
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.transparent,
|
|
foregroundColor: AppPalette.ink,
|
|
elevation: 0,
|
|
centerTitle: true,
|
|
title: const TitlePill('관리자 시스템'),
|
|
actions: [
|
|
IconButton(
|
|
icon: const Icon(Icons.logout),
|
|
onPressed: () => Navigator.pushReplacement(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => const LoginScreen()),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
body: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24.0),
|
|
child: ConstrainedBox(
|
|
constraints: const BoxConstraints(maxWidth: 420),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Icon(
|
|
Icons.admin_panel_settings,
|
|
size: 100,
|
|
color: AppPalette.ink,
|
|
),
|
|
const SizedBox(height: 20),
|
|
const Text(
|
|
'데이터베이스 관리',
|
|
style: TextStyle(
|
|
fontSize: 22,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(height: 40),
|
|
|
|
_controller.isLoading
|
|
? const CircularProgressIndicator(
|
|
color: AppPalette.danger,
|
|
)
|
|
: SizedBox(
|
|
width: double.infinity,
|
|
height: 60,
|
|
child: ElevatedButton.icon(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: AppPalette.dangerBg,
|
|
foregroundColor: AppPalette.danger,
|
|
side: const BorderSide(
|
|
color: AppPalette.danger,
|
|
width: 2,
|
|
),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
icon: const Icon(Icons.delete_forever, size: 28),
|
|
label: const Text(
|
|
'모든 출석 데이터 초기화',
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
onPressed: _showResetConfirmDialog,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|