import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';

import 'callbacks.dart';
import 'display_text.dart';
import 'local_text.dart';

class DefaultDeliveryAddress extends StatelessWidget {
  final DeliveryAddress deliveryAddress;
  final String labelKey;
  final OnTap onTap;
  final IconData iconData;

  const DefaultDeliveryAddress(
      {Key key, this.deliveryAddress, this.onTap, this.labelKey, this.iconData})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          children: [
            Expanded(
              child: this.labelKey == null
                  ? Container()
                  : DisplayText(
                      labelTextKey: this.labelKey,
                      iconData: iconData ?? MaterialCommunityIcons.truck_fast,
                    ),
            ),
            onTap == null
                ? Container()
                : GestureDetector(
                    onTap: () => onTap(),
                    child: Chip(
                        label: LocalText(
                            context, "delivery_address.change_address",
                            color: primaryColor)),
                  )
          ],
        ),
        Padding(
          padding: const EdgeInsets.only(left: 28.0),
          child: deliveryAddress == null
              ? Container()
              : DeliveryAddressRow(
                  key: ValueKey(deliveryAddress.id),
                  deliveryAddress: deliveryAddress),
        ),
      ],
    );
  }
}
