// ๐Ÿ› ๏ธ ์‹œ์Šคํ…œ ๊ด€๋ฆฌ์ž ๋Œ€์‹œ๋ณด๋“œ (UI ์ „์šฉ). ์ถœ์„ DB ์ „์ฒด ์ดˆ๊ธฐํ™” ๋ฒ„ํŠผ์„ ๊ทธ๋ฆฐ๋‹ค. // ์„œ๋ฒ„ ํ†ต์‹ /์ƒํƒœ๋Š” lib/function/admin_controller.dart๊ฐ€ ๋‹ด๋‹นํ•œ๋‹ค. import 'package:flutter/material.dart'; import '../function/admin_controller.dart'; import '../theme/app_palette.dart'; import 'login_screen.dart'; // ========================================== // ๐Ÿ› ๏ธ 5. ๊ด€๋ฆฌ์ž ๋Œ€์‹œ๋ณด๋“œ (DB ์ดˆ๊ธฐํ™” ์•”ํ˜ธ ํŒŒ๋ผ๋ฏธํ„ฐ ๋ณด์ • ์™„๋ฃŒ) // ========================================== class AdminDashboard extends StatefulWidget { const AdminDashboard({super.key}); @override State createState() => _AdminDashboardState(); } class _AdminDashboardState extends State { final AdminController _controller = AdminController(); @override void dispose() { _controller.dispose(); super.dispose(); } Future _resetDatabase() async { final message = await _controller.resetDatabase(); if (!mounted) return; ScaffoldMessenger.of( context, ).showSnackBar(SnackBar(content: Text(message))); } void _showResetConfirmDialog() { showDialog( context: context, builder: (BuildContext dialogContext) { return AlertDialog( title: const Text( 'DB ์ดˆ๊ธฐํ™” ๊ฒฝ๊ณ ', style: TextStyle(color: Colors.red, fontWeight: FontWeight.bold), ), content: const Text( '๋ชจ๋“  ํ•™์ƒ์˜ ์ถœ์„ ๋ฐ ํœด๋Œ€ํฐ ์ œ์ถœ ๋ฐ์ดํ„ฐ๊ฐ€ ์˜๊ตฌ์ ์œผ๋กœ ์‚ญ์ œ๋ฉ๋‹ˆ๋‹ค.\n\n์ •๋ง ์ดˆ๊ธฐํ™”ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?', ), actions: [ TextButton( onPressed: () => Navigator.pop(dialogContext), child: const Text('์ทจ์†Œ', style: TextStyle(color: Colors.grey)), ), ElevatedButton( style: ElevatedButton.styleFrom(backgroundColor: Colors.red), 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( title: const Text('๊ด€๋ฆฌ์ž ์‹œ์Šคํ…œ'), backgroundColor: AppPalette.ink, foregroundColor: AppPalette.paper, 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: 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: Colors.red) : SizedBox( width: double.infinity, height: 60, child: ElevatedButton.icon( style: ElevatedButton.styleFrom( backgroundColor: Colors.red[50], foregroundColor: Colors.red, side: const BorderSide( color: Colors.red, 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, ), ), ], ), ), ), ); }, ); } }