import 'package:flutter/material.dart';

import '../../../resouce/base_color.dart';

class VoucherActionMenu extends StatelessWidget {
  const VoucherActionMenu({super.key});

  @override
  Widget build(BuildContext context) {
    final screenWidth = MediaQuery.of(context).size.width;
    final itemWidth = screenWidth / 4;

    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 12),
      child: Row(
        children: const [
          _ActionItem(icon: "assets/images/ic_topup.png", label: 'Nạp tiền\ndiện thoại'),
          _ActionItem(icon: "assets/images/ic_card_code.png", label: 'Đổi mã\nthẻ nạp'),
          _ActionItem(icon: "assets/images/ic_sim_service.png", label: 'Gói cước\nnhà mạng'),
          _ActionItem(icon: "assets/images/ic_topup_data.png", label: 'Ưu đãi\nData'),
        ],
      ),
    );
  }
}

class _ActionItem extends StatelessWidget {
  final String icon;
  final String label;

  const _ActionItem({required this.icon, required this.label});

  @override
  Widget build(BuildContext context) {
    final screenWidth = MediaQuery.of(context).size.width;
    final itemWidth = screenWidth / 4;

    return SizedBox(
      width: itemWidth,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Image.asset(
            icon,
            fit: BoxFit.cover,
            width: 40,
            height: 40,
          ),
          const SizedBox(height: 8),
          Text(
            label,
            style: const TextStyle(fontSize: 12),
            textAlign: TextAlign.center,
            maxLines: 2,
            overflow: TextOverflow.ellipsis,
          ),
        ],
      ),
    );
  }
}
