import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/models/eit/get_eit_transaction_model.dart';
import 'package:mohem_flutter_app/provider/eit_provider_model.dart';
import 'package:mohem_flutter_app/widgets/loading_dialog.dart';
import 'package:provider/provider.dart';

class MissingSwipe extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Consumer<EITProviderModel>(
      builder: (context, data, child) {
        return !data.isEitLoaded
            ? LoadingDialog()
            : SizedBox(
                width: double.infinity,
                height: double.infinity,
                child: ListView.separated(
                  itemBuilder: (context, index) {
                    return rowItem(data.eitTransactionList![index]);
                  },
                  separatorBuilder: (context, index) {
                    return 12.height;
                  },
                  itemCount: data.eitTransactionList?.length ?? 0,
                  padding: EdgeInsets.only(left: 21, right: 21),
                ));
      },
    );
  }

  Widget rowItem(CollectionTransaction types) {
    return InkWell(
      onTap: () {
        // Navigator.pushNamed(context, AppRoutes.missingSwipe);
      },
      child: Container(
        width: double.infinity,
        padding: EdgeInsets.all(12),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(10),
          boxShadow: [
            BoxShadow(
              color: const Color(0xff000000).withOpacity(.05),
              blurRadius: 26,
              offset: const Offset(0, -3),
            ),
          ],
        ),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Container(
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(4),
                gradient: LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomRight, colors: [Colors.red, Colors.blue]),
              ),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  SvgPicture.asset(
                    "assets/images/miss_swipe.svg",
                    color: Colors.white,
                  ),
                  2.height,
                  Text(types.aPPLICATIONCOLUMNNAME.toString())
                ],
              ).paddingAll(6),
            ),
            12.width,
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  "Missing Swipe Request".toText16(),
                  "Missing Swipe Request for Hussain, Mohammad has been approved".toText10(),
                  12.height,
                  Row(
                    children: [
                      Expanded(child: "07 Jan 2021".toText10(color: MyColors.lightTextColor)),
                      SvgPicture.asset(
                        "assets/images/arrow_next.svg",
                        color: MyColors.darkIconColor,
                      )
                    ],
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
