import 'package:flutter/material.dart';
import 'package:test_sa/models/visits/visit.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';

class VisitStatusLabel extends StatelessWidget {
  final Visit visit;

  const VisitStatusLabel({Key key, 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: EdgeInsets.symmetric(vertical: 2, horizontal: 8),
        alignment: Alignment.center,
        decoration: BoxDecoration(color: getStatusColor(), borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [AppStyle.boxShadow]),
        child: Text(
          visit.status.name == null || visit.status.name.isEmpty ? "no status" : visit.status.name,
          style: Theme.of(context).textTheme.subtitle2.copyWith(
                color: getStatusColor().computeLuminance() > 0.5 ? AColors.black : Colors.white,
              ),
        ));
  }
}
