// πŸ‘¨β€πŸ« ꡐ사 νšŒμ›κ°€μž… ν™”λ©΄ (UI μ „μš©). μ„œλ²„ 톡신/μƒνƒœλŠ” // lib/function/teacher_register_controller.dartκ°€ λ‹΄λ‹Ήν•œλ‹€. import 'package:flutter/material.dart'; import '../function/teacher_register_controller.dart'; import '../theme/app_palette.dart'; class TeacherRegisterScreen extends StatefulWidget { const TeacherRegisterScreen({super.key}); @override State createState() => _TeacherRegisterScreenState(); } class _TeacherRegisterScreenState extends State { final TeacherRegisterController _controller = TeacherRegisterController(); final _idController = TextEditingController(); final _pwController = TextEditingController(); final _nameController = TextEditingController(); final _secretController = TextEditingController(); @override void dispose() { _controller.dispose(); _idController.dispose(); _pwController.dispose(); _nameController.dispose(); _secretController.dispose(); super.dispose(); } Future _registerTeacher() async { String id = _idController.text.trim(); String pw = _pwController.text.trim(); String name = _nameController.text.trim(); String secret = _secretController.text.trim(); if (id.isEmpty || pw.isEmpty || name.isEmpty || secret.isEmpty) { ScaffoldMessenger.of( context, ).showSnackBar(const SnackBar(content: Text('λͺ¨λ“  λΉˆμΉΈμ„ μž…λ ₯ν•΄ μ£Όμ„Έμš”.'))); return; } final (success, message) = await _controller.registerTeacher( id: id, password: pw, name: name, secretCode: secret, ); if (!mounted) return; ScaffoldMessenger.of( context, ).showSnackBar(SnackBar(content: Text(message))); if (success) { Navigator.pop(context); // κ°€μž… 성곡 μ‹œ 둜그인 ν™”λ©΄μœΌλ‘œ 볡귀 } } @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, ), body: SingleChildScrollView( padding: const EdgeInsets.all(24.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'ꡐ직원 μ „μš© 인증', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), const SizedBox(height: 4), const Text( 'ν•™κ΅μ—μ„œ λ°œκΈ‰ν•œ ꡐ사 κ°€μž… λΉ„λ°€μ½”λ“œκ°€ ν•„μš”ν•©λ‹ˆλ‹€.', style: TextStyle(color: Colors.grey), ), const SizedBox(height: 24), TextField( controller: _secretController, obscureText: true, decoration: const InputDecoration( labelText: 'ꡐ사 인증 λΉ„λ°€μ½”λ“œ μž…λ ₯', border: OutlineInputBorder(), ), ), const SizedBox(height: 16), const Divider(), const SizedBox(height: 16), TextField( controller: _idController, decoration: const InputDecoration( labelText: 'ꡐ직원 번호 (ID둜 μ‚¬μš©)', border: OutlineInputBorder(), ), ), const SizedBox(height: 12), TextField( controller: _nameController, decoration: const InputDecoration( labelText: 'μ„ μƒλ‹˜ 성함', border: OutlineInputBorder(), ), ), const SizedBox(height: 12), TextField( controller: _pwController, obscureText: true, decoration: const InputDecoration( labelText: 'μ‚¬μš©ν•  λΉ„λ°€λ²ˆν˜Έ μž…λ ₯', border: OutlineInputBorder(), ), ), const SizedBox(height: 24), SizedBox( width: double.infinity, height: 50, child: ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: AppPalette.ink, foregroundColor: AppPalette.paper, ), onPressed: _controller.isLoading ? null : _registerTeacher, child: _controller.isLoading ? const CircularProgressIndicator(color: Colors.white) : const Text('ꡐ사 계정 μƒμ„±ν•˜κΈ°'), ), ), ], ), ), ); }, ); } }