import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';

class TimeRegionComponent extends StatefulWidget {
  final TimeRegionDetails details;
  const TimeRegionComponent({super.key, required this.details});

  @override
  State<TimeRegionComponent> createState() => _TimeRegionComponentState();
}

class _TimeRegionComponentState extends State<TimeRegionComponent> {
  @override
  Widget build(BuildContext context) {
    var text = widget.details.region.text!;
    var color = widget.details.region.color;

    if (text == 'centerIcon') {
      return Container(
        color: color,
        alignment: Alignment.center,
        child: Icon(
          widget.details.region.iconData,
          size: 17,
          color: Theme.of(context).primaryColor,
        ),
      );
    } else if(text.startsWith('holiday')) {
      return Container(
        color: color,
        alignment: Alignment.center,
        child: Column(
          children: [
            const SizedBox(height: 15),
            const Icon(Icons.cake),
            const Text('FREI'),
            const SizedBox(height: 10),
            RotatedBox(
              quarterTurns: 1,
              child: Text(
                text.split(':').last,
                maxLines: 1,
                style: const TextStyle(
                  fontWeight: FontWeight.bold,
                  fontSize: 15,
                  decorationStyle: TextDecorationStyle.dashed,
                  letterSpacing: 2,
                ),
              ),
            ),
          ],
        ),
      );
    }

    return const Placeholder();
  }
}