diff --git a/lib/hrDashboard.dart b/lib/hrDashboard.dart index eb6e406..e48f140 100755 --- a/lib/hrDashboard.dart +++ b/lib/hrDashboard.dart @@ -199,6 +199,7 @@ class _hrDashboardState extends State empClientId: empClientId, empClientBranchId: empClientBranchId, empHrId: empHrId, + empToken: _postToken, ), ); } @@ -420,556 +421,169 @@ class _hrDashboardState extends State return Scaffold( appBar: CustomAppBar(), body: Stack(children: [ - SingleChildScrollView( - child: Container( - padding: - EdgeInsets.only(top: 30, bottom: 200, left: 50, right: 50), - color: Color(0xFFEFF3F6), - child: Column( - children: [ - Container( - color: Colors.white, - width: double.infinity, - height: 75, - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 10, bottom: 10, left: 20, right: 20) - : 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, - ); - }, - ), + Container( + padding: const EdgeInsets.all(40), + + // padding: const EdgeInsets.only( + // top: 20, bottom: 20, left: 50, right: 50), + color: const Color(0xFFEFF3F6), + child: Column( + children: [ + Container( + color: Colors.white, + width: double.infinity, + // height: 75, + height: MediaQuery.of(context).size.height * 0.12, + padding: Responsive.isDesktop(context) + ? const EdgeInsets.only( + top: 10, bottom: 10, left: 20, right: 20) + : 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, - ), + ), + Expanded( + flex: 9, + child: Text( + clientName ?? '', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) ? 20 : 18, + fontWeight: FontWeight.w600, ), - ) - ], - ), - ), - - SizedBox(height: 16), - Container( - padding: const EdgeInsets.all(5), - decoration: BoxDecoration( - color: Color( - 0xFFC4E3E6), // 🔹 Background behind the TabBar - borderRadius: BorderRadius.circular(12), - border: Border.all(color: Colors.transparent), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.15), - blurRadius: 4, - offset: const Offset(0, 4), ), - ], - ), - child: TabBar( - controller: _tabController, - isScrollable: true, - labelPadding: const EdgeInsets.symmetric( - horizontal: 0, vertical: 0), - // indicator: BoxDecoration( - // color: const Color(0xFF00999E), // Selected tab background - // borderRadius: BorderRadius.circular(12), - // boxShadow: [ - // BoxShadow( - // color: Colors.black.withOpacity(0.2), - // blurRadius: 4, - // offset: const Offset(0, 2), - // ) - // ], - // ), - dividerColor: Colors.transparent, - indicatorColor: Colors.transparent, - labelColor: Colors.white, - unselectedLabelColor: const Color(0xFF828282), - // tabs: visibleTabs, - tabs: List.generate(tabData.length, (index) { - final data = tabData[index]; - return CustomTab( - icon: data['icon'], - label: data['label'], - isSelected: selectedIndex == index, - ); - }), - - // tabs: [ - // CustomTab( - // icon: Icons.grid_view, - // label: 'Pre Enrollment', - // isSelected: selectedIndex == 0), - // CustomTab( - // icon: Icons.verified_user, - // label: 'Active Policies', - // isSelected: selectedIndex == 1), - // CustomTab( - // icon: Icons.desktop_windows, - // label: 'CD', - // isSelected: selectedIndex == 2), - // CustomTab( - // icon: Icons.receipt_long, - // label: 'Claims', - // isSelected: selectedIndex == 3), - // ], - ), + ) + ], ), - SizedBox(height: 16), - // Expanded TabBarView - SizedBox( - height: 500, // Adjust height based on your layout + ), + + SizedBox(height: 16), + Container( + padding: const EdgeInsets.all(5), + height: MediaQuery.of(context).size.height * 0.08, + decoration: BoxDecoration( + color: + Color(0xFFC4E3E6), // 🔹 Background behind the TabBar + borderRadius: BorderRadius.circular(12), + border: Border.all(color: Colors.transparent), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.15), + blurRadius: 4, + offset: const Offset(0, 4), + ), + ], + ), + child: TabBar( + controller: _tabController, + isScrollable: true, + labelPadding: const EdgeInsets.symmetric( + horizontal: 0, vertical: 0), + // indicator: BoxDecoration( + // color: const Color(0xFF00999E), // Selected tab background + // borderRadius: BorderRadius.circular(12), + // boxShadow: [ + // BoxShadow( + // color: Colors.black.withOpacity(0.2), + // blurRadius: 4, + // offset: const Offset(0, 2), + // ) + // ], + // ), + dividerColor: Colors.transparent, + indicatorColor: Colors.transparent, + labelColor: Colors.white, + unselectedLabelColor: const Color(0xFF828282), + // tabs: visibleTabs, + tabs: List.generate(tabData.length, (index) { + final data = tabData[index]; + return CustomTab( + icon: data['icon'], + label: data['label'], + isSelected: selectedIndex == index, + ); + }), + + // tabs: [ + // CustomTab( + // icon: Icons.grid_view, + // label: 'Pre Enrollment', + // isSelected: selectedIndex == 0), + // CustomTab( + // icon: Icons.verified_user, + // label: 'Active Policies', + // isSelected: selectedIndex == 1), + // CustomTab( + // icon: Icons.desktop_windows, + // label: 'CD', + // isSelected: selectedIndex == 2), + // CustomTab( + // icon: Icons.receipt_long, + // label: 'Claims', + // isSelected: selectedIndex == 3), + // ], + ), + ), + SizedBox(height: 16), + // Expanded TabBarView + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 5), child: TabBarView( controller: _tabController, children: tabViews, ), - - // child: TabBarView( - // controller: _tabController, - // children: [ - // // Pre Enrollment Tab - // Card( - // elevation: 5, - // color: Colors.white, - // child: Container( - // child: GridView.builder( - // itemCount: getCardArrays.length, - // gridDelegate: - // const SliverGridDelegateWithFixedCrossAxisCount( - // crossAxisCount: - // 4, // Adjust for screen size (e.g., use 2 or 3 for tablets) - // crossAxisSpacing: 16, - // mainAxisSpacing: 0, - // childAspectRatio: 2, - // ), - // itemBuilder: (context, index) { - // return buildPolicyCard( - // getCardArrays[index]); - // }, - // ), - // )), - // - // Center(child: Text("Active Policies")), - // Center(child: Text("CD")), - // Center(child: Text("Claims")), - // ], - // ), ), - // if (getCardArrays.length != 0) - // Card( - // elevation: 0, - // color: Colors.white, - // child: Container( - // width: double.infinity, - // padding: Responsive.isDesktop(context) - // ? EdgeInsets.all(20) - // : EdgeInsets.all( - // 10), // Add padding to the container - // child: Column(children: [ - // Row(children: [ - // Text( - // 'Cash Transaction', - // style: GoogleFonts.poppins( - // fontSize: 18, - // fontWeight: FontWeight.w600, - // color: Colors.black, - // ), - // ) - // ]), - // SizedBox(height: 8), - // Row( - // children: [ - // // Create an Expanded widget with flex of 4 for each card - // for (var cardData in getCardArrays) - // Container( - // width: - // 300, // Set a fixed width for the card - // height: cardHeight, - // child: Card( - // elevation: 3, - // color: cardColors[ - // getCardArrays.indexOf(cardData) % - // cardColors.length], - // child: Column( - // crossAxisAlignment: - // CrossAxisAlignment.start, - // children: [ - // ListTile( - // title: SizedBox( - // height: 50, - // child: Text( - // cardData['insurerName'], - // style: GoogleFonts.poppins( - // fontSize: 18, - // fontWeight: FontWeight.w500, - // color: Color(0xFF000000), - // height: 1.5, - // ), - // ), - // ), - // subtitle: Text( - // 'Balance: ₹ ${cardData['balance']}', - // style: GoogleFonts.poppins( - // fontSize: 16, - // fontWeight: FontWeight.w400, - // color: Color(0xFF000000), - // height: 1.5, - // ), - // ), - // ), - // SizedBox(height: 10), - // Padding( - // padding: EdgeInsets.symmetric( - // horizontal: 15), - // child: GestureDetector( - // onTap: () { - // openForm( - // cardData['depositData'], - // cardData['insurerName'], - // cardData['clientId'], - // cardData['insurerId'], - // cardColors[getCardArrays - // .indexOf(cardData) % - // cardColors.length], - // ); - // }, - // child: MouseRegion( - // cursor: - // SystemMouseCursors.click, - // child: Align( - // alignment: - // Alignment.centerRight, - // child: Text( - // 'View Details', - // style: - // GoogleFonts.poppins( - // color: - // Color(0xFF000000), - // fontSize: 14, - // fontWeight: - // FontWeight.w300, - // height: 1.5, - // ), - // ), - // ), - // ), - // ), - // ), - // ], - // ), - // ), - // ), - // ], - // ), - // ])), - // ), - // SizedBox(height: 16), - // if (getCardArrays.length != 0) - // Card( - // elevation: 0, - // color: Colors.white, - // child: Padding( - // padding: Responsive.isDesktop(context) - // ? EdgeInsets.all(20) - // : EdgeInsets.all(10), - // child: Column( - // children: [ - // Row( - // children: [ - // Expanded( - // child: Column( - // crossAxisAlignment: - // CrossAxisAlignment.start, - // children: List.generate( - // numExpanded, - // (index) { - // var insurerName = getCardArrays[index] - // ['insurerName']; - // var policyDetails = - // getCardArrays[index] - // ['policyDetails']; - // - // // Determine the color for the policyDetails based on the index of the card in getCardArrays - // var cardColorIndex = - // getCardArrays.indexOf( - // getCardArrays[index]) % - // cardColors.length; - // var cardColor = - // cardColors[cardColorIndex]; - // - // return Column( - // crossAxisAlignment: - // CrossAxisAlignment.start, - // children: [ - // Text( - // insurerName, - // style: GoogleFonts.poppins( - // fontSize: 18, - // fontWeight: FontWeight.w600, - // color: Colors.black, - // ), - // ), - // SizedBox(height: 8), - // Row( - // children: [ - // IconButton( - // icon: - // Icon(Icons.arrow_back), - // onPressed: () { - // _scrollController - // .animateTo( - // _scrollController - // .offset - - // 300, - // duration: Duration( - // milliseconds: 500), - // curve: Curves.easeInOut, - // ); - // }, - // ), - // Expanded( - // child: - // SingleChildScrollView( - // scrollDirection: - // Axis.horizontal, - // controller: - // _scrollController, - // dragStartBehavior: - // DragStartBehavior - // .start, - // child: Row( - // children: List.generate( - // policyDetails.length, - // (index) => Container( - // width: 300, - // height: - // policyHeight, - // child: - // GestureDetector( - // onTap: () { - // Navigator.pushNamed( - // context, - // 'hrPolicyDetails', - // arguments: - // policyDetails[ - // index]); - // }, - // child: - // MouseRegion( - // cursor: - // SystemMouseCursors - // .click, - // child: Card( - // elevation: 3, - // color: - // cardColor, - // child: Column( - // crossAxisAlignment: - // CrossAxisAlignment - // .start, - // children: [ - // ListTile( - // title: - // SizedBox( - // height: - // 50, - // child: - // Text( - // '${policyDetails[index]['policy_name']} - (${policyDetails[index]['type']})', - // style: - // GoogleFonts.poppins( - // fontSize: 16, - // fontWeight: FontWeight.w500, - // color: Color(0xFF000000), - // height: 1.5, - // ), - // softWrap: - // true, - // ), - // ), - // ), - // SizedBox( - // height: - // 8), - // Padding( - // padding: EdgeInsets.only( - // left: - // 15, - // right: - // 15), - // child: - // Row( - // children: [ - // Expanded( - // flex: 4, - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // Text( - // 'Draft', - // style: GoogleFonts.poppins( - // fontSize: 16, - // fontWeight: FontWeight.w500, - // color: Color(0xFF000000), - // height: 1.5, - // ), - // ), - // Text( - // policyDetails[index]['membersCountOfDraft'].toString(), - // style: GoogleFonts.poppins( - // fontSize: 16, - // fontWeight: FontWeight.w400, - // color: Color(0xFF000000), - // height: 1.5, - // ), - // ), - // ], - // ), - // ), - // Expanded( - // flex: 4, - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // Text( - // 'Enrolled', - // style: GoogleFonts.poppins( - // fontSize: 16, - // fontWeight: FontWeight.w500, - // color: Color(0xFF000000), - // height: 1.5, - // ), - // ), - // Text( - // policyDetails[index]['membersCountOfEnrolled'].toString(), - // style: GoogleFonts.poppins( - // fontSize: 16, - // fontWeight: FontWeight.w400, - // color: Color(0xFF000000), - // height: 1.5, - // ), - // ), - // ], - // ), - // ), - // Expanded( - // flex: 4, - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // Text( - // 'Total', - // style: GoogleFonts.poppins( - // fontSize: 16, - // fontWeight: FontWeight.w500, - // color: Color(0xFF000000), - // height: 1.5, - // ), - // ), - // Text( - // policyDetails[index]['totalMembersCount'].toString(), - // style: GoogleFonts.poppins( - // fontSize: 16, - // fontWeight: FontWeight.w400, - // color: Color(0xFF000000), - // height: 1.5, - // ), - // ), - // ], - // ), - // ), - // ], - // ), - // ), - // ], - // ), - // ), - // ), - // ), - // ), - // ), - // ), - // ), - // ), - // IconButton( - // icon: Icon( - // Icons.arrow_forward), - // onPressed: () { - // _scrollController - // .animateTo( - // _scrollController - // .offset + - // 300, - // duration: Duration( - // milliseconds: 500), - // curve: Curves.easeInOut, - // ); - // }, - // ), - // ], - // ), - // SizedBox(height: 20), - // ], - // ); - // }, - // ), - // ), - // ), - // ], - // ), - // ], - // ), - // ), - // ) - ], - ), + ), + + // SizedBox( + // height: MediaQuery.of(context).size.height * 0.55, + // // height: 500, // Adjust height based on your layout + // child: TabBarView( + // controller: _tabController, + // children: tabViews, + // ), + // ), + ], ), ), if (isLoading) diff --git a/lib/service/api_service.dart b/lib/service/api_service.dart index ec64aeb..ab125eb 100755 --- a/lib/service/api_service.dart +++ b/lib/service/api_service.dart @@ -415,13 +415,30 @@ class ApiService { String clintID, String empRefId, String hr_id, String token) async { print("getCashDepositDetailsToApi1"); + if (token == null) { + await _initializeToken(); + } + final url = Uri.parse( + '${Environment.apiUrl}getPolicyLevelEmployeeSummaryData?client_id=$clintID&client_branch_id=$empRefId&hr_id=470'); + + final headers = { + 'Authorization': 'Bearer $token' ?? '', + }; + final response = await _makeGetRequest(url, headers); + return response; + } + + Future> getActiveCashDepositDetailsToApi(String clintID, + String empRefId, String hr_id, String token, int emp_status) async { + print("getCashDepositDetailsToApi1"); + if (token == null) { await _initializeToken(); } // final url = Uri.parse( // '${Environment.apiUrl}getPolicyLevelEmployeeSummaryData?client_id=$clintID&client_branch_id=$empRefId&hr_id=470'); final url = Uri.parse( - '${Environment.apiUrl}getPolicyLevelEmployeeSummaryData?client_id=$clintID&client_branch_id=$empRefId&hr_id=$hr_id'); + '${Environment.apiUrl}getPolicyLevelEmployeeSummaryData?client_id=$clintID&client_branch_id=$empRefId&policy_status=$emp_status&hr_id=$hr_id'); final headers = { 'Authorization': 'Bearer $token' ?? '', diff --git a/lib/service/hrDashboardTabs/activePolicies.dart b/lib/service/hrDashboardTabs/activePolicies.dart index 26bfb07..8240516 100644 --- a/lib/service/hrDashboardTabs/activePolicies.dart +++ b/lib/service/hrDashboardTabs/activePolicies.dart @@ -11,11 +11,13 @@ class ActivePolicies extends StatefulWidget { final String empClientId; final String empClientBranchId; final String empHrId; + final String empToken; const ActivePolicies( {Key? key, required this.empClientId, required this.empClientBranchId, + required this.empToken, required this.empHrId}); @override @@ -24,22 +26,221 @@ class ActivePolicies extends StatefulWidget { class _ActivePolicieState extends State { late ApiService apiService; - dynamic getCardArrays = []; - int selectedIndex = 0; + // dynamic getCardArrays = []; + int selectedIndex = 1; + + List> 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": 396, + "client_id": 58, + "policy_type_id": 4, + "is_addon": 2, + "OpenForEnrollment": 1, + "inception_type": 2, + "policy_no": "GMC-MA8596745566998855885", + "insurer_id": 1, + "type": "GMC - Topup", + "policy_name": "Group Medical Coverage Topup", + "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 + }, + { + "client_policy_id": 396, + "client_id": 58, + "policy_type_id": 4, + "is_addon": 2, + "OpenForEnrollment": 1, + "inception_type": 2, + "policy_no": "GMC-MA8596745566998855885", + "insurer_id": 1, + "type": "GMC - Topup", + "policy_name": "Group Medical Coverage Topup", + "insurer_name": "Life Insurance Corporation of India (LIC)", + "insurer_short_name": "LIC", + "totalMembersCount": 7, + "membersCountOfEnrolled": 0, + "membersCountOfDraft": 7 + }, + { + "client_policy_id": 396, + "client_id": 58, + "policy_type_id": 4, + "is_addon": 2, + "OpenForEnrollment": 1, + "inception_type": 2, + "policy_no": "GMC-MA8596745566998855885", + "insurer_id": 1, + "type": "GMC - Topup", + "policy_name": "Group Medical Coverage Topup", + "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 + }, + { + "client_policy_id": 396, + "client_id": 58, + "policy_type_id": 4, + "is_addon": 2, + "OpenForEnrollment": 1, + "inception_type": 2, + "policy_no": "GMC-MA8596745566998855885", + "insurer_id": 1, + "type": "GMC - Topup", + "policy_name": "Group Medical Coverage Topup", + "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(); + + print("_PreEnrollmentState 1"); + } + + Future _loadData() async { + await getCashDepositDetails(widget.empClientBranchId, widget.empClientId, + widget.empHrId, widget.empToken); + } + + Future getCashDepositDetails( + clintBranchId, clintID, hr_id, token) async { + print("_PreEnrollmentState 2"); + print('IN'); + print("clintBranchId -$clintBranchId"); + print("clintID -$clintID"); + print("hr_id -$hr_id"); + print("token -$token"); + + // isLoading = true; + // setState(() { + // _isLoading = true; + // }); + try { + if (clintBranchId == null || clintID == null) { + return; + } + + final response = await apiService.getActiveCashDepositDetailsToApi( + clintID!, clintBranchId!, hr_id, token, selectedIndex); + + // final response = await apiService.getCashDepositDetailsToApi( + // clintID!, clintBranchId!, hr_id, token); + print('IN1'); + if (response['status'] == 'success') { + // isLoading = false; + setState(() { + print('response'); + print(response['data']); + + print("_PreEnrollmentState 3"); + getCardArrays = List>.from(response['data']); + print('getCardArrays'); + print(getCardArrays); + }); + + print('IN2'); + print("getCardArrays9 - $getCardArrays"); + } else { + print('API request failed with status'); + } + } catch (e) { + print('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; + + print("_PreEnrollmentState 4"); // TODO: implement build return Container( - color: Colors.white, + // 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( @@ -70,36 +271,182 @@ class _ActivePolicieState extends State { ), ], ), - // Container( - // color: Colors.amber, - // child: Card( - // elevation: 5, - // color: Colors.white, - // child: GridView.builder( - // itemCount: getCardArrays.length, - // gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - // crossAxisCount: 4, - // crossAxisSpacing: 16, - // mainAxisSpacing: 0, - // childAspectRatio: 2, - // ), - // itemBuilder: (context, index) { - // return buildPolicyCard(getCardArrays[index]); - // }, - // ), - // ), - // ), + SizedBox( + height: 20, + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + 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: 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 buildTab(String title, int index) { - final isSelected = selectedIndex == index; + Widget buildPolicyCard(Map policy) { + final mediaQuery = MediaQuery.of(context); + final devicePixelRatio = mediaQuery.devicePixelRatio; + final logicalWidth = 230 / devicePixelRatio; + final logicalHeight = 115 / devicePixelRatio; + + print("logicalWidth - $logicalWidth"); + print("logicalHeight - $logicalHeight"); return GestureDetector( onTap: () { setState(() { - selectedIndex = index; + print("policy"); + }); + }, + + // 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['policy_no']} " ?? '', + style: const TextStyle( + fontFamily: "Inter", + fontWeight: FontWeight.w600, + fontSize: 14, + ), + ), + Text( + "${policy['insurer_short_name']} - ${policy['policy_name']} " ?? + '', + style: const TextStyle( + fontSize: 12, + color: Colors.grey, + ), + ), + ], + ), + ], + ), + ), + // Spacer(), + Container( + // color: Colors.pink.shade50, + height: MediaQuery.of(context).size.height * 0.09, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + _buildCountBox( + policy['membersCountOfDraft'].toString(), + "Active", + Color(0xFF7BD9B6), + ), + // Spacer(), + _buildCountBox( + policy['membersCountOfEnrolled'].toString(), + "Inactive", + Color(0xFFFF2020), + ), + // 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 GestureDetector( + onTap: () { + setState(() { + selectedIndex = index + 1; }); }, child: Container( @@ -128,68 +475,4 @@ class _ActivePolicieState extends State { ))), ); } - - Widget buildPolicyCard(Map policy) { - return Card( - elevation: 3, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), - child: Padding( - padding: const EdgeInsets.all(12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - policy['type'] ?? '', - style: const TextStyle( - fontWeight: FontWeight.w600, - fontSize: 14, - ), - ), - const SizedBox(height: 4), - Text( - policy['policy_name'] ?? '', - style: const TextStyle( - fontSize: 12, - color: Colors.grey, - ), - ), - const SizedBox(height: 16), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - _buildCountBox( - policy['membersCountOfDraft'].toString(), "Draft"), - _buildCountBox( - policy['membersCountOfEnrolled'].toString(), "Enrolled"), - _buildCountBox(policy['totalMembersCount'].toString(), "Total"), - ], - ), - ], - ), - ), - ); - } - - Widget _buildCountBox(String count, String label) { - return Column( - children: [ - Container( - width: 50, - height: 40, - alignment: Alignment.center, - decoration: BoxDecoration( - color: const Color(0xFFDFF1F3), - borderRadius: BorderRadius.circular(8), - ), - child: Text( - count, - style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600), - ), - ), - const SizedBox(height: 6), - Text(label, - style: const TextStyle(fontSize: 12, color: Colors.black87)), - ], - ); - } } diff --git a/lib/service/hrDashboardTabs/preEnrollment.dart b/lib/service/hrDashboardTabs/preEnrollment.dart index 71aeb03..5549baf 100644 --- a/lib/service/hrDashboardTabs/preEnrollment.dart +++ b/lib/service/hrDashboardTabs/preEnrollment.dart @@ -28,6 +28,44 @@ class _PreEnrollmentState extends State { late ApiService apiService; dynamic getCardArrays = []; int selectedIndex = 0; + // List> 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": 396, + // "client_id": 58, + // "policy_type_id": 4, + // "is_addon": 2, + // "OpenForEnrollment": 1, + // "inception_type": 2, + // "policy_no": "GMC-MA8596745566998855885", + // "insurer_id": 1, + // "type": "GMC - Topup", + // "policy_name": "Group Medical Coverage Topup", + // "insurer_name": "Life Insurance Corporation of India (LIC)", + // "insurer_short_name": "LIC", + // "totalMembersCount": 7, + // "membersCountOfEnrolled": 0, + // "membersCountOfDraft": 7 + // }, + // + // + // ]; @override void initState() { @@ -79,6 +117,7 @@ class _PreEnrollmentState extends State { }); print('IN2'); + print("getCardArrays9 - $getCardArrays"); } else { print('API request failed with status'); } @@ -89,30 +128,57 @@ class _PreEnrollmentState extends State { @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; + print("_PreEnrollmentState 4"); // TODO: implement build return Container( - color: Colors.white, + // 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( + mainAxisAlignment: MainAxisAlignment.center, children: [ Container( - color: Colors.white, - child: SizedBox( - height: 400, - child: GridView.builder( - itemCount: getCardArrays.length, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 4, - crossAxisSpacing: 16, - mainAxisSpacing: 0, - childAspectRatio: 2, - ), - itemBuilder: (context, index) { - return buildPolicyCard(getCardArrays[index]); - }, + // color: Colors.redAccent.shade100, + // color: Colors.white, + // color: Colors.white, + padding: EdgeInsets.symmetric(horizontal: 16.0), + height: MediaQuery.of(context).size.height * 0.45, + // height: 400, + + child: 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]); + }, ), ), ], @@ -120,92 +186,115 @@ class _PreEnrollmentState extends State { ); } - Widget buildTab(String title, int index) { - final isSelected = selectedIndex == index; + Widget buildPolicyCard(Map policy) { + final mediaQuery = MediaQuery.of(context); + final devicePixelRatio = mediaQuery.devicePixelRatio; + final logicalWidth = 230 / devicePixelRatio; + final logicalHeight = 115 / devicePixelRatio; + + print("logicalWidth - $logicalWidth"); + print("logicalHeight - $logicalHeight"); return GestureDetector( onTap: () { setState(() { - selectedIndex = index; + print("policy"); }); }, - 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( - color: isSelected ? Colors.white : Colors.black, - fontWeight: FontWeight.w600, - ))), - ); - } - Widget buildPolicyCard(Map policy) { - return Card( - color: Colors.white, - elevation: 3, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), - child: Padding( - padding: const EdgeInsets.all(12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - policy['type'] ?? '', - style: const TextStyle( - fontFamily: "Inter", - fontWeight: FontWeight.w600, - fontSize: 14, - ), - ), - const SizedBox(height: 2), - Text( - policy['policy_name'] ?? '', - style: const TextStyle( - fontSize: 12, - color: Colors.grey, - ), - ), - const SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - _buildCountBox( - policy['membersCountOfDraft'].toString(), "Draft"), - _buildCountBox( - policy['membersCountOfEnrolled'].toString(), "Enrolled"), - _buildCountBox(policy['totalMembersCount'].toString(), "Total"), - ], + // 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['policy_no']} " ?? '', + style: const TextStyle( + fontFamily: "Inter", + fontWeight: FontWeight.w600, + fontSize: 14, + ), + ), + Text( + "${policy['insurer_short_name']} - ${policy['policy_name']} " ?? + '', + style: const TextStyle( + fontSize: 12, + color: Colors.grey, + ), + ), + ], + ), + ], + ), + ), + // Spacer(), + Container( + // color: Colors.pink.shade50, + height: MediaQuery.of(context).size.height * 0.09, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + _buildCountBox( + policy['membersCountOfDraft'].toString(), "Draft"), + Spacer(), + _buildCountBox(policy['membersCountOfEnrolled'].toString(), + "Enrolled"), + Spacer(), + _buildCountBox( + policy['totalMembersCount'].toString(), "Total"), + // Spacer(), + ], + ), + ), + ], + ), + ), ), ); } Widget _buildCountBox(String count, String label) { return Column( - mainAxisAlignment: MainAxisAlignment.center, + // mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( - width: 70, - height: 40, + // 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: const Color(0xFFDFF1F3), @@ -213,9 +302,10 @@ class _PreEnrollmentState extends State { ), child: Text( count, - style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600), + style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w600), ), ), + // Spacer(), const SizedBox(height: 8), Text(label, style: const TextStyle(fontSize: 10, color: Color(0xFF848484))),