import 'package:flutter/material.dart';

import '../../../models/visits/visit.dart';
import '../../app_style/colors.dart';
import '../../app_style/sizing.dart';

class VisitStatusLabel extends StatelessWidget {
  final Visit visit;

  const VisitStatusLabel({Key? key, required this.visit}) : super(key: key);

  Color getStatusColor() {
    switch (visit.status?.id) {
      case 0:
        return AColors.green;
      case 1:
        return AColors.grey;
      case 2:
        return AColors.grey;
      default:
        return AColors.grey;
    }
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 8),
      alignment: Alignment.center,
      decoration: BoxDecoration(
        color: getStatusColor(),
        borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
        boxShadow: const [AppStyle.boxShadow],
      ),
      child: Text(
        visit.status?.label == null || (visit.status?.label?.isEmpty ?? false) ? "no status" : visit.status?.label ?? "",
        style: Theme.of(context).textTheme.titleSmall?.copyWith(
              color: getStatusColor().computeLuminance() > 0.5 ? AColors.black : Colors.white,
            ),
      ),
    );
  }
}
