import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:worker_client/models/entities/BankCard.dart';

class BankCard extends StatelessWidget {
  const BankCard({Key? key, required this.item, required this.unBind})
      : super(key: key);
  final BankCardModel item;
  final GestureTapCallback unBind;

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(15.w),
      margin: EdgeInsets.only(bottom: 15.h),
      height: 112.5.w,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(10.w),
        gradient: LinearGradient(
          begin: Alignment.topLeft,
          end: Alignment.bottomRight,
          colors: [
            Color(int.parse('0xff' + item.color2.toString())),
            Color(int.parse('0xff' + item.color1.toString()))
          ],
        ),
      ),
      child: Stack(
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                  width: 30.w,
                  height: 30.w,
                  alignment: Alignment.center,
                  margin: EdgeInsets.only(right: 15.w),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(15.w),
                      color: Colors.white),
                  child: Image.network(
                    item.bankCode.toString(),
                    width: 20.w,
                    fit: BoxFit.cover,
                  )),
              Expanded(
                flex: 1,
                child: Text(
                  item.ownerBank.toString()+'储蓄卡',
                  style: const TextStyle(
                    color: Colors.white,
                  ),
                ),
              ),
              Text(
                '**** ' +
                    item.cardNo
                        .substring(item.cardNo.length - 4, item.cardNo.length),
                style: const TextStyle(
                  color: Colors.white,
                ),
              ),
            ],
          ),
          Positioned(
            bottom: 0,
            right: 0,
            child: GestureDetector(
              onTap: unBind,
              child: const Text(
                '解除绑定',
                style: TextStyle(
                  color: Colors.white,
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
