전역 구조 리팩터링 및 테스트 확장

This commit is contained in:
JiWoong Sul
2025-09-29 01:51:47 +09:00
parent c00c0c9ab2
commit fef7108479
70 changed files with 7709 additions and 3185 deletions

View File

@@ -15,6 +15,8 @@ class _LoginPageState extends State<LoginPage> {
final idController = TextEditingController();
final passwordController = TextEditingController();
bool rememberMe = false;
bool isLoading = false;
String? errorMessage;
@override
void dispose() {
@@ -23,7 +25,35 @@ class _LoginPageState extends State<LoginPage> {
super.dispose();
}
void _handleSubmit() {
Future<void> _handleSubmit() async {
if (isLoading) return;
setState(() {
errorMessage = null;
isLoading = true;
});
final id = idController.text.trim();
final password = passwordController.text.trim();
await Future<void>.delayed(const Duration(milliseconds: 600));
if (id.isEmpty || password.isEmpty) {
setState(() {
errorMessage = '아이디와 비밀번호를 모두 입력하세요.';
isLoading = false;
});
return;
}
if (password.length < 6) {
setState(() {
errorMessage = '비밀번호는 6자 이상이어야 합니다.';
isLoading = false;
});
return;
}
if (!mounted) return;
context.go(dashboardRoutePath);
}
@@ -73,9 +103,33 @@ class _LoginPageState extends State<LoginPage> {
],
),
const SizedBox(height: 24),
if (errorMessage != null)
Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Text(
errorMessage!,
style: theme.textTheme.small.copyWith(
color: theme.colorScheme.destructive,
),
),
),
ShadButton(
onPressed: _handleSubmit,
child: const Text('로그인'),
onPressed: isLoading ? null : _handleSubmit,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
if (isLoading) ...[
const SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(strokeWidth: 2),
),
const SizedBox(width: 8),
],
const Text('로그인'),
],
),
),
],
),