import 'package:flutter/material.dart';
import '../models/hospital.dart';
import '../services/medical_service.dart';
import 'doctor_list_screen.dart';

class DepartmentScreen extends StatelessWidget {
  final Hospital hospital;
  
  const DepartmentScreen({required this.hospital});
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('选择科室')),
      body: GridView.builder(
        padding: EdgeInsets.all(16),
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 3,
          crossAxisSpacing: 12,
          mainAxisSpacing: 12,
        ),
        itemCount: hospital.departments.length,
        itemBuilder: (context, index) {
          final department = hospital.departments[index];
          return Card(
            child: InkWell(
              onTap: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (_) => DoctorListScreen(
                      hospital: hospital,
                      department: department,
                    ),
                  ),
                );
              },
              child: Center(
                child: Text(
                  department,
                  style: TextStyle(fontSize: 16),
                ),
              ),
            ),
          );
        },
      ),
    );
  }
}
