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

import '../controller/home_controller.dart';
import '../helper/helper.dart';

class MyDropDownYear extends StatelessWidget {
  const MyDropDownYear({super.key, required this.homCtrl});

  final HomeController homCtrl;

  @override
  Widget build(BuildContext context) {
    return Obx(
      () => DropdownButton<int>(
        menuWidth: 150,
        value: homCtrl.currentYear.value,
        dropdownColor: Colors.blueGrey,
        underline: Container(),
        style: const TextStyle(color: Colors.white, fontSize: 16),
        items: kListDropDownYear.map((year) {
          return DropdownMenuItem<int>(
            value: year,
            child: Text(year.toString()),
          );
        }).toList(),
        onChanged: (selectedYear) {
          if (selectedYear != null) {
            homCtrl.changeYear(selectedYear);
          }
        },
      ),
    );
  }
}
