import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:krow/core/presentation/styles/kw_box_decorations.dart';
import 'package:krow/core/presentation/styles/kw_text_styles.dart';
import 'package:krow/core/presentation/styles/theme.dart';
import 'package:krow/features/earning/domain/entities/earning_shift_entity.dart';

class EarningCardCompactWidget extends StatelessWidget {
  final EarningShiftEntity earningEntity;

  const EarningCardCompactWidget({
    super.key,
    required this.earningEntity,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: KwBoxDecorations.primaryLight12,
      height: 72,
      margin: const EdgeInsets.only(bottom: 12, left: 16, right: 16),
      padding: const EdgeInsets.all(12),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          _buildContent(),
        ],
      ),
    );
  }

  Widget _buildContent() {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        ClipOval(
            child: CachedNetworkImage(
          imageUrl: earningEntity.businessImageUrl,
          fit: BoxFit.cover,
          height: 48,
          width: 48,
        )),
        const Gap(12),
        Expanded(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.center,
            mainAxisSize: MainAxisSize.max,
            children: [
              const Gap(5),
              Text(
                earningEntity.skillName,
                style: AppTextStyles.bodyMediumMed,
              ),
              const Gap(4),
              Text(
                earningEntity.businessName,
                style: AppTextStyles.bodySmallReg
                    .copyWith(color: AppColors.blackGray),
              ),
              const Gap(5),
            ],
          ),
        ),
        const Gap(24),
        Padding(
          padding: const EdgeInsets.only(top: 5),
          child: Text(
            '\$${earningEntity.earned}',
            style: AppTextStyles.bodyMediumMed,
          ),
        ),
      ],
    );
  }
}
