import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:generp/Notifiers/financeProvider/RequesitionLidtDetailsProvider.dart'; import 'package:generp/Notifiers/financeProvider/approveRejectPaymentRequestResponse.dart'; import 'package:generp/Utils/app_colors.dart'; import 'package:generp/Utils/commonWidgets.dart'; import 'package:generp/screens/commom/accountsListDetails.dart'; import 'package:provider/provider.dart'; import 'FileViewer.dart'; class Paymentrequestionlistdetails extends StatefulWidget { final paymentRequestId; final pageName; final mode; const Paymentrequestionlistdetails({ super.key, required this.mode, required this.paymentRequestId, required this.pageName, }); @override State createState() => _PaymentrequestionlistdetailsState(); } class _PaymentrequestionlistdetailsState extends State { TextEditingController approvedAmount = TextEditingController(); TextEditingController remarks = TextEditingController(); TextEditingController paymentReferenceNumber = TextEditingController(); FocusNode requestNode = FocusNode(); FocusNode approveNode = FocusNode(); FocusNode remarkNode = FocusNode(); FocusNode proposedPaymentAmountNode = FocusNode(); FocusNode paymentReferenceNumberNode = FocusNode(); FocusNode accountNameNode = FocusNode(); FocusNode branchNode = FocusNode(); FocusNode requestingPurposeNode = FocusNode(); FocusNode descriptionNode = FocusNode(); FocusNode amountNode = FocusNode(); FocusNode paymentModeNode = FocusNode(); FocusNode bankUpiIDNode = FocusNode(); @override void initState() { // TODO: implement initState super.initState(); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { var provider = Provider.of( context, listen: false, ); provider.paymentRequesitionDetails(context, widget.paymentRequestId); }); } @override Widget build(BuildContext context) { return Consumer( builder: (context, provider, child) { var payment_det = provider.paymentsDetails; var req_det = provider.requestsDetails; WidgetsBinding.instance.addPostFrameCallback((timeStamp) { provider.subHeadings = [ req_det.accountName ?? "-", req_det.proposedAccount ?? "-", req_det.branch ?? "-", req_det.requestingPurpose ?? "-", req_det.requestMode ?? "-", req_det.createdEmployee ?? "-", req_det.attachmentViewFileName ?? "-", req_det.date ?? "-", req_det.description ?? "-", req_det.level1ApprovalRemarks ?? "-", req_det.level1Employee ?? "-", req_det.level2ApprovalRemarks ?? "-", req_det.level2Employee ?? "-", req_det.createdDatetime ?? "-", req_det.updatedDatetime ?? "-", ]; }); return WillPopScope( child: Scaffold( resizeToAvoidBottomInset: true, appBar: appbar(context, widget.pageName), backgroundColor: AppColors.scaffold_bg_color, body: Container( child: SingleChildScrollView( child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), ), margin: EdgeInsets.symmetric(vertical: 10, horizontal: 10), padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), child: Column( children: [ Row( children: [ Expanded( flex: 1, child: Container( height: 50, width: 35, padding: EdgeInsets.all(8.0), decoration: BoxDecoration( color: Color(0xFFFFF3CE), borderRadius: BorderRadius.circular(8), ), child: SvgPicture.asset("assets/svg/fin_ic.svg"), ), ), SizedBox(width: 10), Expanded( flex: 4, child: SizedBox( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( req_det.accountName ?? "-", style: TextStyle( fontFamily: "JakartaMedium", fontSize: 14, color: AppColors.semi_black, ), ), Text( "₹${req_det.amount}", style: TextStyle( fontFamily: "JakartaMedium", fontSize: 14, color: AppColors.app_blue, ), ), ], ), ), ), Expanded( flex: 2, child: Container( padding: EdgeInsets.symmetric( horizontal: 5, vertical: 10, ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: Color(0xFFE3FFE0), ), child: Center( child: Text( req_det.status ?? "-", textAlign: TextAlign.center, style: TextStyle( fontFamily: "JakartaMedium", fontSize: 14, color: Color(0xFF0D9C00), ), ), ), ), ), ], ), Divider(thickness: 0.5, color: Color(0xFFD7D7D7)), ...List.generate(provider.subHeadings.length, (j) { return Container( padding: EdgeInsets.symmetric(vertical: 7), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Text( provider.Headings[j], style: TextStyle( fontFamily: "JakartaMedium", fontSize: 14, color: AppColors.semi_black, ), ), ), Expanded( child: InkResponse( onTap: () { if (provider.Headings[j] == "Attachment") { Navigator.push( context, MaterialPageRoute( builder: (context) => Fileviewer( fileName: req_det .attachmentViewFileName!, fileUrl: req_det .attachmentDirFilePath!, ), ), ); } else if (provider.Headings[j] == "Requested Account") { Navigator.push( context, MaterialPageRoute( builder: (context) => Accountslistdetails( accountID: provider.requestsDetails.accountId, ), ), ); } }, child: Text( [ "Attachment", ].contains(provider.Headings[j]) ? "View" : "${provider.subHeadings[j]}", style: TextStyle( fontSize: 14, color: [ "Attachment", "Requested Account", ].contains(provider.Headings[j]) ? AppColors.app_blue : Color(0xFF818181), decoration: [ "Attachment", "Requested Account", ].contains(provider.Headings[j]) ? TextDecoration.underline : TextDecoration.none, decorationColor: [ "Attachment", "Requested Account", ].contains(provider.Headings[j]) ? AppColors.app_blue : AppColors.white, ), ), ), ), ], ), ); }), ], ), ), ), ), bottomNavigationBar: (["admin", "self"].contains(widget.mode)) ? Container(height: 0) : Container( margin: EdgeInsets.symmetric(horizontal: 10), alignment: Alignment.bottomCenter, height: 60, child: Container( margin: EdgeInsets.only(bottom: 10), alignment: Alignment.center, height: 45, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: InkResponse( onTap: () { _showLevelRejectionSheet(context); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: Color(0xFFFFEFEF), border: Border.all( color: Color(0xFFED3424), width: 0.5, ), ), child: Center( child: Text( "Reject", style: TextStyle( color: Color(0xFFED3424), ), ), ), ), ), ), SizedBox(width: 10), if ([ "apr_lvl1", "apr_lvl2", ].contains(widget.mode)) ...[ Expanded( child: InkResponse( onTap: () { provider .approveRejectPaymentRequestAPIFunction( context, provider.requestsDetails.id, ); _showLevelApprovalSheet(context); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: Color(0xFFE7FFE5), border: Border.all( color: Color(0xFF0D9C00), width: 0.5, ), ), child: Center( child: Text( "Approve", style: TextStyle( color: Color(0xFF0D9C00), ), ), ), ), ), ), ] else if (widget.mode == "process") ...[ Expanded( child: InkResponse( onTap: () { provider .approveRejectPaymentRequestAPIFunction( context, provider.requestsDetails.id, ); _showAddPaymentSheet(context); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: Color(0xFFE7FFE5), border: Border.all( color: Color(0xFF0D9C00), width: 0.5, ), ), child: Center( child: Text( "Add Payment", style: TextStyle( color: Color(0xFF0D9C00), ), ), ), ), ), ), ], ], ), ), ), ), onWillPop: () { return onBackPressed(context); }, ); }, ); } Future _showLevelApprovalSheet(BuildContext context) { return showModalBottomSheet( useSafeArea: true, isDismissible: true, isScrollControlled: true, showDragHandle: true, backgroundColor: Colors.white, enableDrag: true, context: context, builder: (context) { return StatefulBuilder( builder: (context, setState) { return SafeArea( child: Consumer( builder: (context, provider, child) { return Container( margin: EdgeInsets.only( bottom: 15, left: 15, right: 15, top: 10, ), child: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, children: [ Align( alignment: Alignment.topLeft, child: Text( "Level 1 Approval", style: TextStyle( color: AppColors.app_blue, fontSize: 16, ), ), ), textControllerReadonlyWidget( context, provider.requestedAmount, "Enter Requested Amount", (p0) {}, ), textControllerWidget( context, approvedAmount, "Enter Approved Amount", (p0) {}, ), textControllerWidget( context, remarks, "Enter Remarks", (p0) {}, ), TextWidget(context, "Proposed Payment Account"), DropdownButtonHideUnderline( child: Row( children: [ Expanded( child: DropdownButton2( isExpanded: true, hint: Text( 'Select Payment mode', style: TextStyle(fontSize: 14), overflow: TextOverflow.ellipsis, ), items: provider.paymentsAccounts .map( (paymenents) => DropdownMenuItem< PaymentAccounts >( value: paymenents, child: Text( paymenents.name ?? '', style: const TextStyle( fontSize: 14, ), overflow: TextOverflow.ellipsis, ), ), ) .toList(), value: provider.selectedPaymentAccounts, onChanged: (PaymentAccounts? value) { if (value != null) { if (provider .paymentsAccounts .isNotEmpty) { provider.selectedPaymentAccounts = value; print( "Selected Complaint Type: ${value.name}, ID: ${value.id}", ); provider.selectedID = value.id!; provider.selectedValue = value.name!; print( "hfjkshfg" + provider.selectedID.toString(), ); } } }, buttonStyleData: ButtonStyleData( height: 50, width: 160, padding: const EdgeInsets.only( left: 14, right: 14, ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(14), color: AppColors.text_field_color, ), ), iconStyleData: IconStyleData( icon: SvgPicture.asset("assets/svg/arrow_dropdown.svg",height: 25,width: 20,), iconSize: 12, iconEnabledColor: Color(0xFF2D2D2D), iconDisabledColor: Colors.grey, ), dropdownStyleData: DropdownStyleData( maxHeight: 200, decoration: BoxDecoration( borderRadius: BorderRadius.circular(14), color: AppColors.text_field_color, ), scrollbarTheme: ScrollbarThemeData( radius: const Radius.circular(15), thickness: MaterialStateProperty.all( 6, ), thumbVisibility: MaterialStateProperty.all( true, ), ), ), menuItemStyleData: const MenuItemStyleData( height: 40, padding: EdgeInsets.only( left: 14, right: 14, ), ), ), ), ], ), ), InkWell( onTap: () { provider .paymentrequisitionApproveSubmitAPIFunction( context, widget.mode, provider.paymentsReqDetails.id, approvedAmount.text, remarks.text, provider.selectedID, ); }, child: Container( alignment: Alignment.center, height: 45, margin: EdgeInsets.only( left: 5.0, right: 5.0, top: 5.0, bottom: 5.0, ), decoration: BoxDecoration( color: AppColors.app_blue, //1487C9 borderRadius: BorderRadius.circular(14.0), ), child: Center( child: Text( "Submit", textAlign: TextAlign.center, style: TextStyle(color: Colors.white), ), ), ), ), ], ), ), ); }, ), ); }, ); }, ); } Future _showLevelRejectionSheet(BuildContext context) { return showModalBottomSheet( useSafeArea: true, isDismissible: true, isScrollControlled: true, showDragHandle: true, backgroundColor: Colors.white, enableDrag: true, context: context, builder: (context) { return StatefulBuilder( builder: (context, setState) { return SafeArea( child: Consumer( builder: (context, provider, child) { return Container( margin: EdgeInsets.only( bottom: 15, left: 15, right: 15, top: 10, ), child: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, children: [ Align( alignment: Alignment.topLeft, child: Text( "Level 1 Rejection", style: TextStyle( color: AppColors.app_blue, fontSize: 16, ), ), ), textControllerReadonlyWidget( context, provider.requestedAmount, "Enter Requested Amount", (p0) {}, ), textControllerWidget( context, remarks, "Enter Remarks", (p0) {}, ), InkWell( onTap: () { provider .paymentrequisitionRejectSubmitAPIFunction( context, widget.mode, provider.paymentsReqDetails.id, remarks.text, ); }, child: Container( alignment: Alignment.center, height: 45, margin: EdgeInsets.only( left: 5.0, right: 5.0, top: 5.0, bottom: 5.0, ), decoration: BoxDecoration( color: AppColors.app_blue, //1487C9 borderRadius: BorderRadius.circular(14.0), ), child: Center( child: Text( "Submit", textAlign: TextAlign.center, style: TextStyle(color: Colors.white), ), ), ), ), ], ), ), ); }, ), ); }, ); }, ); } Future _showAddPaymentSheet(BuildContext context) { return showModalBottomSheet( useSafeArea: true, isDismissible: true, isScrollControlled: true, showDragHandle: true, backgroundColor: Colors.white, enableDrag: true, context: context, builder: (context) { return StatefulBuilder( builder: (context, setState) { return SafeArea( child: Consumer( builder: (context, provider, child) { return Container( margin: EdgeInsets.only( bottom: 15, left: 15, right: 15, top: 10, ), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Align( alignment: Alignment.topLeft, child: Text( "Add Approval", style: TextStyle( color: AppColors.app_blue, fontSize: 16, ), ), ), textControllerReadonlyWidget( context, provider.proposedPaymentAccount, "Enter Proposed Payment Account", (p0) {}, ), TextWidget(context, "Payment Account"), DropdownButtonHideUnderline( child: Row( children: [ Expanded( child: DropdownButton2( isExpanded: true, hint: Text( 'Select Account', style: TextStyle(fontSize: 14), overflow: TextOverflow.ellipsis, ), items: provider.paymentsAccounts .map( (paymenents) => DropdownMenuItem< PaymentAccounts >( value: paymenents, child: Text( paymenents.name ?? '', style: const TextStyle( fontSize: 14, ), overflow: TextOverflow.ellipsis, ), ), ) .toList(), value: provider.selectedPaymentAccounts, onChanged: (PaymentAccounts? value) { if (value != null) { if (provider .paymentsAccounts .isNotEmpty) { provider.selectedPaymentAccounts = value; print( "Selected Complaint Type: ${value.name}, ID: ${value.id}", ); provider.selectedID = value.id!; provider.selectedValue = value.name!; print( "hfjkshfg" + provider.selectedID.toString(), ); } } }, buttonStyleData: ButtonStyleData( height: 50, width: 160, padding: const EdgeInsets.only( left: 14, right: 14, ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(14), color: AppColors.text_field_color, ), ), iconStyleData: IconStyleData( icon: SvgPicture.asset("assets/svg/arrow_dropdown.svg",height: 25,width: 20,), iconSize: 12, iconEnabledColor: Color(0xFF2D2D2D), iconDisabledColor: Colors.grey, ), dropdownStyleData: DropdownStyleData( maxHeight: 200, decoration: BoxDecoration( borderRadius: BorderRadius.circular(14), color: AppColors.text_field_color, ), scrollbarTheme: ScrollbarThemeData( radius: const Radius.circular(15), thickness: MaterialStateProperty.all( 6, ), thumbVisibility: MaterialStateProperty.all( true, ), ), ), menuItemStyleData: const MenuItemStyleData( height: 40, padding: EdgeInsets.only( left: 14, right: 14, ), ), ), ), ], ), ), textControllerWidget( context, paymentReferenceNumber, "Enter Payment Reference Number", (p0) {}, ), textControllerWidget( context, remarks, "Enter Remarks", (p0) {}, ), InkResponse( onTap: () { _showAttachmentSheet(context); }, child: Container( margin: EdgeInsets.symmetric(vertical: 10), height: 45, width: MediaQuery.of(context).size.width, decoration: BoxDecoration( color: Color(0xFFE6F6FF), borderRadius: BorderRadius.circular(12), border: Border.all( color: AppColors.app_blue, width: 0.5, ), ), child: Center( child: Text( "Add Attachment", style: TextStyle( fontFamily: "JakartaMedium", color: AppColors.app_blue, ), ), ), ), ), if(provider.imagePicked==1 && provider.imagePath!=null)...[ Padding( padding: const EdgeInsets.symmetric(vertical: 4.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text("${provider.imagePath}",style: TextStyle( color: AppColors.semi_black, fontSize: 11, fontWeight: FontWeight.w600 ),), InkResponse( onTap: () { provider.imagePicked = 0; provider.imagePath = null; provider.imageFilePath = null; }, child: SvgPicture.asset("assets/svg/ic_close.svg",width: 15,height: 15,)) ], ), ) ], textControllerReadonlyWidget( context, provider.accountName, "Enter Account Name", (p0) {}, ), textControllerReadonlyWidget( context, provider.branch, "Enter Branch Name", (p0) {}, ), textControllerReadonlyWidget( context, provider.requestingPurpose, "Enter Requesting Purpose", (p0) {}, ), textControllerReadonlyWidget( context, provider.description, "Enter Description", (p0) {}, ), textControllerReadonlyWidget( context, provider.amount, "Enter Amount", (p0) {}, ), textControllerReadonlyWidget( context, provider.paymentMode, "Enter Payment Mode", (p0) {}, ), textControllerReadonlyWidget( context, provider.bankHolderName, "Bank Account Holder Name", (p0) {}, ), textControllerReadonlyWidget( context, provider.bankAccountNumber, "Bank Account Number", (p0) {}, ), textControllerReadonlyWidget( context, provider.bankName, "Bank Name", (p0) {}, ), textControllerReadonlyWidget( context, provider.bankBranchName, "Bank Branch Name", (p0) {}, ), textControllerReadonlyWidget( context, provider.bankIfscCode, "Bank IFSC Code", (p0) {}, ), textControllerReadonlyWidget( context, provider.bankUpiID, "Bank UPI ID", (p0) {}, ), InkWell( onTap: () { provider .paymentrequisitionProcessSubmitAPIFunction( context, widget.mode, provider.paymentsReqDetails.id, paymentReferenceNumber.text, remarks.text, provider.imagePath, ); }, child: Container( alignment: Alignment.center, height: 45, margin: EdgeInsets.only( left: 5.0, right: 5.0, top: 5.0, bottom: 5.0, ), decoration: BoxDecoration( color: AppColors.app_blue, //1487C9 borderRadius: BorderRadius.circular(14.0), ), child: Center( child: Text( "Submit", textAlign: TextAlign.center, style: TextStyle(color: Colors.white), ), ), ), ), ], ), ), ); }, ), ); }, ); }, ); } Future _showAttachmentSheet(BuildContext context) { return showModalBottomSheet( useSafeArea: true, isDismissible: true, isScrollControlled: true, showDragHandle: true, backgroundColor: Colors.white, enableDrag: true, context: context, builder: (context) { return StatefulBuilder( builder: (context, setState) { return SafeArea( child: Consumer( builder: (context, provider, child) { return Padding( padding: EdgeInsets.only( bottom: MediaQuery.of( context, ).viewInsets.bottom, // This handles keyboard ), child: Container( margin: EdgeInsets.only( bottom: 15, left: 15, right: 15, top: 10, ), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Align( alignment: Alignment.center, child: Text( "Select Source", style: TextStyle( color: AppColors.app_blue, fontSize: 16, ), ), ), SizedBox(height: 15), InkWell( onTap: () { Navigator.of(context).pop(false); provider.imgFromGallery(context); }, child: Container( height: 35, child: Text("Select photo from gallery"), ), ), SizedBox(height: 10), InkWell( onTap: () { Navigator.of(context).pop(false); provider.imgFromCamera(context); }, child: Container( height: 35, child: Text("Capture photo from camera"), ), ), ], ), ), ), ); }, ), ); }, ); }, ); } Widget TextWidget(context, text) { return Padding( padding: const EdgeInsets.only(bottom: 5.0, top: 8.0), child: Text(text), ); } Widget ErrorWidget(context, text) { if (text != null) return Text(text!, style: TextStyle(color: Colors.red, fontSize: 12)); else return SizedBox(height: 10); } Widget textControllerWidget( context, controller, hintText, Function(String)? onChanged, ) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(bottom: 5.0, top: 8.0), child: Text(hintText), ), Container( height: hintText == "Enter Description" || hintText == "Enter Remarks" ? 150 : 50, alignment: Alignment.center, decoration: BoxDecoration( color: AppColors.text_field_color, borderRadius: BorderRadius.circular(14), ), child: Padding( padding: const EdgeInsets.fromLTRB(10.0, 0.0, 10, 0), child: TextFormField( controller: controller, keyboardType: TextInputType.text, maxLines: hintText == "Enter Description" || hintText == "Enter Remarks" ? 60 : 1, onChanged: onChanged, decoration: InputDecoration( hintText: hintText, hintStyle: TextStyle( fontWeight: FontWeight.w400, color: Color(0xFFB4BEC0), fontSize: 14, ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, ), ), ), ), ], ); } Widget textControllerReadonlyWidget( context, controller, hintText, Function(String)? onChanged, ) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(bottom: 5.0, top: 8.0), child: Text(hintText), ), Container( height: hintText == "Enter Description" ? 150 : 50, alignment: Alignment.center, decoration: BoxDecoration( color: Color(0xFFE9E9E9), borderRadius: BorderRadius.circular(14), ), child: Padding( padding: const EdgeInsets.fromLTRB(10.0, 0.0, 10, 0), child: TextFormField( controller: controller, readOnly: true, keyboardType: TextInputType.text, maxLines: hintText == "Enter Description" ? 60 : 1, onChanged: onChanged, style: TextStyle(color: Color(0xFF818181), fontSize: 14), decoration: InputDecoration( hintText: hintText, hintStyle: TextStyle( fontWeight: FontWeight.w400, color: Color(0xFFB4BEC0), fontSize: 14, ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, ), ), ), ), ], ); } }