import 'package:fcs/domain/entities/custom_duty.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';

typedef SelectionCallback(CustomDuty custom);

class CustomRow extends StatelessWidget {
  final CustomDuty custom;
  final SelectionCallback selectionCallback;
  const CustomRow({Key key, this.custom, this.selectionCallback})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: selectionCallback == null
          ? null
          : () => this.selectionCallback(custom),
      child: Row(
        children: <Widget>[
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                line(context, custom.productType,
                    iconData: MaterialCommunityIcons.account,
                    color: primaryColor,
                    fontSize: 16),
                line(context, custom.fee.toString(),
                    iconData: Icons.phone, color: primaryColor, fontSize: 16),
              ],
            ),
          ),
        ],
      ),
    );
  }

  Widget line(BuildContext context, String text,
      {IconData iconData, Color color, double fontSize}) {
    return Row(
      children: [
        iconData == null
            ? SizedBox(width: 40)
            : Padding(
                padding: const EdgeInsets.only(left: 8.0, right: 8),
                child: Icon(iconData, color: Colors.black38),
              ),
        Flexible(
          child: TextLocalStyle(
            context,
            text ?? "",
            fontSize: fontSize ?? 14,
            color: color,
          ),
        ),
      ],
    );
  }
}
