import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

class DriverShell extends StatefulWidget {
  const DriverShell({super.key, required this.child});
  final Widget child;

  @override
  State<DriverShell> createState() => _DriverShellState();
}

class _DriverShellState extends State<DriverShell> {
  int _currentIndex = 0;

  void _onTap(int index) {
    setState(() {
      _currentIndex = index;
    });
    switch (index) {
      case 0:
        context.go('/driver');
        break;
      case 1:
        context.go('/driver/collections');
        break;
      case 2:
        context.go('/driver/incident');
        break;
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: widget.child,
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        onTap: _onTap,
        items: const [
          BottomNavigationBarItem(icon: Icon(Icons.route), label: 'Mi Ruta'),
          BottomNavigationBarItem(
            icon: Icon(Icons.location_on),
            label: 'Recolecciones',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.warning),
            label: 'Reportar Falla',
          ),
        ],
      ),
    );
  }
}
