From d532f9150d9db275371d428b334f91a9c964d256 Mon Sep 17 00:00:00 2001 From: SurendarSuri30 Date: Tue, 8 Jul 2025 12:25:58 +0530 Subject: [PATCH] Claims History Added --- lib/claimshistory.dart | 440 ++++++++++++++++++++++++----------------- 1 file changed, 257 insertions(+), 183 deletions(-) diff --git a/lib/claimshistory.dart b/lib/claimshistory.dart index 1ae452d..d3bfe01 100644 --- a/lib/claimshistory.dart +++ b/lib/claimshistory.dart @@ -31,6 +31,8 @@ class ClaimHistoryPopup extends StatefulWidget { class _ClaimHistoryPopupState extends State { late ApiService apiService; List> getClaimsHistoryList = []; + List stepKeys =[]; + late Map stepMap; int _index = 4; @override @@ -44,7 +46,7 @@ class _ClaimHistoryPopupState extends State { print(widget.empCode); print(widget.policyType); print(widget.ticket_id); - // getClaimsHistoryDetails(); + getClaimsHistoryDetails(); } @override @@ -58,10 +60,10 @@ class _ClaimHistoryPopupState extends State { }); try { print('10'); - final ticketID = widget.ticket_id; - if (ticketID != '' || ticketID != null) { - return; - } + // final ticketID = widget.ticket_id; + // if (ticketID != '' || ticketID != null) { + // return; + // } final response = await apiService.getClaimsHistoryToApi( widget.ticket_id, widget.postToken); if (response['status'] == 'success') { @@ -69,8 +71,10 @@ class _ClaimHistoryPopupState extends State { // isLoading = false; }); setState(() { - getClaimsHistoryList = - List>.from(response['data']); + getClaimsHistoryList = [Map.from(response['data']['ticket_data'])]; + stepMap = getClaimsHistoryList[0]; + stepKeys = stepMap.keys.toList(); + print('Claims History List $getClaimsHistoryList'); // originalData = getCDPolicies; // filteredData = List.from(originalData); // print('filteredData'); @@ -99,12 +103,12 @@ class _ClaimHistoryPopupState extends State { @override Widget build(BuildContext context) { - if (getClaimsHistoryList.isEmpty) { - return SizedBox( - height: 50, - child: Center(child: Text('No available Claims')), - ); - } + // if (getClaimsHistoryList.isEmpty) { + // return SizedBox( + // height: 50, + // child: Center(child: Text('No available Claims')), + // ); + // } return Container( constraints: BoxConstraints(maxWidth: 800, maxHeight: 800), padding: EdgeInsets.all(20), @@ -154,123 +158,124 @@ class _ClaimHistoryPopupState extends State { ], ), SizedBox(height: 10), + Container( + margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), + decoration: BoxDecoration( + color: Color(0xFFFFFFFF), // White background + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Color(0xFFEBEBEB), // Shadow color + blurRadius: 14, // How soft the shadow is + spreadRadius: 2, // How much it spreads + offset: Offset(0, 1), // X and Y offset + ), + ], + ), + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: _buildKeyValue( + 'Name', '${widget.empName ?? ''} (${widget.empCode ?? ''})'), + ), + SizedBox(width: 16), + Expanded( + child: _buildKeyValue('Policy Name', + '${widget.policyType ?? ''} - ${widget.clientPolicyNo ?? ''}')), + ], + ), + SizedBox(height: 16), + Row( + children: [ + Expanded( + child: _buildKeyValue( + 'Claim Amount', '₹${widget.claimAmount ?? ''}'), + ), + SizedBox(width: 16), + Expanded( + child: _buildKeyValue('Claim Number', widget.claimNo ?? ''), + ), + ], + ), + ], + ), + ), + SizedBox(height: 10), // Container( - // decoration: BoxDecoration( - // color: Color(0xFFFFFFFF), // White background - // borderRadius: BorderRadius.circular(12), - // boxShadow: [ - // BoxShadow( - // color: Color(0xFFEBEBEB), // Shadow color - // blurRadius: 14, // How soft the shadow is - // spreadRadius: 2, // How much it spreads - // offset: Offset(0, 1), // X and Y offset - // ), - // ], - // ), // padding: const EdgeInsets.all(16), - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // Row( - // children: [ - // Expanded( - // child: _buildKeyValue( - // 'Name', '${widget.empName ?? ''} (${widget.empCode ?? ''})'), - // ), - // SizedBox(width: 16), - // Expanded( - // child: _buildKeyValue('Policy Name', - // '${widget.policyType ?? ''} - ${widget.clientPolicyNo ?? ''}')), - // ], + // child: Stepper( + // currentStep: _index, + // onStepCancel: () { + // if (_index > 0) { + // setState(() { + // _index -= 1; + // }); + // } + // }, + // onStepContinue: () { + // if (_index < 4) { + // setState(() { + // _index += 1; + // }); + // } + // }, + // onStepTapped: (int index) { + // setState(() { + // _index = index; + // }); + // }, + // steps: [ + // Step( + // title: Text('Step 1: PAYMENT INITIATED'), + // content: Text('Pay Initiate Date: 05-05-2025'), + // isActive: true, + // state: StepState.complete, // ), - // SizedBox(height: 16), - // Row( - // children: [ - // Expanded( - // child: _buildKeyValue( - // 'Claim Amount', '₹${widget.claimAmount ?? ''}'), - // ), - // SizedBox(width: 16), - // Expanded( - // child: _buildKeyValue('Claim Number', widget.claimNo ?? ''), - // ), - // ], + // Step( + // title: Text('Step 2: INFORMATION REQUIRED'), + // content: Text('Raised Date: 05-05-2025'), + // isActive: true, + // state: StepState.complete, + // ), + // Step( + // title: Text('Step 3: CLAIM NO. UPDATION'), + // content: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text('Claim Number: 4315440'), + // Text('Registration Date: 05-05-2025'), + // ], + // ), + // isActive: true, + // state: StepState.complete, + // ), + // Step( + // title: Text('Step 4: QUERY DOCUMENT REQUIRED'), + // content: Text('Query Received Date: 05-05-2025'), + // isActive: true, + // state: StepState.complete, + // ), + // Step( + // title: Text('Step 5: APPROVED'), + // content: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text('Approved Amount: 4315440'), + // Text('Approved Date: 05-05-2025'), + // Text('Approved Letter: Lorem ipsum...'), + // Text('Description: Lorem ipsum...'), + // ], + // ), + // isActive: true, + // state: StepState.complete, // ), // ], // ), - // ), - // SizedBox(height: 10), - // // Container( - // // padding: const EdgeInsets.all(16), - // // child: Stepper( - // // currentStep: _index, - // // onStepCancel: () { - // // if (_index > 0) { - // // setState(() { - // // _index -= 1; - // // }); - // // } - // // }, - // // onStepContinue: () { - // // if (_index < 4) { - // // setState(() { - // // _index += 1; - // // }); - // // } - // // }, - // // onStepTapped: (int index) { - // // setState(() { - // // _index = index; - // // }); - // // }, - // // steps: [ - // // Step( - // // title: Text('Step 1: PAYMENT INITIATED'), - // // content: Text('Pay Initiate Date: 05-05-2025'), - // // isActive: true, - // // state: StepState.complete, - // // ), - // // Step( - // // title: Text('Step 2: INFORMATION REQUIRED'), - // // content: Text('Raised Date: 05-05-2025'), - // // isActive: true, - // // state: StepState.complete, - // // ), - // // Step( - // // title: Text('Step 3: CLAIM NO. UPDATION'), - // // content: Column( - // // crossAxisAlignment: CrossAxisAlignment.start, - // // children: [ - // // Text('Claim Number: 4315440'), - // // Text('Registration Date: 05-05-2025'), - // // ], - // // ), - // // isActive: true, - // // state: StepState.complete, - // // ), - // // Step( - // // title: Text('Step 4: QUERY DOCUMENT REQUIRED'), - // // content: Text('Query Received Date: 05-05-2025'), - // // isActive: true, - // // state: StepState.complete, - // // ), - // // Step( - // // title: Text('Step 5: APPROVED'), - // // content: Column( - // // crossAxisAlignment: CrossAxisAlignment.start, - // // children: [ - // // Text('Approved Amount: 4315440'), - // // Text('Approved Date: 05-05-2025'), - // // Text('Approved Letter: Lorem ipsum...'), - // // Text('Description: Lorem ipsum...'), - // // ], - // // ), - // // isActive: true, - // // state: StepState.complete, - // // ), - // // ], - // // ), - // // ) + // ) // Column( // crossAxisAlignment: CrossAxisAlignment.start, // children: List.generate(5, (index) { @@ -282,6 +287,25 @@ class _ClaimHistoryPopupState extends State { // ); // }), // ) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: List.generate(stepKeys.length, (index) { + String stepTitleKey = stepKeys[index]; + Map stepData = stepMap[stepTitleKey]; + + print('stepTitleKey'); + print(stepTitleKey); + print('stepData'); + print(stepData); + + return _buildStep( + stepNumber: index + 1, + title: _getStepTitleFromApi(stepTitleKey, stepData), + content: _getStepContentFromApi(stepData), + isLast: index == stepKeys.length - 1, + ); + }), + ) ], ), ), @@ -290,10 +314,12 @@ class _ClaimHistoryPopupState extends State { Widget _buildStep({ required int stepNumber, - required String title, + // required String title, + required Widget title, required Widget content, bool isLast = false, }) { + print(title); return Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -342,13 +368,7 @@ class _ClaimHistoryPopupState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - title, - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 15, - ), - ), + title, SizedBox(height: 8), Container( width: double.infinity, @@ -368,52 +388,60 @@ class _ClaimHistoryPopupState extends State { ); } - String _getStepTitle(int index) { - switch (index) { - case 0: - return 'PAYMENT INITIATED (Nalini – 21–06–2025 / 11:20:02 AM)'; - case 1: - return 'INFORMATION REQUIRED (Nalini – 21–06–2025 / 11:20:02 AM)'; - case 2: - return 'UNDER PROCESS – CLAIM NO. UPDATION (Nalini – 21–06–2025 / 11:20:02 AM)'; - case 3: - return 'UNDER PROCESS – QUERY DOCUMENT REQUIRED (Nalini – 21–06–2025 / 11:20:02 AM)'; - case 4: - return 'APPROVED (Nalini – 21–06–2025 / 11:20:02 AM)'; - default: - return ''; - } + // String _getStepTitleFromApi(String status, Map data) { + // final modifiedBy = data['modified_by'] ?? ''; + // final modifiedAt = data['modified_at'] ?? ''; + // return '$status ($modifiedBy – $modifiedAt)'; + // } + + + Widget _getStepTitleFromApi(String status, Map data) { + final modifiedBy = data['modified_by'] ?? ''; + final modifiedAt = data['modified_at'] ?? ''; + + return RichText( + text: TextSpan( + children: [ + TextSpan( + text: status, + style: GoogleFonts.poppins( + fontSize: 15, + fontWeight: FontWeight.w500, + color: Color(0xFF212120), // Status color + ), + ), + TextSpan( + text: ' ($modifiedBy – $modifiedAt)', + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Color(0xFF565656), // Subtitle color + ), + ), + ], + ), + ); } - Widget _getStepContent(int index) { - switch (index) { - case 0: - return Text('Pay Initiate Date: 05-05-2025'); - case 1: - return Text('Raised Date: 05-05-2025'); - case 2: - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('Claim Number: 4315440'), - Text('Registration Date: 05-05-2025'), - ], - ); - case 3: - return Text('Query Received Date: 05-05-2025'); - case 4: - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('Approved Amount: 4315440'), - Text('Approved Date: 05-05-2025'), - Text('Approved Letter: Lorem ipsum...'), - Text('Description: Lorem ipsum...'), - ], - ); - default: - return SizedBox.shrink(); - } + + Widget _getStepContentFromApi(Map data) { + List rows = []; + + data.forEach((key, value) { + // Skip metadata fields + if (key == 'modified_by' || key == 'modified_at') return; + + String displayName = value['display_name'] ?? key; + String displayValue = value['display_value'] ?? 'N/A'; + + rows.add(_buildHistoryListData(displayName, displayValue)); + rows.add(SizedBox(height: 6)); + }); + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: rows, + ); } Widget _buildKeyValue(String title, String value) { @@ -424,29 +452,75 @@ class _ClaimHistoryPopupState extends State { children: [ Text( title, - style: TextStyle( - color: Colors.grey[600], - fontSize: 14, + style: GoogleFonts.poppins( + color: Color(0xFF747474), + fontWeight: FontWeight.w400, + fontSize: 16, ), ), SizedBox(height: 4), Text( displayValue, - style: TextStyle( - color: Colors.black, + style: GoogleFonts.poppins( + color: Color(0xFF000000), fontWeight: FontWeight.w500, - fontSize: 15, + fontSize: 16, ), ), ], ); } + + Widget _buildHistoryListData(String title, String value) { + final displayValue = + (value == null || value.trim().isEmpty) ? 'N/A' : value; + + return Padding( + padding: const EdgeInsets.symmetric(vertical: 6), // optional spacing + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + // Title - Align to center left + Expanded( + child: Align( + alignment: Alignment.centerLeft, + child: Text( + title, + style: GoogleFonts.poppins( + color: const Color(0xFF747474), + fontWeight: FontWeight.w400, + fontSize: 14, + ), + ), + ), + ), + + // Value - Align to center right + Expanded( + child: Align( + alignment: Alignment.centerRight, + child: Text( + displayValue, + style: GoogleFonts.poppins( + color: const Color(0xFF000000), + fontWeight: FontWeight.w400, + fontSize: 14, + ), + ), + ), + ), + ], + ), + ); + } + } class DottedLinePainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - const dashHeight = 4.0; + const dashHeight = 2.0; const dashSpace = 3.0; double startY = 0; final paint = Paint()