import 'dart:io';

import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/svg.dart';
import 'package:generp/Notifiers/commonProvider/accountsListProvider.dart';
import 'package:generp/Utils/ShakeWidget.dart';
import 'package:generp/Utils/app_colors.dart';
import 'package:generp/Utils/commonServices.dart';
import 'package:generp/Utils/commonWidgets.dart';
import 'package:generp/Utils/dropdownTheme.dart';
import 'package:provider/provider.dart';
import 'package:generp/Models/commonModels/DistrictsResponse.dart';
import 'package:generp/Models/commonModels/SubLocationsResponse.dart';

import '../../Models/commonModels/commonAddAccountsViewResponse.dart';

class Addcommonpayment extends StatefulWidget {
  final from;
  const Addcommonpayment({super.key, required this.from});

  @override
  State<Addcommonpayment> createState() => _AddcommonpaymentState();
}

class _AddcommonpaymentState extends State<Addcommonpayment> {
  Dropdowntheme ddtheme = Dropdowntheme();

  List<FocusNode> focusNodes = List.generate(20, (index) => FocusNode());
  Map _source = {ConnectivityResult.mobile: true};
  final MyConnectivity _connectivity = MyConnectivity.instance;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _connectivity.initialise();
    _connectivity.myStream.listen((source) {
      setState(() => _source = source);
    });
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      var prov = Provider.of<Accountslistprovider>(context, listen: false);
      prov.addCommonAccountViewAPI(context);
    });
  }

  @override
  void dispose() {
    focusNodes.map((e) => e.dispose());
    super.dispose();
    _connectivity.disposeStream();
  }

  @override
  Widget build(BuildContext context) {
    switch (_source.keys.toList()[0]) {
      case ConnectivityResult.mobile:
        connection = 'Online';
        break;
      case ConnectivityResult.wifi:
        connection = 'Online';
        break;
      case ConnectivityResult.none:
      default:
        connection = 'Offline';
    }
    return (connection == "Online")
        ? Platform.isAndroid
            ? WillPopScope(
              onWillPop: () => onBackPressed(context),
              child: SafeArea(
                top: false,
                bottom: true,
                child: _scaffold(context),
              ),
            )
            : _scaffold(context)
        : NoNetwork(context);
  }

  Widget _scaffold(BuildContext context) {
    return Consumer<Accountslistprovider>(
      builder: (context, provider, child) {
        return Scaffold(
          resizeToAvoidBottomInset: true,
          appBar: appbar2(
            context,
            "Add Account",
            provider.resetValues,
            SizedBox(width: 0),
          ),
          backgroundColor: AppColors.white,
          body: SizedBox(
            child: SingleChildScrollView(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Container(
                    padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
                    margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(16),
                    ),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          "Account Details",
                          style: TextStyle(
                            color: AppColors.app_blue,
                            fontSize: 16,
                            fontFamily: "JakartaMedium",
                          ),
                        ),
                        SizedBox(height: 10),
                        Text("Account"),
                        DropdownButtonHideUnderline(
                          child: Row(
                            children: [
                              Expanded(
                                child: DropdownButton2<String>(
                                  isExpanded: true,
                                  hint: const Row(
                                    children: [
                                      Expanded(
                                        child: Text(
                                          'Select Account',
                                          style: TextStyle(fontSize: 14),
                                          overflow: TextOverflow.ellipsis,
                                        ),
                                      ),
                                    ],
                                  ),
                                  items:
                                      provider.accountTypes
                                          .map(
                                            (act) => DropdownMenuItem<String>(
                                              value: act,
                                              child: Text(
                                                act,
                                                style: const TextStyle(
                                                  fontSize: 14,
                                                ),
                                                overflow: TextOverflow.ellipsis,
                                              ),
                                            ),
                                          )
                                          .toList(),
                                  // value: provider.selectedAccountType,
                                  value:
                                      provider.accountTypes.contains(
                                            provider.selectedAccountType,
                                          )
                                          ? provider.selectedAccountType
                                          : null,
                                  onChanged: (value) {
                                    if (value != null) {
                                      provider.selectedAccountType = value;
                                      print(
                                        "statusId:${provider.selectedAccountType}",
                                      );
                                    }
                                  },
                                  buttonStyleData: ddtheme.buttonStyleData,
                                  iconStyleData: ddtheme.iconStyleData,
                                  menuItemStyleData: ddtheme.menuItemStyleData,
                                  dropdownStyleData: ddtheme.dropdownStyleData,
                                ),
                              ),
                            ],
                          ),
                        ),
                        errorWidget(context, provider.accountError),
                        textControllerWidget(
                          context,
                          provider.nameController,
                          "Company Name",
                          "Enter Company Name",
                          (p0) {
                            provider.updateName(p0);
                            provider.checkInputsAPI(
                              context,
                              "name",
                              provider.nameController.text,
                            );
                          },
                          TextInputType.text,
                          false,
                          null,
                          focusNodes[0],
                          focusNodes[1],
                          TextInputAction.next,
                        ),
                        errorWidget(context, provider.nameError),
                        textControllerWidget(
                          context,
                          provider.mobileController,
                          "Mobile Number",
                          "Enter Mobile",
                          (p0) {
                            provider.updateMobile(p0);
                            provider.checkInputsAPI(
                              context,
                              "mob1",
                              provider.mobileController.text,
                            );
                          },
                          TextInputType.phone,
                          false,
                          FilteringTextInputFormatter.digitsOnly,
                          focusNodes[1],
                          focusNodes[2],
                          TextInputAction.next,
                          10,
                        ),
                        errorWidget(context, provider.mobileError),
                        textControllerWidget(
                          context,
                          provider.contactPersonController,
                          "Contact Person Name",
                          "Enter Contact Person Name",
                          provider.updateContactPerson,
                          TextInputType.text,
                          false,
                          null,
                          focusNodes[12],
                          focusNodes[13],
                          TextInputAction.next,
                        ),
                        errorWidget(context, provider.contactPersonError),
                      ],
                    ),
                  ),
                  SizedBox(height: 12),
                  Column(
                    children: [
                      InkResponse(
                        onTap: () => provider.isVisible = !provider.isVisible,
                        child: Center(
                          child: Text(
                            provider.isVisible
                                ? "- Hide More Details"
                                : "+ Add More Details",
                            style: TextStyle(
                              color: AppColors.app_blue,
                              fontSize: 16,
                              fontFamily: "JakartaMedium",
                            ),
                          ),
                        ),
                      ),
                      if (provider.addMoreDetailsError != null) ...[
                        Center(
                          child: ShakeWidget(
                            key: Key("value"),
                            duration: Duration(milliseconds: 700),
                            child: Text(
                              provider.addMoreDetailsError ?? "",
                              style: TextStyle(
                                color: Colors.red,
                                fontSize: 13,
                                fontFamily: "JakartaMedium",
                              ),
                            ),
                          ),
                        ),
                      ],
                      Visibility(
                        visible: provider.isVisible,
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Container(
                              margin: EdgeInsets.symmetric(
                                horizontal: 10,
                                vertical: 10,
                              ),
                              padding: EdgeInsets.symmetric(
                                horizontal: 10,
                                vertical: 10,
                              ),
                              decoration: BoxDecoration(
                                color: Colors.white,
                                borderRadius: BorderRadius.circular(16),
                              ),
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  Text("State"),
                                  DropdownButtonHideUnderline(
                                    child: Row(
                                      children: [
                                        Expanded(
                                          child: DropdownButton2<States>(
                                            focusNode: focusNodes[2],
                                            autofocus:
                                                focusNodes[2].hasFocus
                                                    ? true
                                                    : false,
                                            isExpanded: true,
                                            hint: Text(
                                              'Select State',
                                              style: TextStyle(fontSize: 14),
                                              overflow: TextOverflow.ellipsis,
                                            ),
                                            items:
                                                provider.states
                                                    .map(
                                                      (
                                                        states,
                                                      ) => DropdownMenuItem<
                                                        States
                                                      >(
                                                        value: states,
                                                        child: Text(
                                                          states.name ?? '',
                                                          style:
                                                              const TextStyle(
                                                                fontSize: 14,
                                                              ),
                                                          overflow:
                                                              TextOverflow
                                                                  .ellipsis,
                                                        ),
                                                      ),
                                                    )
                                                    .toList(),
                                            value:
                                                provider.states.contains(
                                                      provider.selectedState,
                                                    )
                                                    ? provider.selectedState
                                                    : null,
                                            // value: provider.selectedState,
                                            onChanged: (States? value) {
                                              if (value != null) {
                                                if (provider
                                                    .states
                                                    .isNotEmpty) {
                                                  provider.selectedState =
                                                      value;
                                                  print(
                                                    "Selected Complaint Type: ${value.name}, ID: ${value.id}",
                                                  );
                                                  provider.selectedStateID =
                                                      value.id!;
                                                  print(
                                                    "hfjkshfg" +
                                                        provider.selectedStateID
                                                            .toString(),
                                                  );
                                                  if (provider
                                                          .selectedDistricts !=
                                                      null) {
                                                    provider.states.clear();
                                                    // provider.selectedDistricts = null;
                                                    provider.selectedDistrictId =
                                                        null;
                                                    provider.selectedDistrictValue =
                                                        null;
                                                  }

                                                  provider.getDistrictAPI(
                                                    context,
                                                    provider.selectedStateID,
                                                  );
                                                }
                                              }
                                            },

                                            dropdownSearchData: DropdownSearchData(
                                              searchInnerWidgetHeight: 50,
                                              searchController:
                                                  provider
                                                      .stateSearchController,
                                              searchInnerWidget: Padding(
                                                padding: const EdgeInsets.all(
                                                  8,
                                                ),
                                                child: TextFormField(
                                                  controller:
                                                      provider
                                                          .stateSearchController,
                                                  decoration: InputDecoration(
                                                    isDense: true,
                                                    contentPadding:
                                                        const EdgeInsets.symmetric(
                                                          horizontal: 10,
                                                          vertical: 8,
                                                        ),
                                                    hintText:
                                                        'Search States...',
                                                    border: OutlineInputBorder(
                                                      borderRadius:
                                                          BorderRadius.circular(
                                                            8,
                                                          ),
                                                    ),
                                                  ),
                                                ),
                                              ),
                                              searchMatchFn: (
                                                item,
                                                searchValue,
                                              ) {
                                                return item.value?.name
                                                        ?.toLowerCase()
                                                        .contains(
                                                          searchValue
                                                              .toLowerCase(),
                                                        ) ??
                                                    false;
                                              },
                                            ),
                                            onMenuStateChange: (isOpen) {
                                              if (!isOpen) {
                                                provider.stateSearchController
                                                    .clear();
                                              }
                                            },
                                            buttonStyleData:
                                                ddtheme.buttonStyleData,
                                            iconStyleData:
                                                ddtheme.iconStyleData,
                                            menuItemStyleData:
                                                ddtheme.menuItemStyleData,
                                            dropdownStyleData:
                                                ddtheme.dropdownStyleData,
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                  errorWidget(context, provider.stateError),
                                  Text("District"),
                                  DropdownButtonHideUnderline(
                                    child: Row(
                                      children: [
                                        Expanded(
                                          child: DropdownButton2<Districts>(
                                            focusNode: focusNodes[3],
                                            isExpanded: true,
                                            hint: Text(
                                              'Select District',
                                              style: TextStyle(fontSize: 14),
                                              overflow: TextOverflow.ellipsis,
                                            ),
                                            items:
                                                provider.districts
                                                    .map(
                                                      (
                                                        dist,
                                                      ) => DropdownMenuItem<
                                                        Districts
                                                      >(
                                                        value: dist,
                                                        child: Text(
                                                          dist.district ?? '',
                                                          style:
                                                              const TextStyle(
                                                                fontSize: 14,
                                                              ),
                                                          overflow:
                                                              TextOverflow
                                                                  .ellipsis,
                                                        ),
                                                      ),
                                                    )
                                                    .toList(),
                                            value:
                                                provider.districts.contains(
                                                      provider
                                                          .selectedDistricts,
                                                    )
                                                    ? provider.selectedDistricts
                                                    : null,
                                            // value: provider.selectedDistricts,
                                            onChanged: (Districts? value) {
                                              if (value != null) {
                                                if (provider
                                                    .districts
                                                    .isNotEmpty) {
                                                  provider.selectedDistricts =
                                                      value;
                                                  print(
                                                    "Selected ID: ${value.id}",
                                                  );
                                                  provider.selectedDistrictId =
                                                      value.id!;
                                                  provider.selectedDistrictValue =
                                                      value.district!;
                                                  print(
                                                    "hfjkshfg" +
                                                        provider
                                                            .selectedDistrictId
                                                            .toString(),
                                                  );
                                                  if (provider
                                                          .selectedSubLocations !=
                                                      null) {
                                                    // provider.selectedSubLocations =
                                                    // null;
                                                    provider.selectedSubLocID =
                                                        null;
                                                    provider.selectedSubLocValue =
                                                        null;
                                                  }
                                                  provider.getSubLocationAPI(
                                                    context,
                                                    provider.selectedDistrictId,
                                                  );
                                                }
                                              }
                                            },
                                            dropdownSearchData: DropdownSearchData(
                                              searchInnerWidgetHeight: 50,
                                              searchController:
                                                  provider
                                                      .districtSearchController,
                                              searchInnerWidget: Padding(
                                                padding: const EdgeInsets.all(
                                                  8,
                                                ),
                                                child: TextFormField(
                                                  controller:
                                                      provider
                                                          .districtSearchController,
                                                  decoration: InputDecoration(
                                                    isDense: true,
                                                    contentPadding:
                                                        const EdgeInsets.symmetric(
                                                          horizontal: 10,
                                                          vertical: 8,
                                                        ),
                                                    hintText:
                                                        'Search Districts...',
                                                    border: OutlineInputBorder(
                                                      borderRadius:
                                                          BorderRadius.circular(
                                                            8,
                                                          ),
                                                    ),
                                                  ),
                                                ),
                                              ),
                                              searchMatchFn: (
                                                item,
                                                searchValue,
                                              ) {
                                                return item.value?.district
                                                        ?.toLowerCase()
                                                        .contains(
                                                          searchValue
                                                              .toLowerCase(),
                                                        ) ??
                                                    false;
                                              },
                                            ),
                                            onMenuStateChange: (isOpen) {
                                              if (!isOpen) {
                                                provider
                                                    .districtSearchController
                                                    .clear();
                                              }
                                            },
                                            buttonStyleData:
                                                ddtheme.buttonStyleData,
                                            iconStyleData:
                                                ddtheme.iconStyleData,
                                            menuItemStyleData:
                                                ddtheme.menuItemStyleData,
                                            dropdownStyleData:
                                                ddtheme.dropdownStyleData,
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                  errorWidget(context, provider.districtError),
                                  Text("Sub Locality"),
                                  DropdownButtonHideUnderline(
                                    child: Row(
                                      children: [
                                        Expanded(
                                          child: DropdownButton2<SubLocations>(
                                            focusNode: focusNodes[4],
                                            isExpanded: true,
                                            hint: Text(
                                              'Select Sub Locality',
                                              style: TextStyle(fontSize: 14),
                                              overflow: TextOverflow.ellipsis,
                                            ),
                                            items:
                                                provider.subLocations
                                                    .map(
                                                      (
                                                        subloc,
                                                      ) => DropdownMenuItem<
                                                        SubLocations
                                                      >(
                                                        value: subloc,
                                                        child: Text(
                                                          subloc.subLocality ??
                                                              '',
                                                          style:
                                                              const TextStyle(
                                                                fontSize: 14,
                                                              ),
                                                          overflow:
                                                              TextOverflow
                                                                  .ellipsis,
                                                        ),
                                                      ),
                                                    )
                                                    .toList(),
                                            // value: provider.selectedSubLocations,
                                            value:
                                                provider.subLocations.contains(
                                                      provider
                                                          .selectedSubLocations,
                                                    )
                                                    ? provider
                                                        .selectedSubLocations
                                                    : null,
                                            onChanged: (SubLocations? value) {
                                              if (value != null) {
                                                if (provider
                                                    .subLocations
                                                    .isNotEmpty) {
                                                  provider.selectedSubLocations =
                                                      value;
                                                  print(
                                                    "Selected ID: ${value.id}",
                                                  );
                                                  provider.selectedSubLocID =
                                                      value.id!;
                                                  provider.selectedSubLocValue =
                                                      value.subLocality!;
                                                  print(
                                                    "hfjkshfg" +
                                                        provider
                                                            .selectedSubLocID
                                                            .toString(),
                                                  );
                                                }
                                              }
                                            },
                                            dropdownSearchData: DropdownSearchData(
                                              searchInnerWidgetHeight: 50,
                                              searchController:
                                                  provider
                                                      .subLocSearchController,
                                              searchInnerWidget: Padding(
                                                padding: const EdgeInsets.all(
                                                  8,
                                                ),
                                                child: TextFormField(
                                                  controller:
                                                      provider
                                                          .subLocSearchController,
                                                  decoration: InputDecoration(
                                                    isDense: true,
                                                    contentPadding:
                                                        const EdgeInsets.symmetric(
                                                          horizontal: 10,
                                                          vertical: 8,
                                                        ),
                                                    hintText:
                                                        'Search Sub Locality...',
                                                    border: OutlineInputBorder(
                                                      borderRadius:
                                                          BorderRadius.circular(
                                                            8,
                                                          ),
                                                    ),
                                                  ),
                                                ),
                                              ),
                                              searchMatchFn: (
                                                item,
                                                searchValue,
                                              ) {
                                                return item.value?.subLocality
                                                        ?.toLowerCase()
                                                        .contains(
                                                          searchValue
                                                              .toLowerCase(),
                                                        ) ??
                                                    false;
                                              },
                                            ),
                                            onMenuStateChange: (isOpen) {
                                              if (!isOpen) {
                                                provider.subLocSearchController
                                                    .clear();
                                              }
                                            },
                                            buttonStyleData:
                                                ddtheme.buttonStyleData,
                                            iconStyleData:
                                                ddtheme.iconStyleData,
                                            menuItemStyleData:
                                                ddtheme.menuItemStyleData,
                                            dropdownStyleData:
                                                ddtheme.dropdownStyleData,
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                  errorWidget(context, provider.localityError),
                                  textControllerWidget(
                                    context,
                                    provider.addressController,
                                    "Address",
                                    "Enter Address",
                                    provider.updateAddress,
                                    TextInputType.text,
                                    false,
                                    null,
                                    focusNodes[5],
                                    null,
                                    TextInputAction.done,
                                  ),
                                  errorWidget(context, provider.addressError),
                                  Text(
                                    "Bank Details",
                                    style: TextStyle(
                                      color: AppColors.app_blue,
                                      fontSize: 16,
                                      fontFamily: "JakartaMedium",
                                    ),
                                  ),
                                  textControllerWidget(
                                    context,
                                    provider.bankNameController,
                                    "Bank Name",
                                    "Enter Bank Name",
                                    provider.updateBankName,
                                    TextInputType.text,
                                    false,
                                    null,
                                    focusNodes[6],
                                    focusNodes[7],
                                    TextInputAction.next,
                                  ),
                                  errorWidget(context, provider.banknameError),
                                  textControllerWidget(
                                    context,
                                    provider.branchNameController,
                                    "Bank Branch",
                                    "Enter Bank Branch",
                                    provider.updateBankBranch,
                                    TextInputType.text,
                                    false,
                                    null,
                                    focusNodes[7],
                                    focusNodes[8],
                                    TextInputAction.next,
                                  ),
                                  errorWidget(
                                    context,
                                    provider.bankBranchError,
                                  ),
                                  textControllerWidget(
                                    context,
                                    provider.bankIfscCotroller,
                                    "Bank IFSC",
                                    "Enter Bank IFSC",
                                    provider.updateIFSC,
                                    TextInputType.text,
                                    false,
                                    null,
                                    focusNodes[8],
                                    focusNodes[9],
                                    TextInputAction.next,
                                  ),
                                  errorWidget(context, provider.bankIFSCError),
                                  textControllerWidget(
                                    context,
                                    provider.bankHolderNameController,
                                    "Bank Holder Name",
                                    "Enter Bank Holder Name",
                                    provider.updateHolder,
                                    TextInputType.text,
                                    false,
                                    null,
                                    focusNodes[9],
                                    focusNodes[10],
                                    TextInputAction.next,
                                  ),
                                  errorWidget(
                                    context,
                                    provider.bankHolderNameError,
                                  ),
                                  textControllerWidget(
                                    context,
                                    provider.bankAcNumberController,
                                    "Bank Account Number",
                                    "Enter Bank Account Number",
                                    provider.updateNumber,
                                    TextInputType.number,
                                    false,
                                    FilteringTextInputFormatter.digitsOnly,
                                    focusNodes[10],
                                    focusNodes[11],
                                    TextInputAction.next,
                                  ),
                                  errorWidget(
                                    context,
                                    provider.bankAcNumberError,
                                  ),
                                  textControllerWidget(
                                    context,
                                    provider.bankUpiController,
                                    "Bank UPI ID",
                                    "Enter Bank UPI ID",
                                    provider.updateUPI,
                                    TextInputType.text,
                                    false,
                                    null,
                                    focusNodes[11],
                                    focusNodes[12],
                                    TextInputAction.next,
                                  ),
                                  errorWidget(context, provider.upiError),
                                ],
                              ),
                            ),
                            Container(
                              margin: EdgeInsets.symmetric(
                                horizontal: 10,
                                vertical: 10,
                              ),
                              padding: EdgeInsets.symmetric(
                                horizontal: 10,
                                vertical: 10,
                              ),
                              decoration: BoxDecoration(
                                color: Colors.white,
                                borderRadius: BorderRadius.circular(16),
                              ),
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  Text(
                                    "Contact Details",
                                    style: TextStyle(
                                      color: AppColors.app_blue,
                                      fontSize: 16,
                                      fontFamily: "JakartaMedium",
                                    ),
                                  ),

                                  textControllerWidget(
                                    context,
                                    provider.contectPersonDesignationController,
                                    "Contact Person Designation",
                                    "Enter Contact Person Designation",
                                    provider.updateDesignation,
                                    TextInputType.text,
                                    false,
                                    null,
                                    focusNodes[13],
                                    focusNodes[14],
                                    TextInputAction.next,
                                  ),
                                  errorWidget(
                                    context,
                                    provider.desigantionError,
                                  ),
                                  textControllerWidget(
                                    context,
                                    provider.contectPersonAltMobController,
                                    "Alternative Mobile Number",
                                    "Enter Alternative Mobile Number",
                                    (p0) {
                                      provider.updateAltMobile(p0);
                                      provider.checkInputsAPI(
                                        context,
                                        "mob2",
                                        provider
                                            .contectPersonAltMobController
                                            .text,
                                      );
                                    },
                                    TextInputType.number,
                                    false,
                                    FilteringTextInputFormatter.digitsOnly,
                                    focusNodes[14],
                                    focusNodes[15],
                                    TextInputAction.next,
                                    10,
                                  ),
                                  errorWidget(context, provider.altMobError),
                                  textControllerWidget(
                                    context,
                                    provider.contectPersonTeleController,
                                    "Telephone Number",
                                    "Enter Telephone Number",
                                    provider.updateTeleMobile,
                                    TextInputType.number,
                                    false,
                                    FilteringTextInputFormatter.digitsOnly,
                                    focusNodes[15],
                                    focusNodes[16],
                                    TextInputAction.next,
                                  ),
                                  errorWidget(context, provider.teleError),
                                  textControllerWidget(
                                    context,
                                    provider.contectPersonMailController,
                                    "Customer Mail ID",
                                    "Enter Customer Mail ID",
                                    provider.updateMail,
                                    TextInputType.text,
                                    false,
                                    null,
                                    focusNodes[16],
                                    focusNodes[17],
                                    TextInputAction.next,
                                  ),
                                  errorWidget(context, provider.mailError),
                                ],
                              ),
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ),

          bottomNavigationBar: InkResponse(
            onTap:
                provider.submitClickced
                    ? null
                    : () {
                      provider.submitClickced = true;
                      provider.submitCommonAccountsAPI(context, widget.from);
                    },
            child: Container(
              height: 45,
              alignment: Alignment.center,
              margin: EdgeInsets.symmetric(horizontal: 10, vertical: 15),
              padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
              decoration: BoxDecoration(
                color: AppColors.app_blue,
                borderRadius: BorderRadius.circular(15),
              ),
              child:
                  provider.submitClickced
                      ? CircularProgressIndicator.adaptive(
                        valueColor: AlwaysStoppedAnimation(AppColors.white),
                      )
                      : Text(
                        "Submit",
                        style: TextStyle(
                          fontSize: 15,
                          fontFamily: "JakartaMedium",
                          color: Colors.white,
                        ),
                      ),
            ),
          ),
        );
      },
    );
  }
}
