import 'package:flutter/material.dart';
import 'status_card.dart';
import '../../../product/extension/context_extension.dart';
import '../../../product/services/language_services.dart';

class OverviewCard extends StatefulWidget {
  final bool isOwner;
  final int total;
  final int active;
  final int inactive;
  final int warning;
  final int unused;
  final bool showTotal;
  final bool showActive;
  final bool showInactive;
  final bool showWarning;
  final bool showUnused;

  const OverviewCard({
    super.key,
    required this.isOwner,
    required this.total,
    required this.active,
    required this.inactive,
    required this.warning,
    required this.unused,
    this.showTotal = true,
    this.showActive = true,
    this.showInactive = true,
    this.showWarning = true,
    this.showUnused = true,
  });

  @override
  State<OverviewCard> createState() => _OverviewCardState();
}

class _OverviewCardState extends State<OverviewCard> {
  @override
  Widget build(BuildContext context) {
    return FittedBox(
      alignment: Alignment.topCenter,
      child: SizedBox(
        width: context.width,
        child: Card(
          // elevation: 8,
          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
          child: Padding(
            padding: context.paddingNormal,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Text(
                  widget.isOwner
                      ? appLocalization(context).overview_message
                      : appLocalization(context).interfamily_page_name,
                  style: context.h2,
                ),
                SizedBox(height: context.normalValue),
                Column(
                  children: [
                    if (widget.showTotal)
                      StatusCard(
                        label: appLocalization(context).total_nof_devices_message,
                        count: widget.total,
                        color: Colors.blue,
                      ),
                    if (widget.showActive)
                      StatusCard(
                        label: appLocalization(context).active_devices_message,
                        count: widget.active,
                        color: Colors.green,
                      ),
                    if (widget.showInactive)
                      StatusCard(
                        label: appLocalization(context).inactive_devices_message,
                        count: widget.inactive,
                        color: Colors.grey,
                      ),
                    if (widget.showWarning)
                      StatusCard(
                        label: appLocalization(context).warning_devices_message,
                        count: widget.warning,
                        color: Colors.orange,
                      ),
                    if (widget.showUnused)
                      StatusCard(
                        label: appLocalization(context).unused_devices_message,
                        count: widget.unused,
                        color: Colors.yellow,
                      ),
                  ],
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
