post_enrollment_app/lib/pages/enrollment/empReview.dart
venbaittech b5d77d2426 CHANGE_
2024-07-28 11:50:54 +05:30

2742 lines
140 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:nhance_app_pwa/customAppBar/enrollmentAppBar.dart';
import 'package:nhance_app_pwa/pages/enrollment/service/api_service.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:http/http.dart' as http;
import 'package:flutter/widgets.dart';
import 'package:flutter/services.dart';
import 'dart:convert';
import 'package:url_launcher/url_launcher.dart';
import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart';
import '../postEnrollment/chatbot.dart';
class empReviewDetails extends StatefulWidget {
const empReviewDetails({Key? key}) : super(key: key);
@override
State<empReviewDetails> createState() => _empReviewDetailsState();
}
class _empReviewDetailsState extends State<empReviewDetails> {
late ApiService apiService;
bool isLoading = true;
bool isChecked = false; // Declare the _isSwitched variable here
dynamic _token;
dynamic empCodeString;
dynamic empPrimaryId;
dynamic gpaEmpName;
dynamic client_id;
dynamic gpaPolicies;
dynamic gpaPolicyName;
dynamic gpaGridMaster;
dynamic gmcPolicies;
dynamic gpasumInsured;
dynamic gpaClintPolicyId = 0;
dynamic gpaMappedFamilyFloaters = [];
dynamic gpaSelfName;
dynamic gpaSelfDob;
dynamic gpaSelfRelationship;
dynamic gpaSelfDetails;
dynamic gpaECardDownload;
dynamic gmcECardDownload;
dynamic gmcClintPolicyId = 0;
dynamic gmcMappedFamilyFloaters = [];
dynamic gmcSelfName;
dynamic gmcSelfDob;
dynamic gmcSelfRelationship;
dynamic gmcSelfDetails;
dynamic gmcPolicyName;
dynamic gmcNotes;
dynamic gmcSumInsured;
dynamic gmcTypeName;
dynamic clientName;
dynamic clientLogo;
dynamic addOnsDependentMappedFamilyFloatersArray;
dynamic addOnsDependentClientPolicyId;
dynamic gmcAddOnsselectedSI;
dynamic gmcAddOnsselectedDependent;
dynamic gmcFloaterTextDescription;
dynamic gmcFloaterTextHeading;
dynamic dependentValue;
dynamic siValue;
dynamic addOnsDependentSumInsured;
dynamic addOnsDependentPolicyName;
dynamic addOnsFloaterTextHeading;
dynamic addOnsDependentECardDownload;
dynamic addOnsFamilyFloater;
late DateTime? selectedDate;
int totalPayableAmt = 0;
List<Map<String, String>> relationshipOptions = [];
List<Map<String, String>> selectedRelationships = [];
List<Map<String, dynamic>> formDataList = [];
dynamic topUpMappedFamilyFloatersSi;
dynamic topUpMappedFamilyFloatersSiArray;
dynamic topUpClientPolicyId;
dynamic topUpSlabRates;
dynamic topUpFamilyFloater;
dynamic topUpPolicyName;
dynamic topUpTypeName;
int topUpSiPremiumValue = 0;
int topUpSiPremiumGst = 0;
int topUpSiTotalAmt = 0;
int topUpParentSiPremiumValue = 0;
int topUpParentSiPremiumGst = 0;
int topUpParentSiTotalAmt = 0;
int addOnDependentPremiumValue = 0;
int addOnsDependentPremiumGst = 0;
int addOnsDependentTotalAmt = 0;
dynamic topUpSiValue;
dynamic topUpSiSelectedSI;
dynamic topUpSumInsured;
dynamic topUpFloaterTextHeading;
dynamic topUpECardDownload;
int showHideTopUpCard = 0;
int showHideAddOnsCard = 0;
int showHideTopUpParentCard = 0;
dynamic iAgreeForAddOn = [];
dynamic topUpSiParentPolicies = [];
dynamic topUpParentClientPolicyId;
dynamic topUpParentSlabRates;
dynamic topUpParentPolicyName;
dynamic topUpParentFamilyFloater;
dynamic topUpParentMappedFamilyFloatersSi;
dynamic topUpParentECardDownload;
dynamic topUpParentSiValue;
dynamic topUpParentSiSelectedSI;
dynamic topUpParentTypeName;
dynamic topUpParentFloterTextHeading;
int topUpParentOpenForEnrollment = 0;
int activeSiData = 0;
int activeSiParentData = 0;
int activeDependentData = 0;
int activePremiumSummary = 0;
dynamic gmcDataIsEmpty = 1;
dynamic gpaDataIsEmpty = 1;
dynamic empClientBranchId;
dynamic selfEmpStatus;
@override
void initState() {
super.initState();
apiService = ApiService(context); // Initialize ApiService here
_loadToken();
Future.delayed(Duration(seconds: 3), () {
setState(() {
isLoading = false;
});
});
}
@override
void dispose() {
super.dispose();
}
String formatDate(String inputDate) {
// Parse the input date string
DateTime dateTime = DateFormat('dd-MM-yyyy').parse(inputDate);
// Format the date to the desired format
String formattedDate = DateFormat('dd MMM yyyy').format(dateTime);
return formattedDate;
}
Future<void> _loadToken() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
final String? token = prefs.getString('token');
if (token != null && token.isNotEmpty) {
setState(() {
_token = token;
});
selfEmpStatus = prefs.getString('selfEmpStatus');
empClientBranchId = prefs.getString('empClientBranchId');
empCodeString = prefs.getString('empCode');
print(empCodeString); // Check if emp_code is correct
empPrimaryId = prefs.getString('empPrimaryId');
gpaEmpName = prefs.getString('gpaEmpName');
client_id = prefs.getString('client_id');
print(client_id);
// print(empPrimaryId);
// Call the API when the page enters
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
clientLogo = prefs.getString('clientLogo');
clientName = prefs.getString('clientName');
} else {
getClientLogoAndDetails();
}
getGmcSiTopUp();
getGmcSiParentTopUp();
getGmcDependentAddOns();
getGpaEmpPolicyDetails(empPrimaryId);
getGmcEmpPolicyDetails(empPrimaryId);
primarySummary();
} else {
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
// For now, let's navigate to the login screen
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushReplacementNamed(context, 'phone');
}
}
void primarySummary() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
if (prefs.containsKey('siData')) {
activeSiData = 1;
String? siDataJson = prefs.getString('siData');
print('siDataJson');
print(siDataJson);
List<dynamic> siDataList = jsonDecode(siDataJson!);
if (siDataList.isNotEmpty) {
// Access the first map in the list
Map<String, dynamic> firstSiData = siDataList.first;
// Get the value of topUpSiPremiumValue
topUpSiPremiumValue = firstSiData['topUpSiPremiumValue'];
topUpSiPremiumGst = firstSiData['topUpSiPremiumGst'];
topUpSiTotalAmt = firstSiData['topUpSiTotalAmt'];
}
}
if (prefs.containsKey('siParentData')) {
activeSiParentData = 1;
String? siParentDataJson = prefs.getString('siParentData');
print('siParentDataJson');
print(siParentDataJson);
List<dynamic> siParentDataList = jsonDecode(siParentDataJson!);
if (siParentDataList.isNotEmpty) {
// Access the first map in the list
Map<String, dynamic> firstSiParentData = siParentDataList.first;
// Get the value of topUpSiPremiumValue
topUpParentSiPremiumValue =
firstSiParentData['topUpParentSiPremiumValue'];
topUpParentSiPremiumGst = firstSiParentData['topUpParentSiPremiumGst'];
topUpParentSiTotalAmt = firstSiParentData['topUpParentSiTotalAmt'];
}
}
if (prefs.containsKey('dependentData')) {
activeDependentData = 1;
String? dependentDataJson = prefs.getString('dependentData');
print('dependentDataJson');
print(dependentDataJson);
List<dynamic> dependentDataList = jsonDecode(dependentDataJson!);
if (dependentDataList.isNotEmpty) {
// Access the first map in the list
Map<String, dynamic> firstDependentListData = dependentDataList.first;
// Get the value of topUpSiPremiumValue
addOnDependentPremiumValue =
firstDependentListData['addOnDependentPremiumValue'];
addOnsDependentPremiumGst =
firstDependentListData['addOnsDependentPremiumGst'];
addOnsDependentTotalAmt =
firstDependentListData['addOnsDependentTotalAmt'];
}
}
if (prefs.containsKey('siData') &&
prefs.containsKey('siParentData') &&
prefs.containsKey('dependentData')) {
activePremiumSummary = 0;
} else {
activePremiumSummary = 1;
}
// Calculate the sum, skipping any missing values
if (topUpSiTotalAmt != null) totalPayableAmt += topUpSiTotalAmt;
if (topUpParentSiTotalAmt != null) totalPayableAmt += topUpParentSiTotalAmt;
if (addOnsDependentTotalAmt != null)
totalPayableAmt += addOnsDependentTotalAmt;
// Print or use the totalAmtSum value
print('Sum of Total Amounts: $totalPayableAmt');
}
Future<void> getClientLogoAndDetails() async {
try {
if (client_id == null ||
empCodeString == null ||
empClientBranchId == null) {
return;
}
final response = await apiService.getClientLogoAndDetailsToApi(
client_id!, empCodeString!, empClientBranchId!);
if (response['status'] == 'success') {
if (response.containsKey('data')) {
dynamic clientDetails = response['data'];
print(clientDetails);
clientName = clientDetails['client']['client_name'];
print(clientName);
clientLogo = clientDetails['client']['client_logo'];
print(clientLogo);
} else {
// Handle other status messages if needed
print('API request failed with status: ${response['status']}');
}
} else {
// Handle other status codes
print('Request failed with status: ${response['code']}');
}
} catch (e) {
// Handle exceptions
print('Exception occurred: $e');
}
}
Future<void> getGpaEmpPolicyDetails(empPrimaryId) async {
try {
if (client_id == null ||
empCodeString == null ||
empClientBranchId == null) {
return;
}
final response = await apiService.getGpaEmpPolicyDetailsToApi(
empPrimaryId, empCodeString!, client_id!, 'GPA', empClientBranchId!);
if (response['status'] == 'success') {
if (response.containsKey('data')) {
gpaPolicies = response['data'];
print(gpaPolicies);
// Assuming data is a List
print(gpaPolicies);
if (gpaPolicies.isNotEmpty) {
setState(() {
// You can use gpaPolicies as needed
print('GPA Policies found: $gpaPolicies');
gpaPolicyName = gpaPolicies['Policy_Name'];
print(gpaPolicyName);
gpasumInsured = gpaPolicies['mapped_family_floaters']['data']
['basic_cover_si'];
print(gpasumInsured);
gpaMappedFamilyFloaters =
gpaPolicies['mapped_family_floaters']['data'];
print(gpaMappedFamilyFloaters);
gpaSelfName = gpaMappedFamilyFloaters['name'];
// gpaSelfMobileNo = gpaMappedFamilyFloaters['mobile'];
gpaSelfDob = gpaMappedFamilyFloaters['dob'];
gpaSelfRelationship = gpaMappedFamilyFloaters['relationship'];
gpaSelfDetails = gpaSelfName +
' ~ ' +
gpaSelfRelationship +
' ~ ' +
' DOB : ' +
formatDate(gpaSelfDob);
// gpaGridMaster = await gpaPolicies[0]['GridMaster'];
// gpaSlabRates = await gpaPolicies[0]['SlabRates'];
gpaClintPolicyId = gpaPolicies['ClientPolicyId'];
gpaECardDownload = gpaPolicies['eCardDownload'];
// gpaSelectedSI =
// gpaMappedFamilyFloaters['basic_cover_si'].toString();
});
} else {
setState(() {
gpaDataIsEmpty = 0;
});
// ToastHelper.showWarningToast(context, 'No data found');
print('No data found in the response');
}
} else {
// Handle other status messages if needed
ToastHelper.showWarningToast(context, 'Something went wrong');
print('API request failed with status: ${response['status']}');
}
} else {
setState(() {
gpaDataIsEmpty = 0;
});
// Handle other status codes
ToastHelper.showErrorToast(context, 'Something went wrong');
print('Request failed with status: ${response['code']}');
}
} catch (e) {
// Handle exceptions
print('Exception occurred: $e');
}
}
Future<void> getGmcEmpPolicyDetails(empPrimaryId) async {
try {
if (client_id == null ||
empCodeString == null ||
empClientBranchId == null) {
return;
}
final response = await apiService.getGmcEmpPolicyDetailsToApi(
empPrimaryId, empCodeString!, client_id!, 'GMC', empClientBranchId!);
if (response['status'] == 'success') {
setState(() {
gmcPolicies = response['data'];
print('gmcPolicies');
});
// Assuming data is a List
print(gmcPolicies);
} else {
setState(() {
gmcDataIsEmpty = 0;
});
// Handle other status codes
// ToastHelper.showErrorToast(
// context, 'Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response['code']}');
}
} catch (e) {
// Handle exceptions
print('Exception occurred: $e');
}
}
Future<void> getGmcSiTopUp() async {
try {
if (client_id == null ||
empCodeString == null ||
empClientBranchId == null) {
return;
}
final response = await apiService.getGmcSiTopUpToApi(
client_id!, empCodeString!, 'GMC-SI-TOPUP', empClientBranchId!);
if (response['status'] == 'success') {
if (response.containsKey('data')) {
dynamic topUpSiPolicies = response['data'];
print(topUpSiPolicies);
if (topUpSiPolicies.isNotEmpty) {
// setState(() {
topUpClientPolicyId =
topUpSiPolicies['gmc_si_topup']['client_policy_id'];
topUpSumInsured = topUpSiPolicies['gmc_si_topup']
['family_floaters_of_only_si_value'];
print(topUpSumInsured);
if (topUpSumInsured == 0) {
showHideTopUpCard = 0;
} else {
showHideTopUpCard = 1;
}
topUpPolicyName =
await topUpSiPolicies['gmc_si_topup']['policy_name'];
topUpMappedFamilyFloatersSiArray = topUpSiPolicies['gmc_si_topup']
['family_floaters_of_only_si_array'];
print('topUpMappedFamilyFloatersSiArray');
print(topUpMappedFamilyFloatersSiArray);
topUpTypeName = topUpSiPolicies['gmc_si_topup']['type'];
topUpFloaterTextHeading =
topUpSiPolicies['gmc_si_topup']['floter_text_heading'];
topUpECardDownload =
topUpSiPolicies['gmc_si_topup']['eCardDownload'];
// });
} else {
// ToastHelper.showErrorToast(
// context, 'No data found in the response');
print('No data found in the response');
}
} else {
// Handle other status messages if needed
// ToastHelper.showErrorToast(
// context, 'API request failed with status: ${data['status']}');
print('API request failed with status: ${response['status']}');
}
} else {
// Handle other status codes
// ToastHelper.showErrorToast(
// context, 'Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response['code']}');
}
} catch (e) {
// Handle exceptions
print('Exception occurred: $e');
}
}
Future<void> getGmcSiParentTopUp() async {
try {
if (client_id == null ||
empCodeString == null ||
empClientBranchId == null) {
return;
}
final response = await apiService.getGmcSiParentTopUpToApi(client_id!,
empCodeString!, 'GMC-SI-PARENT-TOPUP', empClientBranchId!);
if (response['status'] == 'success') {
if (response.containsKey('data')) {
setState(() {
topUpSiParentPolicies = response['data'];
print('topUpSiParentPolicies');
print(topUpSiParentPolicies);
});
if (topUpSiParentPolicies.isNotEmpty) {
// setState(() {
topUpParentClientPolicyId =
await topUpSiParentPolicies['gmc_si_parent_topup']
['client_policy_id'];
topUpParentSlabRates =
await topUpSiParentPolicies['gmc_si_parent_topup']['SlabRates'];
print('topUpParentSlabRates');
print(topUpParentSlabRates);
topUpParentPolicyName =
await topUpSiParentPolicies['gmc_si_parent_topup']
['policy_name'];
topUpParentFamilyFloater =
await topUpSiParentPolicies['gmc_si_parent_topup']
['policy_terms']['family_floater'];
print('topUpParentFamilyFloater');
print(topUpParentFamilyFloater);
topUpParentMappedFamilyFloatersSi =
await topUpSiParentPolicies['gmc_si_parent_topup']
['family_floaters_of_only_si_array'];
print('topUpParentMappedFamilyFloatersSi');
print(topUpParentMappedFamilyFloatersSi);
print('topUpECardDownload');
topUpParentECardDownload =
topUpSiParentPolicies['gmc_si_parent_topup']['eCardDownload'];
print(topUpParentECardDownload);
String intOpenForEnrollment =
topUpSiParentPolicies['gmc_si_parent_topup']
['OpenForEnrollment'];
topUpParentOpenForEnrollment = int.parse(intOpenForEnrollment);
print(topUpParentOpenForEnrollment);
topUpParentTypeName =
topUpSiParentPolicies['gmc_si_parent_topup']['type'];
topUpParentFloterTextHeading =
topUpSiParentPolicies['gmc_si_parent_topup']
['floter_text_heading'];
topUpParentSiValue =
await topUpSiParentPolicies['gmc_si_parent_topup']
['family_floaters_of_only_si_value'];
if (topUpParentSiValue == 0) {
showHideTopUpParentCard = 0;
} else {
showHideTopUpParentCard = 1;
}
// });
} else {
// ToastHelper.showErrorToast(
// context, 'No data found in the response');
print('No data found in the response');
}
} else {
// Handle other status messages if needed
// ToastHelper.showErrorToast(
// context, 'API request failed with status: ${data['status']}');
print('API request failed with status: ${response['status']}');
}
} else {
// Handle other status codes
// ToastHelper.showErrorToast(
// context, 'Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response['code']}');
}
} catch (e) {
// Handle exceptions
print('Exception occurred: $e');
}
}
Future<void> getGmcDependentAddOns() async {
try {
if (client_id == null ||
empCodeString == null ||
empClientBranchId == null) {
return;
}
final response = await apiService.getGmcDependentAddOnsToApi(client_id!,
empCodeString!, 'GMC-DEPENDENT-ADDON', empClientBranchId!);
if (response['status'] == 'success') {
if (response.containsKey('data')) {
dynamic addOnsDependentPolicies = response['data'];
print('addOnsDependentPolicies');
print(addOnsDependentPolicies);
if (addOnsDependentPolicies.isNotEmpty) {
// setState(() {
addOnsDependentClientPolicyId =
addOnsDependentPolicies['gmc_dependent_addon']
['client_policy_id'];
print(addOnsDependentClientPolicyId);
addOnsDependentSumInsured =
addOnsDependentPolicies['gmc_dependent_addon']
['family_floaters_of_dependent_and_si_value'];
print(addOnsDependentSumInsured);
if (addOnsDependentSumInsured == 0) {
showHideAddOnsCard = 0;
} else {
showHideAddOnsCard = 1;
}
addOnsDependentPolicyName =
addOnsDependentPolicies['gmc_dependent_addon']['policy_name'];
print(addOnsDependentPolicyName);
addOnsDependentMappedFamilyFloatersArray =
await addOnsDependentPolicies['gmc_dependent_addon']
['family_floaters_of_dependent_and_si_array'];
print('addOnsDependentMappedFamilyFloatersArray');
print(addOnsDependentMappedFamilyFloatersArray);
addOnsFloaterTextHeading =
addOnsDependentPolicies['gmc_dependent_addon']
['floter_text_heading'];
addOnsDependentECardDownload =
addOnsDependentPolicies['gmc_dependent_addon']['eCardDownload'];
} else {
// ToastHelper.showErrorToast(
// context, 'No data found in the response');
print('No data found in the response');
}
} else {
// Handle other status messages if needed
// ToastHelper.showErrorToast(
// context, 'API request failed with status: ${data['status']}');
print('API request failed with status: ${response['status']}');
}
} else {
// Handle other status codes
// ToastHelper.showErrorToast(
// context, 'Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response['code']}');
}
} catch (e) {
// Handle exceptions
print('Exception occurred: $e');
}
}
Future<void> sendAddOnAPI() async {
setState(() {
isLoading = true;
});
if (addOnsDependentMappedFamilyFloatersArray != null) {
dynamic getDependentTrueObjects = addOnsDependentMappedFamilyFloatersArray
.where((element) => element['is_value_exist'] == true)
.toList();
print(getDependentTrueObjects);
if (getDependentTrueObjects.isNotEmpty) {
iAgreeForAddOn.add(int.parse(addOnsDependentClientPolicyId));
}
}
if (topUpMappedFamilyFloatersSiArray != null) {
dynamic getSiTrueObjects = topUpMappedFamilyFloatersSiArray
.where((element) => element['is_value_exist'] == true)
.toList();
print(getSiTrueObjects);
if (getSiTrueObjects.isNotEmpty) {
iAgreeForAddOn.add(int.parse(topUpClientPolicyId));
}
}
if (topUpParentMappedFamilyFloatersSi != null) {
dynamic getSiTrueObjects = topUpParentMappedFamilyFloatersSi
.where((element) => element['is_value_exist'] == true)
.toList();
print(getSiTrueObjects);
if (getSiTrueObjects.isNotEmpty) {
iAgreeForAddOn.add(int.parse(topUpParentClientPolicyId));
}
}
print('gpaPolicies');
print(gpaPolicies);
print('gmcPolicies');
print(gmcPolicies);
if (gpaDataIsEmpty != 0) {
iAgreeForAddOn.add(int.parse(gpaClintPolicyId));
}
if (gmcDataIsEmpty != 0) {
for (var item in gmcPolicies) {
// Extract ClientPolicyId value from each object
String clientPolicyId = item['ClientPolicyId'];
// Convert to integer and add to iAgreeForAddOn list
iAgreeForAddOn.add(int.parse(clientPolicyId));
}
}
print('iAgreeForAddOn');
iAgreeForAddOn = iAgreeForAddOn.toSet().toList();
print(iAgreeForAddOn); // Output: [90, 92, 88, 89]
Map<String, dynamic> apiParams = {
'emp_code': empCodeString,
'client_policy_id': iAgreeForAddOn,
'client_id': client_id,
};
print(apiParams);
// Convert the list of objects to JSON
String formDataJson = jsonEncode(apiParams);
try {
final response = await apiService.sendAddOnToAPI(apiParams);
if (response['status'] == 'success') {
setState(() {
isLoading = false;
isChecked = false;
});
print('response.statusCode == 200');
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
_showSuccessDialog();
} else {
setState(() {
isLoading = false;
});
// Handle other status codes
ToastHelper.showErrorToast(context, 'Failed to Save');
_showErrorDialog();
print('Request failed with status: ${response['code']}');
}
} catch (e) {
setState(() {
isLoading = false;
});
// Handle exceptions
print('Exception occurred: $e');
}
}
void _showSuccessDialog() {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: Colors.white,
title: Text(
'Success',
style: GoogleFonts.poppins(
color: Colors.green,
),
),
content: Text('Enrollment Completed'),
actions: <Widget>[
TextButton(
child: Text(
'OK',
style: GoogleFonts.poppins(
color: Color(0xFFE26728),
),
),
onPressed: () {
Navigator.popAndPushNamed(context, 'home');
},
),
],
);
},
);
}
void _showErrorDialog() {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(
'Error',
style: GoogleFonts.poppins(
color: Colors.red,
),
),
content: Text('Something went wrong. Enrollemnt not completed'),
actions: <Widget>[
TextButton(
child: Text(
'OK',
style: GoogleFonts.poppins(
color: Color(0xFFE26728),
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
@override
Widget build(BuildContext context) {
if ((gpaMappedFamilyFloaters == [] && gpaMappedFamilyFloaters == null) &&
(gmcMappedFamilyFloaters == [] && gmcMappedFamilyFloaters == null)) {
return Scaffold(
appBar: CustomAppBar(),
body: SingleChildScrollView(
child: Container(
color: Color(0xFFEFF3F6),
child: Column(
children: [
Center(
child: Text('No Data Available',
style: GoogleFonts.poppins(
fontSize: 16,
fontWeight: FontWeight.bold,
)),
)
],
),
),
));
} else {
return Scaffold(
appBar: CustomAppBar(),
body: Stack(children: [
SingleChildScrollView(
child: Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width *
0.2, // 30% of screen width as horizontal padding
vertical: MediaQuery.of(context).size.height *
0.03, // 5% of screen height as vertical padding
)
: EdgeInsets.all(10),
color: Color(0xFFEFF3F6),
child: Column(
children: [
Card(
elevation: 0,
color: Colors.white,
child: Container(
width: double.infinity,
height: 75,
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 20, bottom: 20, left: 30, right: 30)
: EdgeInsets.only(
top: 12,
bottom: 12,
left: 10,
right: 10), // Add padding to the container
child: Row(
children: [
Expanded(
flex: 6,
child: Container(
width: 150,
height: 150,
alignment: Alignment.centerLeft,
child: Image.network(
clientLogo ?? '',
width: 80, // Set the width here
height: 80, // Set the height here
loadingBuilder: (BuildContext context,
Widget child,
ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) return child;
return Center(
child: CircularProgressIndicator(
value:
loadingProgress.expectedTotalBytes !=
null
? loadingProgress
.cumulativeBytesLoaded /
loadingProgress
.expectedTotalBytes!
: null,
),
);
},
errorBuilder: (BuildContext context,
Object error, StackTrace? stackTrace) {
return Image.asset(
'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path
width: 80,
height: 80,
fit: BoxFit.cover,
);
},
),
),
),
Expanded(
flex: 9,
child: Text(
clientName ?? '',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 20 : 18,
fontWeight: FontWeight.w600,
),
),
)
],
),
),
),
SizedBox(height: 16),
Card(
elevation: 0,
color: Colors.white,
child: Container(
width: double.infinity,
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(
10), // Add padding to the container
child: Column(children: [
Row(
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Review',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 20
: 18,
color: Color(0xFF181818),
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
Row(
children: [
Expanded(
flex: 6,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Total Payable',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 18
: 16,
color: Color(0xFF181818),
),
),
],
))),
Expanded(
flex: 6,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'$totalPayableAmt/Year ',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 22
: 18,
color: Color(0xFFE26728),
fontWeight: FontWeight.w500,
),
),
],
))),
],
),
])),
),
SizedBox(height: 16),
if (gpaPolicies != null && gpaPolicies.length > 0)
Card(
elevation: 0,
color: Colors.white,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Color(
0xFFFFF1DD), // Set background color for the container
borderRadius: BorderRadius.circular(
5), // Set border radius for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 15,
bottom: 15,
left: 25,
right: 25)
: EdgeInsets.only(
top: 10,
bottom: 10,
left: 10,
right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 9,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
gpaPolicyName ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
),
),
Row(
children: [
Text(
'Group Personal Accident Coverage',
textAlign: TextAlign.left,
style:
GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 20
: 14,
fontWeight:
FontWeight.w600,
),
),
if (gpaECardDownload !=
null)
GestureDetector(
onTap: () async {
// Convert the URL string to a Uri object
Uri uri = Uri.parse(
gpaECardDownload);
// Check if the URL is valid
if (await canLaunchUrl(
uri)) {
// Open the URL in the default browser
await launchUrl(
uri);
} else {
// Handle the case where the URL cannot be launched
print(
'Could not launch $gpaECardDownload');
}
},
child: MouseRegion(
cursor:
SystemMouseCursors
.click,
child: Icon(
Icons.file_download,
color: Color(
0xFFE26728),
size: 25,
),
),
),
],
),
],
))),
Expanded(
flex: 3,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
'Sum Insured',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
),
),
Text(
'${gpasumInsured != null ? gpasumInsured : 'NA'}',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 20
: 14,
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 0, bottom: 0, left: 15, right: 15)
: EdgeInsets.only(
top: 0, bottom: 0, left: 5, right: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Icon(Icons.arrow_right,
color: Color(
0xFFE26728)), // Arrow icon
SizedBox(
width: Responsive.isDesktop(context)
? 10
: 5), // Space between icon and text
Expanded(
child: Text(
gpaSelfDetails ?? '',
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 18
: 16,
color: Color(0xFF232526),
),
),
),
],
),
],
),
),
],
),
)),
SizedBox(height: 16),
if (gmcPolicies != null && gmcPolicies.length > 0)
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
...generateGmcCards(gmcPolicies),
],
),
SizedBox(height: 16),
if (showHideTopUpCard == 1)
Card(
elevation: 0,
color: Colors.white,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Add Ons',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 16,
color: Color(0xFF181818),
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
decoration: BoxDecoration(
color: Color(
0xFFFFF1DD), // Set background color for the container
borderRadius: BorderRadius.circular(
5), // Set border radius for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 15,
bottom: 15,
left: 25,
right: 25)
: EdgeInsets.only(
top: 10,
bottom: 10,
left: 10,
right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 9,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
topUpPolicyName ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
),
),
Row(
children: [
Text(
'Group Medical Coverage - Top Up',
textAlign: TextAlign.left,
style:
GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 20
: 14,
fontWeight:
FontWeight.w600,
),
),
if (topUpECardDownload !=
null)
GestureDetector(
onTap: () async {
// Convert the URL string to a Uri object
Uri uri = Uri.parse(
topUpECardDownload);
// Check if the URL is valid
if (await canLaunchUrl(
uri)) {
// Open the URL in the default browser
await launchUrl(
uri);
} else {
// Handle the case where the URL cannot be launched
print(
'Could not launch $topUpECardDownload');
}
},
child: MouseRegion(
cursor:
SystemMouseCursors
.click,
child: Icon(
Icons.file_download,
color: Color(
0xFFE26728),
size: 25,
),
),
),
],
),
],
))),
Expanded(
flex: 3,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
topUpFloaterTextHeading ?? '',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
),
),
Text(
'${topUpSumInsured != null ? topUpSumInsured : 'NA'}',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 20
: 14,
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 0, bottom: 0, left: 15, right: 15)
: EdgeInsets.only(
top: 0, bottom: 0, left: 5, right: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: topUpMappedFamilyFloatersSiArray
.where((item) =>
item['is_value_exist'] == true)
.map<Widget>((item) {
Map<String, dynamic> data = item['data'];
String formattedDate =
formatDate(data['dob']);
return Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Icon(Icons.arrow_right,
color: Color(
0xFFE26728)), // Arrow icon
SizedBox(
width: Responsive.isDesktop(context)
? 10
: 5), // Space between icon and text
Expanded(
child: Text(
'${data['name']} ~ ${data['relationship']} ~ DOB : $formattedDate',
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 18
: 16,
color: Color(0xFF232526),
),
),
),
],
);
}).toList(),
),
),
],
),
)),
SizedBox(height: showHideTopUpCard == 1 ? 16 : 0),
if (showHideTopUpParentCard == 1)
Card(
elevation: 0,
color: Colors.white,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Add Ons',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 16,
color: Color(0xFF181818),
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
decoration: BoxDecoration(
color: Color(
0xFFFFF1DD), // Set background color for the container
borderRadius: BorderRadius.circular(
5), // Set border radius for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 15,
bottom: 15,
left: 25,
right: 25)
: EdgeInsets.only(
top: 10,
bottom: 10,
left: 10,
right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 9,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
topUpParentPolicyName ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
),
),
Container(
// padding: EdgeInsets.all(8.0),
child: Row(
children: [
Flexible(
child: Text(
topUpParentTypeName ??
'',
textAlign:
TextAlign.left,
style: GoogleFonts
.poppins(
fontSize: Responsive
.isDesktop(
context)
? 20
: 14,
fontWeight:
FontWeight.w600,
),
softWrap: true,
overflow: TextOverflow
.visible,
),
),
if (topUpParentECardDownload !=
null)
GestureDetector(
onTap: () async {
// Convert the URL string to a Uri object
Uri uri = Uri.parse(
topUpParentECardDownload);
// Check if the URL is valid
if (await canLaunchUrl(
uri)) {
// Open the URL in the default browser
await launchUrl(
uri);
} else {
// Handle the case where the URL cannot be launched
print(
'Could not launch $topUpParentECardDownload');
}
},
child: MouseRegion(
cursor:
SystemMouseCursors
.click,
child: Icon(
Icons
.file_download,
color: Color(
0xFFE26728),
size: 25,
),
),
),
],
),
)
],
))),
Expanded(
flex: 3,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
topUpParentFloterTextHeading ??
'',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
),
),
Text(
'${topUpParentSiValue != null ? topUpParentSiValue : 'NA'}',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 20
: 14,
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 0, bottom: 0, left: 15, right: 15)
: EdgeInsets.only(
top: 0, bottom: 0, left: 5, right: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: topUpParentMappedFamilyFloatersSi
.where((item) =>
item['is_value_exist'] == true)
.map<Widget>((item) {
Map<String, dynamic> data = item['data'];
String formattedDate =
formatDate(data['dob']);
return Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Icon(Icons.arrow_right,
color: Color(
0xFFE26728)), // Arrow icon
SizedBox(
width: Responsive.isDesktop(context)
? 10
: 5), // Space between icon and text
Expanded(
child: Text(
'${data['name']} ~ ${data['relationship']} ~ DOB : $formattedDate',
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 18
: 16,
color: Color(0xFF232526),
),
),
),
],
);
}).toList(),
),
),
],
),
)),
SizedBox(height: showHideTopUpCard == 1 ? 16 : 0),
if (showHideAddOnsCard == 1)
Card(
elevation: 0,
color: Colors.white,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Add Ons',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 16,
color: Color(0xFF181818),
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
decoration: BoxDecoration(
color: Color(
0xFFFFF1DD), // Set background color for the container
borderRadius: BorderRadius.circular(
5), // Set border radius for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 15,
bottom: 15,
left: 25,
right: 25)
: EdgeInsets.only(
top: 10,
bottom: 10,
left: 10,
right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: Responsive.isDesktop(context)
? 9
: 8,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
addOnsDependentPolicyName ??
'',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 14,
),
),
Row(
children: [
Text(
'Group Medical Coverage - Dependent AddOns',
textAlign: TextAlign.left,
style:
GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 20
: 16,
fontWeight:
FontWeight.w600,
),
),
if (addOnsDependentECardDownload !=
null)
GestureDetector(
onTap: () async {
// Convert the URL string to a Uri object
Uri uri = Uri.parse(
addOnsDependentECardDownload);
// Check if the URL is valid
if (await canLaunchUrl(
uri)) {
// Open the URL in the default browser
await launchUrl(
uri);
} else {
// Handle the case where the URL cannot be launched
print(
'Could not launch $addOnsDependentECardDownload');
}
},
child: MouseRegion(
cursor:
SystemMouseCursors
.click,
child: Icon(
Icons.file_download,
color: Color(
0xFFE26728),
size: 25,
),
),
),
],
),
],
))),
Expanded(
flex: Responsive.isDesktop(context)
? 3
: 4,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
addOnsFloaterTextHeading ??
'',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 14,
),
),
Text(
'${addOnsDependentSumInsured != null ? addOnsDependentSumInsured : 'NA'}',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 20
: 16,
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 0, bottom: 0, left: 15, right: 15)
: EdgeInsets.only(
top: 0, bottom: 0, left: 5, right: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children:
addOnsDependentMappedFamilyFloatersArray
.where((item) =>
item['is_value_exist'] == true)
.map<Widget>((item) {
Map<String, dynamic> data = item['data'];
return Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Icon(Icons.arrow_right,
color: Color(
0xFFE26728)), // Arrow icon
SizedBox(
width: Responsive.isDesktop(context)
? 10
: 5), // Space between icon and text
Expanded(
child: Text(
'${data['name']} - ${data['relationship']} - ${data['dob']}',
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 18
: 16,
color: Color(0xFF232526),
),
),
),
],
);
}).toList(),
),
),
],
),
)),
SizedBox(height: showHideAddOnsCard == 1 ? 16 : 0),
Card(
elevation: 0,
color: Colors.white,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Premium Summary',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 16,
color: Color(0xFF181818),
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment
.centerLeft, // Adjust padding as needed
child: Table(
columnWidths: {
0: FlexColumnWidth(
2), // Adjust column width as needed
1: FlexColumnWidth(2),
2: FlexColumnWidth(
2), // Adjust column width as needed
3: FlexColumnWidth(2),
},
children: [
TableRow(
children: [
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'Policy ',
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 16
: 14,
fontWeight:
FontWeight.bold),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'Additional Premium',
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 16
: 14,
fontWeight:
FontWeight.bold),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'GST',
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 16
: 14,
fontWeight:
FontWeight.bold),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'Total',
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 16
: 14,
fontWeight:
FontWeight.bold),
),
),
),
],
),
if (activeSiData == 1)
TableRow(
children: [
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
Responsive.isDesktop(
context)
? topUpTypeName
: 'GMC - Top Up',
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 14
: 12),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'$topUpSiPremiumValue/Year',
textAlign: Responsive
.isDesktop(
context)
? TextAlign.start
: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 14
: 12),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'$topUpSiPremiumGst/-',
textAlign: Responsive
.isDesktop(
context)
? TextAlign.start
: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 14
: 12),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'$topUpSiTotalAmt/Year',
textAlign: Responsive
.isDesktop(
context)
? TextAlign.start
: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 14
: 12),
),
),
),
],
),
if (activeSiParentData == 1)
TableRow(
children: [
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
Responsive.isDesktop(
context)
? topUpParentTypeName
: 'GMC - Parents Top Up',
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 14
: 12),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'$topUpParentSiPremiumValue/Year',
textAlign: Responsive
.isDesktop(
context)
? TextAlign.start
: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 14
: 12),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'$topUpParentSiPremiumGst/-',
textAlign: Responsive
.isDesktop(
context)
? TextAlign.start
: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 14
: 12),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'$topUpParentSiTotalAmt/Year',
textAlign: Responsive
.isDesktop(
context)
? TextAlign.start
: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 14
: 12),
),
),
),
],
),
if (activeDependentData == 1)
TableRow(
children: [
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
Responsive.isDesktop(
context)
? 'Group Medical Coverage - Add Dependent'
: 'GMC - Dependent ',
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 14
: 12),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'$addOnDependentPremiumValue/Year',
textAlign: Responsive
.isDesktop(
context)
? TextAlign.start
: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 14
: 12),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'$addOnsDependentPremiumGst/-',
textAlign: Responsive
.isDesktop(
context)
? TextAlign.start
: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 14
: 12),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'$addOnsDependentTotalAmt/Year',
textAlign: Responsive
.isDesktop(
context)
? TextAlign.start
: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 14
: 12),
),
),
),
],
),
],
),
))
],
),
),
SizedBox(height: 10),
Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 6,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Total Payable',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 20
: 16,
color: Color(0xFF181818),
fontWeight: FontWeight.w600,
),
),
],
))),
Expanded(
flex: 6,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
'$totalPayableAmt/Year',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 16,
color: Color(0xFFE26728),
fontWeight: FontWeight.w500,
),
),
],
)))
],
),
),
SizedBox(height: 15),
Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 1,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Checkbox(
value: isChecked,
onChanged: (bool? value) {
setState(() {
isChecked = value!;
});
},
activeColor: Color(0xFFE26728),
),
],
))),
Expanded(
flex: 11,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
'I declare that the information I have provided is true and accurate to the best of my knowledge',
textAlign: Responsive.isDesktop(
context)
? TextAlign.left
: TextAlign.start,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 15,
color: Color(0xFF292929),
),
),
],
))),
],
),
),
SizedBox(
height: Responsive.isDesktop(context) ? 15 : 0),
Container(
child: Row(
children: [
Expanded(
flex: 6,
child: Container(
width: 150,
height: Responsive.isDesktop(context)
? 150
: 100,
alignment: Alignment.centerLeft,
child: ElevatedButton(
onPressed: () async {
// Remove siData, siParentData, and dependentData from local storage
final SharedPreferences prefs =
await SharedPreferences
.getInstance();
prefs.remove('siData');
prefs.remove('siParentData');
prefs.remove('dependentData');
Navigator.pushNamed(
context, 'addOnsDetails');
},
child: Text(
'Back',
style: GoogleFonts.poppins(
color: Color(0xFFE26728)),
),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(5),
side: BorderSide(
color: Color(0xFFE26728)),
),
),
),
)),
Expanded(
flex: 6,
child: Container(
width: 150,
height: 150,
alignment: Alignment.centerRight,
child: ElevatedButton(
onPressed:
isChecked ? sendAddOnAPI : null,
child: Text(
'Submit',
style: GoogleFonts.poppins(
color: Colors.white),
),
style: ElevatedButton.styleFrom(
backgroundColor: Color(0xFFE26728),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(5),
),
),
),
)),
],
),
),
],
),
)),
SizedBox(height: 30)
],
),
),
),
if (isLoading)
Container(
color: Color(0x98FFFCE5), // Semi-transparent background
child: Center(
child: // Your GIF loader widget
Image.asset(
height: 60,
width: 60,
'assets/nhance-loader.gif'), // Adjust path to your GIF loader
),
),
if (Responsive.isDesktop(context) ||
(!Responsive.isDesktop(context) && selfEmpStatus != 'enrolled'))
Align(
alignment: Alignment.bottomCenter,
child: Container(
width: double.infinity, // Make the footer full width
child: CustomFooter(),
),
),
]),
floatingActionButton: Responsive.isDesktop(context)
? null
: selfEmpStatus == 'enrolled'
? FloatingActionButton(
onPressed: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) => chatbot()),
),
child: Icon(Icons.chat),
)
: null,
floatingActionButtonLocation: Responsive.isDesktop(context)
? null
: selfEmpStatus == 'enrolled'
? FloatingActionButtonLocation.miniEndFloat
: null,
bottomNavigationBar: Responsive.isDesktop(context)
? null
: selfEmpStatus == 'enrolled'
? CustomBottomNavigationBar(
onTabChanged: (index) {
// Add your navigation logic here
// For example:
if (index == 0) {
Navigator.pushNamed(context, 'home');
} else if (index == 1) {
Navigator.pushNamed(context, 'claims');
} else if (index == 2) {
Navigator.pushNamed(context, 'profile');
} else if (index == 3) {
Navigator.pushNamed(context, 'help');
}
},
icons: [
Icons.home_outlined,
Icons.sticky_note_2_outlined,
Icons.person_outline_outlined,
Icons.headset_mic_outlined,
],
labels: [
"Home",
"Claim",
"Profile",
"Help",
],
initialIndex:
0, // Initial index of the bottom navigation bar
)
: null,
);
}
}
List<Widget> generateGmcCards(List<dynamic> data) {
List<Widget> cards = [];
for (var item in data) {
setState(() {
gmcPolicyName = item['Policy_Name'];
gmcFloaterTextHeading = item['floter_text_heading'];
gmcFloaterTextDescription = item['floter_text_description'];
gmcNotes = item['notes'];
gmcECardDownload = item['eCardDownload'];
// gmcSumInsured = item['Policy_Terms']['sum_insured'];
gmcMappedFamilyFloaters = item['mapped_family_floaters'];
dynamic getTrueObjects = gmcMappedFamilyFloaters
.where((element) => element['is_value_exist'] == true)
.toList();
print('getTrueObjects');
print(getTrueObjects);
if (getTrueObjects.length > 0) {
print('true');
gmcSumInsured = gmcMappedFamilyFloaters[0]["data"]["basic_cover_si"];
} else {
print('false');
gmcSumInsured = item['Policy_Terms']['sum_insured'];
}
gmcTypeName = item['type'];
});
print('forEach Card');
print(gmcMappedFamilyFloaters);
dynamic getTrueObjects = gmcMappedFamilyFloaters
.where((element) => element['is_value_exist'] == true)
.toList();
print(getTrueObjects);
Widget card = getTrueObjects.length > 0
? Card(
elevation: 0,
color: Colors.white,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Color(
0xFFFFF1DD), // Set background color for the container
borderRadius: BorderRadius.circular(
5), // Set border radius for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 15, bottom: 15, left: 25, right: 25)
: EdgeInsets.only(
top: 10, bottom: 10, left: 10, right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 9,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
gmcPolicyName ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 18
: 13,
),
),
Row(
children: [
Text(
gmcTypeName ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 20
: 14,
fontWeight: FontWeight.w600,
),
),
if (gmcECardDownload != null)
GestureDetector(
onTap: () async {
// Convert the URL string to a Uri object
Uri uri =
Uri.parse(gmcECardDownload);
// Check if the URL is valid
if (await canLaunchUrl(uri)) {
// Open the URL in the default browser
await launchUrl(uri);
} else {
// Handle the case where the URL cannot be launched
print(
'Could not launch $gmcECardDownload');
}
},
child: MouseRegion(
cursor:
SystemMouseCursors.click,
child: Icon(
Icons.file_download,
color: Color(0xFFE26728),
size: 25,
),
),
),
],
),
],
))),
Expanded(
flex: 3,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
gmcFloaterTextHeading ?? '',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 18
: 13,
),
),
Text(
'${gmcSumInsured != null ? gmcSumInsured : 'NA'}',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 20
: 14,
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 0, bottom: 0, left: 15, right: 15)
: EdgeInsets.only(
top: 0, bottom: 0, left: 5, right: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: gmcMappedFamilyFloaters
.where((item) => item['is_value_exist'] == true)
.map<Widget>((item) {
Map<String, dynamic> data = item['data'];
String formattedDate = formatDate(data['dob']);
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.arrow_right,
color: Color(0xFFE26728)), // Arrow icon
SizedBox(
width: Responsive.isDesktop(context)
? 10
: 5), // Space between icon and text
Expanded(
child: Text(
'${data['name']} ~ ${data['relationship']} ~ DOB : $formattedDate',
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 18 : 16,
color: Color(0xFF232526),
),
),
),
],
);
}).toList(),
),
),
],
),
))
: SizedBox(height: 0);
cards.add(card);
}
return cards;
}
}