import 'package:flutter/material.dart';

import '../model/tyre_type.dart';

class TyrePicker extends StatelessWidget {
  final void Function(TyreType?) onChanged;
  final TyreType? initialValue;

  const TyrePicker({
    super.key,
    required this.onChanged,
    required this.initialValue,
  });

  @override
  Widget build(BuildContext context) {
    return DropdownButton<TyreType>(
        alignment: AlignmentDirectional.centerEnd,
        value: initialValue,
        items: TyreType.values.map((tyre) {
          return DropdownMenuItem<TyreType>(
            value: tyre,
            child: Text(tyre.string),
          );
        }).toList(),
        onChanged: onChanged);
  }
}

TyreType getTyres() {
  final month = DateTime.now().month;
  if (month > 3 && month < 11) {
    return TyreType.summer;
  }
  return TyreType.winter;
}
