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

class WMonth extends StatelessWidget {
  const WMonth({super.key, this.date, this.selected = false});
  final dynamic date;
  final bool selected;
  @override
  Widget build(BuildContext context) {
    Jiffy jdate;
    if (date is Jiffy) {
      jdate = Jiffy.parseFromJiffy(date);
    } else if (date is String) {
      jdate = Jiffy.parse(date, isUtc: true);
    } else if (date is List) {
      jdate = Jiffy.parseFromList(date, isUtc: true);
    } else {
      jdate = Jiffy.now().toUtc();
    }
    return Container(
      height: 80.0,
      width: 80.0,
      margin: const EdgeInsets.all(5.0),
      decoration: BoxDecoration(
        gradient: const LinearGradient(
          colors: [
            Color.fromRGBO(112, 64, 103, 1),
            Color.fromRGBO(84, 1, 68, 1),
          ],
          begin: Alignment.centerLeft,
          end: Alignment.centerRight,
        ),
        border: Border.all(color: selected ? Colors.yellow : Colors.black),
        borderRadius: const BorderRadius.all(
          Radius.circular(15.0),
        ),
        boxShadow: const [
          BoxShadow(
            color: Colors.black26,
            spreadRadius: 2,
            blurRadius: 8,
            offset: Offset(3, 3),
          )
        ],
      ),
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            Text(
              jdate.format(pattern: "MMM").toUpperCase(),
              textAlign: TextAlign.center,
              style: const TextStyle(
                letterSpacing: 2,
                fontSize: 24,
                fontWeight: FontWeight.bold,
                color: Colors.white,
              ),
            ),
            Text(
              jdate.format(pattern: "yyyy").toUpperCase(),
              textAlign: TextAlign.center,
              style: const TextStyle(
                fontSize: 16,
                color: Colors.white,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
