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

import '../../../../common/extension/extension.dart';
import '../../../../common/theme/theme.dart';
import '../../../../domain/analytic/analytic.dart';
import '../../../components/spacer/spacer.dart';
import 'stats_tile.dart';
import 'title.dart';

class HomeStats extends StatelessWidget {
  final DashboardOverview overview;
  const HomeStats({super.key, required this.overview});

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(
        vertical: 24,
        horizontal: AppValue.padding,
      ).copyWith(bottom: 0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          HomeTitle(title: context.lang.today_summary),
          const SpaceHeight(20),
          Row(
            children: [
              Expanded(
                child: HomeStatsTile(
                  title: context.lang.order,
                  value: overview.totalOrders.toString(),
                  icon: Icons.receipt_long_rounded,
                  color: AppColor.info,
                  subtitle: context.lang.today,
                ),
              ),

              const SpaceWidth(16),
              Expanded(
                child: HomeStatsTile(
                  title: context.lang.new_customer,
                  value: overview.totalCustomers.toString(),
                  icon: Icons.person_add_outlined,
                  color: AppColor.primary,
                  subtitle: overview.totalCustomers < 1
                      ? context.lang.today
                      : context.lang.increase,
                ),
              ),
            ],
          ),
          const SizedBox(height: 16),
          Row(
            children: [
              Expanded(
                child: HomeStatsTile(
                  title: context.lang.refund,
                  value: overview.refundedOrders.toString(),
                  icon: LineIcons.alternateExchange,
                  color: AppColor.warning,
                  subtitle: context.lang.today,
                ),
              ),
              const SpaceWidth(16),
              Expanded(
                child: HomeStatsTile(
                  title: context.lang.void_text,
                  value: overview.voidedOrders.toString(),
                  icon: Icons.cancel_rounded,
                  color: AppColor.error,
                  subtitle: context.lang.today,
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
