// lib/login_screen.dart
import 'package:flutter/material.dart';

class LoginScreen extends StatelessWidget {
  final Function(String) onLogin;

  LoginScreen({required this.onLogin});

  final TextEditingController _usernameController = TextEditingController();
  final TextEditingController _passwordController = TextEditingController();

  void _handleLogin() {
    final username = _usernameController.text;
    if (username.isNotEmpty) {
      onLogin(username);
    }
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(16.0),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          TextField(
            controller: _usernameController,
            decoration: InputDecoration(labelText: 'ID'),
          ),
          TextField(
            controller: _passwordController,
            decoration: InputDecoration(labelText: '패스워드'),
            obscureText: true,
          ),
          SizedBox(height: 20),
          ElevatedButton(
            onPressed: _handleLogin,
            child: Text('로그인'),
          ),
        ],
      ),
    );
  }
}
