462 lines
17 KiB
Dart
Executable File
462 lines
17 KiB
Dart
Executable File
// import 'package:flutter/cupertino.dart';
|
|
// import 'package:flutter/material.dart';
|
|
// import 'package:flutter/services.dart';
|
|
// import 'package:google_fonts/google_fonts.dart';
|
|
// import 'package:http/http.dart' as http;
|
|
//
|
|
// import '../../presentation/hrPolicyDetails.dart';
|
|
// import '../api_service.dart';
|
|
//
|
|
// class ActivePolicies extends StatefulWidget {
|
|
// final String empClientId;
|
|
// final String empClientBranchId;
|
|
// final String empHrId;
|
|
// final String postToken;
|
|
//
|
|
// const ActivePolicies(
|
|
// {Key? key,
|
|
// required this.empClientId,
|
|
// required this.empClientBranchId,
|
|
// required this.postToken,
|
|
// required this.empHrId});
|
|
//
|
|
// @override
|
|
// State<ActivePolicies> createState() => _ActivePolicieState();
|
|
// }
|
|
//
|
|
// class _ActivePolicieState extends State<ActivePolicies> {
|
|
// late ApiService apiService;
|
|
// dynamic getCardArrays = [];
|
|
// int selectedIndex = 1;
|
|
// int stausVal = 1;
|
|
// bool isLoading = false;
|
|
//
|
|
// // List<Map<String, dynamic>> getCardArrays = [
|
|
// // {
|
|
// // "client_policy_id": 392,
|
|
// // "client_id": 58,
|
|
// // "policy_type_id": 2,
|
|
// // "is_addon": 1,
|
|
// // "OpenForEnrollment": 1,
|
|
// // "inception_type": 2,
|
|
// // "policy_no": "GMC-MA8596745566998855885",
|
|
// // "insurer_id": 1,
|
|
// // "type": "GMC",
|
|
// // "policy_name": "Group Medical Coverage",
|
|
// // "insurer_name": "Life Insurance Corporation of India (LIC)",
|
|
// // "insurer_short_name": "LIC",
|
|
// // "totalMembersCount": 7,
|
|
// // "membersCountOfEnrolled": 0,
|
|
// // "membersCountOfDraft": 7
|
|
// // },
|
|
// // {
|
|
// // "client_policy_id": 392,
|
|
// // "client_id": 58,
|
|
// // "policy_type_id": 2,
|
|
// // "is_addon": 1,
|
|
// // "OpenForEnrollment": 1,
|
|
// // "inception_type": 2,
|
|
// // "policy_no": "GMC-MA8596745566998855885",
|
|
// // "insurer_id": 1,
|
|
// // "type": "GMC",
|
|
// // "policy_name": "Group Medical Coverage",
|
|
// // "insurer_name": "Life Insurance Corporation of India (LIC)",
|
|
// // "insurer_short_name": "LIC",
|
|
// // "totalMembersCount": 7,
|
|
// // "membersCountOfEnrolled": 0,
|
|
// // "membersCountOfDraft": 7
|
|
// // },
|
|
// //
|
|
// // ];
|
|
//
|
|
// @override
|
|
// void initState() {
|
|
// super.initState();
|
|
// apiService = ApiService(context);
|
|
// _loadData();
|
|
//
|
|
// logDebug("_PreEnrollmentState 1");
|
|
// }
|
|
//
|
|
// Future<void> _loadData() async {
|
|
// await getCashDepositDetails(widget.empClientBranchId, widget.empClientId,
|
|
// widget.empHrId, widget.postToken);
|
|
// }
|
|
//
|
|
// Future<void> getCashDepositDetails(
|
|
// clintBranchId, clintID, hr_id, token) async {
|
|
// logDebug("_PreEnrollmentState 2");
|
|
// logDebug('IN');
|
|
// logDebug("clintBranchId -$clintBranchId");
|
|
// logDebug("clintID -$clintID");
|
|
// logDebug("hr_id -$hr_id");
|
|
// logDebug("token -$token");
|
|
//
|
|
// isLoading = true;
|
|
// // setState(() {
|
|
// // _isLoading = true;
|
|
// // });
|
|
// try {
|
|
// if (clintBranchId == null || clintID == null) {
|
|
// return;
|
|
// }
|
|
//
|
|
// final response = await apiService.getActiveCashDepositDetailsToApi(
|
|
// clintID!, clintBranchId!, hr_id, token, stausVal);
|
|
//
|
|
// // final response = await apiService.getCashDepositDetailsToApi(
|
|
// // clintID!, clintBranchId!, hr_id, token);
|
|
// logDebug('IN1');
|
|
// if (response['status'] == 'success') {
|
|
// isLoading = false;
|
|
// setState(() {
|
|
// logDebug('response');
|
|
// logDebug(response['data']);
|
|
//
|
|
// logDebug("_PreEnrollmentState 3");
|
|
// setState(() {
|
|
// getCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
|
// });
|
|
//
|
|
// logDebug('getCardArrays');
|
|
// logDebug(getCardArrays);
|
|
// });
|
|
//
|
|
// logDebug('IN2');
|
|
// logDebug("getCardArrays9 - $getCardArrays");
|
|
// } else {
|
|
// isLoading = false;
|
|
// logDebug('API request failed with status');
|
|
// setState(() {
|
|
// getCardArrays = [];
|
|
// });
|
|
// }
|
|
// } catch (e) {
|
|
// logDebug('Exception occurred: $e');
|
|
// }
|
|
// }
|
|
//
|
|
// @override
|
|
// Widget build(BuildContext context) {
|
|
// final screenWidth = MediaQuery.of(context).size.width;
|
|
// final screenHeight = MediaQuery.of(context).size.height;
|
|
//
|
|
// final crossAxisCount = 4;
|
|
// final spacing = 20.0; // crossAxisSpacing
|
|
// final totalSpacing = (crossAxisCount - 1) * spacing;
|
|
// final itemWidth = (screenWidth - totalSpacing) / crossAxisCount;
|
|
//
|
|
// // Example: target card height
|
|
// final itemHeight = screenHeight * 0.2;
|
|
//
|
|
// // Dynamic aspect ratio:
|
|
// final aspectRatio = screenWidth / screenHeight;
|
|
//
|
|
// logDebug("_PreEnrollmentState 4");
|
|
// // TODO: implement build
|
|
// return Container(
|
|
// // height: MediaQuery.of(context).size.height * 0.2,
|
|
//
|
|
// // height: 400,
|
|
// padding: const EdgeInsets.all(16.0),
|
|
// decoration: BoxDecoration(
|
|
// color: Colors.white,
|
|
// // color: Colors.yellow.shade100,
|
|
// borderRadius: BorderRadius.circular(16),
|
|
// ),
|
|
// //
|
|
//
|
|
// child: Column(
|
|
// children: [
|
|
// Row(
|
|
// mainAxisAlignment: MainAxisAlignment.end,
|
|
// children: [
|
|
// Container(
|
|
// // padding: const EdgeInsets.only(left: 16.0, right: 16.0),
|
|
// decoration: BoxDecoration(
|
|
// color: Colors.grey.shade50,
|
|
// boxShadow: const [
|
|
// BoxShadow(
|
|
// color: Colors.black54, // Grey shadow
|
|
// spreadRadius: 0.2,
|
|
// blurRadius: 6,
|
|
// offset: Offset(0, 1), // Horizontal, Vertical
|
|
// ),
|
|
// ],
|
|
// borderRadius: BorderRadius.circular(16),
|
|
// ),
|
|
//
|
|
// child: Row(
|
|
// children: [
|
|
// buildTab("Active", 0),
|
|
// const SizedBox(width: 10),
|
|
// buildTab("Expired", 1),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// const SizedBox(
|
|
// height: 15,
|
|
// ),
|
|
// isLoading
|
|
// ? Expanded(
|
|
// // 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
|
|
// ),
|
|
// )
|
|
// : Flexible(
|
|
// child: Container(
|
|
// // color: Colors.redAccent.shade100,
|
|
// // height: MediaQuery.of(context).size.height * 0.4,
|
|
// // mainAxisAlignment: MainAxisAlignment.center,
|
|
// // children: [
|
|
// child: Container(
|
|
// // color: Colors.redAccent.shade100,
|
|
// // color: Colors.white,
|
|
// // color: Colors.white,
|
|
// padding: EdgeInsets.symmetric(horizontal: 16.0),
|
|
// // height: MediaQuery.of(context).size.height * 0.4,
|
|
// // height: 400,
|
|
//
|
|
// child: getCardArrays.isEmpty
|
|
// ? Center(
|
|
// child: Text(
|
|
// 'No Policy Mapping Found',
|
|
// style: TextStyle(
|
|
// fontSize: 16,
|
|
// color: Colors.grey.shade600,
|
|
// ),
|
|
// ),
|
|
// )
|
|
// : GridView.builder(
|
|
// itemCount: getCardArrays.length,
|
|
// gridDelegate:
|
|
// SliverGridDelegateWithFixedCrossAxisCount(
|
|
// crossAxisCount: 4,
|
|
// crossAxisSpacing: 20,
|
|
// mainAxisSpacing: 20,
|
|
// // childAspectRatio: 2,
|
|
// childAspectRatio: aspectRatio,
|
|
// // childAspectRatio: 2.1,
|
|
// ),
|
|
// itemBuilder: (context, index) {
|
|
// return buildPolicyCard(getCardArrays[index]);
|
|
// },
|
|
// ),
|
|
// ),
|
|
// // ],
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// );
|
|
// }
|
|
//
|
|
// Widget buildPolicyCard(Map<String, dynamic> policy) {
|
|
// logDebug("buildPolicyCard - $policy");
|
|
// final mediaQuery = MediaQuery.of(context);
|
|
// final devicePixelRatio = mediaQuery.devicePixelRatio;
|
|
// final logicalWidth = 230 / devicePixelRatio;
|
|
// final logicalHeight = 115 / devicePixelRatio;
|
|
//
|
|
// logDebug("logicalWidth - $logicalWidth");
|
|
// logDebug("logicalHeight - $logicalHeight");
|
|
// return InkWell(
|
|
// onTap: () {
|
|
// setState(() {
|
|
// logDebug("policytab - $policy");
|
|
// Navigator.push(
|
|
// context,
|
|
// MaterialPageRoute(
|
|
// builder: (context) => hrPolicyDetails(
|
|
// ClientId: widget.empClientId, // <-- from map
|
|
// policyTypeId:
|
|
// policy['policy_type_id'].toString(), // <-- from map
|
|
// ClientPoliyId: policy['client_policy_id'].toString(),
|
|
// clientBranchId: widget.empClientBranchId,
|
|
// Token: widget.postToken,
|
|
// TokenType: 'post',
|
|
// cardType: policy['type'].toString(),
|
|
// cardPolicyNo: policy['policy_no'].toString(),
|
|
// cardInsurer_name: policy['insurer_short_name'].toString(),
|
|
// cardPolicy_name: policy['policy_name'].toString(),
|
|
// cardPolicy_ExpDate: policy['policy_expiry_date'].toString(),
|
|
// ),
|
|
// ),
|
|
// );
|
|
// });
|
|
// },
|
|
//
|
|
// // height: MediaQuery.of(context).size.height * 0.1,
|
|
// // width: MediaQuery.of(context).size.height * 0.1,
|
|
// // width: logicalWidth,
|
|
// // height: logicalHeight,
|
|
// child: Container(
|
|
// margin: EdgeInsets.symmetric(horizontal: 4.0, vertical: 2.0),
|
|
// // height: MediaQuery.of(context).size.height * 1,
|
|
// // width: MediaQuery.of(context).size.height * 0.1,
|
|
// // margin: EdgeInsets.only(bottom: 10.0),
|
|
// decoration: BoxDecoration(
|
|
// // color: Colors.yellow.shade50,
|
|
// color: Colors.white,
|
|
// borderRadius: BorderRadius.circular(12),
|
|
// boxShadow: const [
|
|
// BoxShadow(
|
|
// color: Colors.black12,
|
|
// blurRadius: 6,
|
|
// spreadRadius: 1,
|
|
// offset: Offset(0, 0), // Equal shadow in all directions
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// // shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
// child: Padding(
|
|
// padding: const EdgeInsets.all(12),
|
|
// child: Column(
|
|
// mainAxisSize: MainAxisSize.min,
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
// children: [
|
|
// Container(
|
|
// height: MediaQuery.of(context).size.height * 0.07,
|
|
// // color: Colors.green.shade100,
|
|
// child: Row(
|
|
// children: [
|
|
// Column(
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
// children: [
|
|
// Text(
|
|
// "${policy['type']} - ${policy['policy_no']} " ?? '',
|
|
// style: const TextStyle(
|
|
// fontFamily: "Inter",
|
|
// fontWeight: FontWeight.w600,
|
|
// fontSize: 12,
|
|
// ),
|
|
// ),
|
|
// policy['insurer_name'] != ''
|
|
// ? Text(
|
|
// // "${policy['insurer_short_name']} - ${policy['policy_name']} " ??
|
|
// // '',
|
|
//
|
|
// policy['insurer_name'] ?? "",
|
|
// style: const TextStyle(
|
|
// fontSize: 11,
|
|
// color: Colors.grey,
|
|
// ),
|
|
// )
|
|
// : SizedBox.shrink(),
|
|
// ],
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// // Spacer(),
|
|
// Container(
|
|
// // color: Colors.pink.shade50,
|
|
// height: MediaQuery.of(context).size.height * 0.09,
|
|
// child: Row(
|
|
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
// children: [
|
|
// _buildCountBox(
|
|
// policy['membersCountOfActive'].toString(),
|
|
// "Active",
|
|
// Color(0xFF7BD9B6),
|
|
// ),
|
|
//
|
|
// // Spacer(),
|
|
// _buildCountBox(
|
|
// policy['membersCountOfInactive'].toString(),
|
|
// "Inactive",
|
|
// Color(0xFFFFA6A6),
|
|
// ),
|
|
// // Spacer(),
|
|
// // _buildCountBox(
|
|
// // policy['totalMembersCount'].toString(), "Total"),
|
|
// // Spacer(),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// );
|
|
// }
|
|
//
|
|
// Widget _buildCountBox(String count, String label, Color boxColor) {
|
|
// return Column(
|
|
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
// children: [
|
|
// Container(
|
|
// // width: 70,
|
|
// // height: 40,
|
|
// height: MediaQuery.of(context).size.height * 0.05,
|
|
// width: MediaQuery.of(context).size.height * 0.1,
|
|
// alignment: Alignment.center,
|
|
// decoration: BoxDecoration(
|
|
// color: boxColor,
|
|
// // color: const Color(0xFFDFF1F3),
|
|
// borderRadius: BorderRadius.circular(8),
|
|
// ),
|
|
// child: Text(
|
|
// count,
|
|
// style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w600),
|
|
// ),
|
|
// ),
|
|
// // Spacer(),
|
|
// const SizedBox(height: 8),
|
|
// Text(label,
|
|
// style: const TextStyle(fontSize: 10, color: Color(0xFF848484))),
|
|
// ],
|
|
// );
|
|
// }
|
|
//
|
|
// Widget buildTab(String title, int index) {
|
|
// final isSelected = selectedIndex == index + 1;
|
|
// return InkWell(
|
|
// onTap: () {
|
|
// setState(() {
|
|
// selectedIndex = index + 1;
|
|
// if (selectedIndex == 2) {
|
|
// stausVal = 0;
|
|
// } else {
|
|
// stausVal = 1;
|
|
// }
|
|
// _loadData();
|
|
// });
|
|
// },
|
|
// child: Container(
|
|
// padding: const EdgeInsets.only(
|
|
// top: 6.5, bottom: 6.0, left: 20.0, right: 20.0),
|
|
// decoration: BoxDecoration(
|
|
// color: isSelected ? const Color(0xFF009195) : Colors.transparent,
|
|
// boxShadow: isSelected
|
|
// ? [
|
|
// BoxShadow(
|
|
// color: isSelected
|
|
// ? const Color(0xFF009195)
|
|
// : Colors.transparent, // Grey shadow
|
|
// spreadRadius: 0.2,
|
|
// blurRadius: 1,
|
|
// offset: const Offset(0, 1), // Horizontal, Vertical
|
|
// ),
|
|
// ]
|
|
// : [],
|
|
// borderRadius: BorderRadius.circular(16),
|
|
// ),
|
|
// child: Text(title,
|
|
// style: GoogleFonts.poppins(
|
|
// fontSize: 11,
|
|
// color: isSelected ? Colors.white : Colors.black,
|
|
// fontWeight: FontWeight.w500,
|
|
// ))),
|
|
// );
|
|
// }
|
|
// }
|