import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../providers/app_lock_provider.dart';
import '../theme/app_colors.dart';

class AppLockScreen extends StatelessWidget {
  const AppLockScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Icon(
              Icons.lock_outline,
              size: 80,
              color: AppColors.navyGray,
            ),
            const SizedBox(height: 24),
            Text(
              '앱이 잠겨 있습니다',
              style: TextStyle(
                fontSize: 24,
                fontWeight: FontWeight.bold,
                color: AppColors.darkNavy,
              ),
            ),
            const SizedBox(height: 16),
            Text(
              '생체 인증으로 잠금을 해제하세요',
              style: TextStyle(
                fontSize: 16,
                color: AppColors.navyGray,
              ),
            ),
            const SizedBox(height: 32),
            ElevatedButton.icon(
              onPressed: () async {
                final appLock = context.read<AppLockProvider>();
                final success = await appLock.authenticate();
                if (!success && context.mounted) {
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(
                      content: Text(
                        '인증에 실패했습니다. 다시 시도해주세요.',
                        style: TextStyle(
                          color: AppColors.pureWhite,
                        ),
                      ),
                      backgroundColor: AppColors.dangerColor,
                    ),
                  );
                }
              },
              icon: const Icon(Icons.fingerprint),
              label: const Text('생체 인증으로 잠금 해제'),
              style: ElevatedButton.styleFrom(
                padding: const EdgeInsets.symmetric(
                  horizontal: 24,
                  vertical: 12,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
