1004 lines
43 KiB
Dart
1004 lines
43 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:jwt_decode/jwt_decode.dart';
|
|
import 'package:nhance_app_pwa/customAppBar/customAppBar.dart';
|
|
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
|
|
import 'package:nhance_app_pwa/pages/postEnrollment/service/svg_service.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:http/http.dart' as http;
|
|
|
|
import '../../customAppBar/customFooter.dart';
|
|
import '../../customAppBar/responsive.dart';
|
|
import '../../customAppBar/tabs.dart';
|
|
import '../../customAppBar/toastHelper.dart';
|
|
|
|
class claims extends StatefulWidget {
|
|
const claims({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<claims> createState() => _claimsState();
|
|
}
|
|
|
|
class _claimsState extends State<claims> {
|
|
bool isLoading = false;
|
|
late ApiService apiService;
|
|
int _currentIndex = 0;
|
|
bool isActive = true;
|
|
dynamic _token;
|
|
dynamic decodedToken;
|
|
dynamic empCodeString;
|
|
dynamic empPrimaryId;
|
|
dynamic client_id;
|
|
dynamic empName;
|
|
dynamic policyList;
|
|
dynamic policyDataIsEmpty = 1;
|
|
dynamic trackClaimsIsEmpty = 1;
|
|
dynamic policyHeading;
|
|
dynamic policyName;
|
|
dynamic EmployeePolicy;
|
|
List<Map<String, String>> employeeDetails = [];
|
|
dynamic argumentsData;
|
|
dynamic empMobileNo;
|
|
List<dynamic> reversedClaimsList = [];
|
|
List<dynamic> trackClaimsList = [];
|
|
int trackClaimsActive = 1;
|
|
int yourPlanActive = 0;
|
|
int? serviceId;
|
|
dynamic client_branch_id;
|
|
|
|
List<DropdownMenuItem<int>> getDepartmentItems() {
|
|
return [
|
|
DropdownMenuItem<int>(value: 1, child: Text('Department 1')),
|
|
DropdownMenuItem<int>(value: 2, child: Text('Department 2')),
|
|
DropdownMenuItem<int>(value: 3, child: Text('Department 3')),
|
|
];
|
|
}
|
|
|
|
void _onTabChanged(int index) {
|
|
setState(() {
|
|
_currentIndex = index;
|
|
});
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
apiService = ApiService(context);
|
|
_loadToken();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
Future<void> _loadToken() async {
|
|
print('_loadToken');
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
final String? token = prefs.getString('token');
|
|
if (token != null && token.isNotEmpty) {
|
|
setState(() {
|
|
_token = token;
|
|
});
|
|
// Decode the JWT token received from the API response
|
|
decodedToken = Jwt.parseJwt(token);
|
|
print(decodedToken);
|
|
client_branch_id = decodedToken['client_branch_id'];
|
|
empMobileNo = decodedToken['mobile'];
|
|
empName = decodedToken['name'];
|
|
empCodeString = prefs.getString('empCode');
|
|
print(empCodeString); // Check if emp_code is correct
|
|
empPrimaryId = prefs.getString('empPrimaryId');
|
|
client_id = prefs.getString('client_id');
|
|
print(client_id);
|
|
getActiveAndInactivePolicyDetails('Active');
|
|
getTrackClaimsList();
|
|
} 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, 'login');
|
|
}
|
|
}
|
|
|
|
Future<void> getActiveAndInactivePolicyDetails(String status) async {
|
|
if (client_id == null || empCodeString == null) {
|
|
return;
|
|
}
|
|
setState(() {
|
|
isLoading = true;
|
|
});
|
|
print('check 1');
|
|
final response = await apiService.getActiveAndInactivePolicyDetails(
|
|
client_id!, empCodeString!, status, client_branch_id);
|
|
print('check 1');
|
|
if (response['status'] == 'success') {
|
|
setState(() {
|
|
isLoading = false;
|
|
policyList = response['data'];
|
|
});
|
|
print(policyList);
|
|
} else {
|
|
setState(() {
|
|
policyDataIsEmpty = 0;
|
|
});
|
|
print('API request failed with status: ${response['status']}');
|
|
}
|
|
}
|
|
|
|
Future<void> getTrackClaimsList() async {
|
|
if (client_id == null || empCodeString == null) {
|
|
return;
|
|
}
|
|
print('check 1');
|
|
final response =
|
|
await apiService.getTrackClaimsList(empMobileNo!, empCodeString!);
|
|
print('check 1');
|
|
if (response['success'] == true) {
|
|
setState(() {
|
|
List<dynamic> data = response['data'];
|
|
|
|
print('Data from response: $data');
|
|
|
|
trackClaimsList = data.where((item) {
|
|
// Check if item is a Map and has the departmentId key
|
|
if (item is Map<String, dynamic> &&
|
|
item.containsKey('department_id')) {
|
|
final departmentId = item['department_id'];
|
|
|
|
// Print each departmentId for debugging
|
|
print('Item department_id: $departmentId');
|
|
|
|
// Ensure departmentId is an int or string, and compare
|
|
if (departmentId is int) {
|
|
return departmentId == 3 || departmentId == 4;
|
|
} else if (departmentId is String) {
|
|
return int.tryParse(departmentId) == 3 ||
|
|
int.tryParse(departmentId) == 4;
|
|
}
|
|
}
|
|
return false;
|
|
}).toList();
|
|
|
|
print('Filtered trackClaimsList: $trackClaimsList');
|
|
reversedClaimsList = List<Map<String, dynamic>>.from(trackClaimsList);
|
|
print('reversedClaimsList $reversedClaimsList');
|
|
trackClaimsList = reversedClaimsList.reversed.toList();
|
|
print('trackClaimsList $trackClaimsList');
|
|
});
|
|
print(trackClaimsList);
|
|
} else {
|
|
setState(() {
|
|
trackClaimsIsEmpty = 0;
|
|
});
|
|
print('API request failed with status: ${response['status']}');
|
|
}
|
|
}
|
|
|
|
String formatDate(String timestamp) {
|
|
// Convert the timestamp string to milliseconds
|
|
int milliseconds = int.parse(timestamp) * 1000;
|
|
|
|
// Create a DateTime object from milliseconds
|
|
DateTime date = DateTime.fromMillisecondsSinceEpoch(milliseconds);
|
|
|
|
// Format the DateTime object
|
|
String formattedDate = DateFormat('d MMM, y').format(date);
|
|
|
|
return formattedDate;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
dynamic arguments = ModalRoute.of(context)!.settings.arguments;
|
|
print('arguments');
|
|
print(arguments);
|
|
if (arguments == 0) {
|
|
print(arguments);
|
|
trackClaimsActive = 0;
|
|
yourPlanActive = 1;
|
|
isActive = false;
|
|
} else {
|
|
print("Arguments are null or not in the expected format");
|
|
}
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
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: Colors.white,
|
|
child: Column(children: [
|
|
Container(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
flex: 12,
|
|
child: InkWell(
|
|
onTap: () {
|
|
Navigator.pushNamed(context, 'home');
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Icon(
|
|
Icons
|
|
.chevron_left, // Replace with your desired icon
|
|
color: Color(0xFF000000),
|
|
size: 30,
|
|
),
|
|
SizedBox(
|
|
width:
|
|
5), // Adjust space between icon and text
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Claim assistance',
|
|
textAlign: TextAlign.start,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: Color(0xFF000000),
|
|
),
|
|
),
|
|
Text(
|
|
'Manage your claims',
|
|
textAlign: TextAlign.start,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
12, // Adjust the font size as needed
|
|
fontWeight: FontWeight.w400,
|
|
color: Color(0xFF000000),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
// Add more rows as needed
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 15),
|
|
MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: InkWell(
|
|
onTap: () {
|
|
Navigator.pushNamed(context, 'help');
|
|
},
|
|
child: Card(
|
|
elevation: 0,
|
|
shape: RoundedRectangleBorder(
|
|
side: BorderSide(
|
|
color: Color(0xFFD9D9D9), // Set the border color here
|
|
width: 1.0, // Set the border width here
|
|
),
|
|
borderRadius: BorderRadius.circular(
|
|
8.0), // Set the border radius here
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors
|
|
.white, // Set background color for the container
|
|
),
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 15, bottom: 15, left: 10, right: 10)
|
|
: EdgeInsets.only(
|
|
top: 15, bottom: 15, left: 10, right: 10),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Expanded(
|
|
flex: 11,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
SvgPicture.string(
|
|
SvgService.getSvg('contactUs'),
|
|
width: 25,
|
|
height: 25,
|
|
),
|
|
SizedBox(
|
|
width:
|
|
7), // Adjust space between icon and text
|
|
Text(
|
|
'Contact Us',
|
|
textAlign: TextAlign.center,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context)
|
|
? 18
|
|
: 12,
|
|
fontWeight: FontWeight.w500,
|
|
color: Color(0xFF000000),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 1,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
Icon(
|
|
Icons
|
|
.chevron_right, // Replace with your desired icon
|
|
color: Color(0xFFE26728),
|
|
size: 20,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 15),
|
|
MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: InkWell(
|
|
onTap: () {
|
|
Navigator.pushNamed(context, 'claimprocess');
|
|
},
|
|
child: Card(
|
|
elevation: 0,
|
|
shape: RoundedRectangleBorder(
|
|
side: BorderSide(
|
|
color: Color(0xFFD9D9D9), // Set the border color here
|
|
width: 1.0, // Set the border width here
|
|
),
|
|
borderRadius: BorderRadius.circular(
|
|
8.0), // Set the border radius here
|
|
),
|
|
child: Column(children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors
|
|
.white, // Set background color for the container
|
|
),
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 15, bottom: 15, left: 10, right: 10)
|
|
: EdgeInsets.only(
|
|
top: 15, bottom: 15, left: 10, right: 10),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Expanded(
|
|
flex: 11,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
SvgPicture.string(
|
|
SvgService.getSvg('fileClaims'),
|
|
width: 25,
|
|
height: 25,
|
|
),
|
|
SizedBox(
|
|
width:
|
|
7), // Adjust space between icon and text
|
|
Text(
|
|
'Know how to file a claim',
|
|
textAlign: TextAlign.center,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context)
|
|
? 18
|
|
: 12,
|
|
fontWeight: FontWeight.w500,
|
|
color: Color(0xFF000000),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 1,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
Icon(
|
|
Icons
|
|
.chevron_right, // Replace with your desired icon
|
|
color: Color(0xFFE26728),
|
|
size: 20,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
])),
|
|
),
|
|
),
|
|
SizedBox(height: 15),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color:
|
|
Color(0xFFF6FAFF), // Set background color for the container
|
|
borderRadius: BorderRadius.circular(
|
|
5), // Set border radius for the container
|
|
),
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(top: 10, bottom: 10, left: 25, right: 25)
|
|
: EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 10),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Expanded(
|
|
flex: 12,
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Expanded(
|
|
flex: 6,
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
setState(() {
|
|
isActive = true;
|
|
// policyList.clear();
|
|
yourPlanActive = 0;
|
|
trackClaimsActive = 1;
|
|
});
|
|
getActiveAndInactivePolicyDetails(
|
|
'Active');
|
|
},
|
|
child: isActive
|
|
? Material(
|
|
elevation: 5,
|
|
borderRadius:
|
|
BorderRadius.circular(10),
|
|
color: Colors.white,
|
|
child: TextButton(
|
|
onPressed: () {},
|
|
style: TextButton.styleFrom(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 140
|
|
: 50,
|
|
vertical: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 15
|
|
: 5),
|
|
// primary: Color(0xFF000000),
|
|
),
|
|
child: Text(
|
|
'Your Plan',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 18
|
|
: 13,
|
|
fontWeight:
|
|
FontWeight.w500,
|
|
color: Color(
|
|
0xFF000000)),
|
|
),
|
|
),
|
|
)
|
|
: Text(
|
|
'Your Plan',
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(
|
|
context)
|
|
? 18
|
|
: 13,
|
|
fontWeight: FontWeight.w400,
|
|
color: Color(0xFF636363),
|
|
),
|
|
),
|
|
),
|
|
)),
|
|
Expanded(
|
|
flex: 6,
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
setState(() {
|
|
isActive = false;
|
|
// trackClaimsList.clear();
|
|
yourPlanActive = 1;
|
|
trackClaimsActive = 0;
|
|
});
|
|
getTrackClaimsList();
|
|
},
|
|
child: !isActive
|
|
? Material(
|
|
elevation: 5,
|
|
borderRadius:
|
|
BorderRadius.circular(10),
|
|
color: Colors.white,
|
|
child: TextButton(
|
|
onPressed: () {},
|
|
style: TextButton.styleFrom(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 130
|
|
: 50,
|
|
vertical: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 15
|
|
: 5),
|
|
// primary: Color(0xFF000000),
|
|
),
|
|
child: Text(
|
|
'Track claims',
|
|
style:
|
|
GoogleFonts.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 18
|
|
: 13,
|
|
color:
|
|
Color(0xFF000000),
|
|
fontWeight:
|
|
FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
: Text(
|
|
'Track claims',
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(
|
|
context)
|
|
? 18
|
|
: 13,
|
|
fontWeight: FontWeight.w400,
|
|
color: Color(0xFF636363),
|
|
),
|
|
),
|
|
),
|
|
))
|
|
],
|
|
)
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 15),
|
|
if (policyList != null && policyList.length > 0)
|
|
if (yourPlanActive == 0)
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
...generateYourPlanList(policyList),
|
|
],
|
|
),
|
|
if (trackClaimsList != null && trackClaimsList.length > 0)
|
|
if (trackClaimsActive == 0)
|
|
SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: generateTrackList(
|
|
trackClaimsList), // Replace 'yourDataList' with your actual data list
|
|
),
|
|
),
|
|
SizedBox(height: Responsive.isDesktop(context) ? 40 : 70),
|
|
]),
|
|
)),
|
|
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))
|
|
Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: Container(
|
|
width: double.infinity, // Make the footer full width
|
|
child: CustomFooter(),
|
|
),
|
|
),
|
|
]),
|
|
floatingActionButton: Responsive.isDesktop(context)
|
|
? null
|
|
: FloatingActionButton(
|
|
onPressed: () {
|
|
Navigator.pushNamed(context, 'chatbot');
|
|
},
|
|
child: Icon(Icons.chat),
|
|
),
|
|
floatingActionButtonLocation: Responsive.isDesktop(context)
|
|
? null
|
|
: FloatingActionButtonLocation.miniEndFloat,
|
|
bottomNavigationBar: Responsive.isDesktop(context)
|
|
? null
|
|
: 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');
|
|
} else if (index == 4) {
|
|
Navigator.pushNamed(context, 'wellness');
|
|
}
|
|
},
|
|
icons: [
|
|
Icons.home_outlined,
|
|
Icons.sticky_note_2_outlined,
|
|
Icons.person_outline_outlined,
|
|
Icons.headset_mic_outlined,
|
|
Icons.health_and_safety_outlined,
|
|
],
|
|
labels: [
|
|
"Home",
|
|
"Claim",
|
|
"Profile",
|
|
"Help",
|
|
"Wellness",
|
|
],
|
|
initialIndex: 1, // Initial index of the bottom navigation bar
|
|
),
|
|
);
|
|
}
|
|
|
|
List<Widget> generateYourPlanList(List<dynamic> data) {
|
|
return [
|
|
ListView.builder(
|
|
shrinkWrap: true,
|
|
physics: NeverScrollableScrollPhysics(),
|
|
itemCount: data.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
var item = data[index];
|
|
String policyHeading = item['heading'];
|
|
String policyName = item['policy_name'];
|
|
String si_value = item['si_value'];
|
|
String policyEndDate = item['policy_end_date'];
|
|
String policyNo = item['policy_no'];
|
|
String clientPolicyId = item['client_policy_id'];
|
|
List<dynamic> employeePolicy = item['EmployeePolicy'];
|
|
|
|
return GestureDetector(
|
|
onTap: () {
|
|
var details = {'claimsDetails': item, 'fromClaimPage': 0};
|
|
Navigator.pushNamed(context, 'planclaimsform',
|
|
arguments: details);
|
|
},
|
|
child: MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: Card(
|
|
elevation: 5,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(15.0),
|
|
),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(15.0),
|
|
),
|
|
padding: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment
|
|
.spaceBetween, // Center content horizontally
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.center, // Center content vertically
|
|
children: [
|
|
Expanded(
|
|
flex: 7,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Insurer',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 16 : 12,
|
|
fontWeight: FontWeight.w400,
|
|
color: Color(0xFF979797),
|
|
),
|
|
),
|
|
Text(
|
|
policyName ?? '',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 18 : 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: Color(0xFF000000),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 4,
|
|
child: Container(
|
|
alignment: Alignment.centerRight,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
'Cover Amount',
|
|
textAlign: TextAlign.end,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 16 : 12,
|
|
fontWeight: FontWeight.w400,
|
|
color: Color(0xFF979797),
|
|
),
|
|
),
|
|
Text(
|
|
'₹ $si_value',
|
|
textAlign: TextAlign.end,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 18 : 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: Color(0xFF000000),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 1,
|
|
child: Container(
|
|
alignment: Alignment.centerRight,
|
|
child: Icon(
|
|
Icons.chevron_right,
|
|
color: Color(0xFFE26728),
|
|
size: Responsive.isDesktop(context) ? 30 : 26,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
];
|
|
}
|
|
|
|
List<Widget> generateTrackList(List<dynamic> data) {
|
|
return [
|
|
ListView.builder(
|
|
shrinkWrap: true,
|
|
physics: NeverScrollableScrollPhysics(),
|
|
itemCount: data.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
var item = data[index];
|
|
String claimsName = item['user_name'];
|
|
String claimsSubject = item['subject'];
|
|
String claimsDate = item['date'];
|
|
String claimsReplies = item['replies'];
|
|
String claimStatus = item['status_value'];
|
|
String claimsDepartmentName = item['department_name'];
|
|
List<dynamic> messageList = item['message_list'];
|
|
|
|
final Map<String, Color> statusColors = {
|
|
'Open': Colors.green,
|
|
'Answered': Colors.blue,
|
|
'Awaiting Reply': Colors.orange,
|
|
'Inprogress': Colors.yellow,
|
|
'Closed': Colors.red,
|
|
};
|
|
|
|
// Determine the color based on the claimStatus
|
|
Color statusColor;
|
|
if (claimStatus != null) {
|
|
statusColor = statusColors[claimStatus!] ?? Color(0xFF979797);
|
|
} else {
|
|
statusColor = Color(0xFF979797); // Default color if status is null
|
|
}
|
|
|
|
return GestureDetector(
|
|
onTap: () {
|
|
Navigator.pushNamed(context, 'claimtracklist', arguments: item);
|
|
},
|
|
child: MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: Card(
|
|
elevation: 5,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(15.0),
|
|
),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(15.0),
|
|
),
|
|
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Expanded(
|
|
flex: 6,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Adjust space between icon and text
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
claimsDepartmentName ?? '',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context)
|
|
? 18
|
|
: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: Color(0xFF000000),
|
|
),
|
|
),
|
|
SizedBox(height: 5),
|
|
Text(
|
|
claimsSubject,
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context)
|
|
? 14
|
|
: 12,
|
|
fontWeight: FontWeight.w400,
|
|
color: Color(0xFF777777),
|
|
), // Ensure text automatically wraps
|
|
),
|
|
],
|
|
))
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 5,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
// Adjust space between icon and text
|
|
Container(
|
|
alignment: Alignment.centerRight,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Container(
|
|
width: 100,
|
|
decoration: BoxDecoration(
|
|
color: statusColor,
|
|
borderRadius: BorderRadius.circular(
|
|
50), // Border radius set to 50
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(5.0),
|
|
child: Text(
|
|
claimStatus,
|
|
textAlign: TextAlign.center,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context)
|
|
? 12
|
|
: 10,
|
|
fontWeight: FontWeight.w400,
|
|
color: Colors
|
|
.white, // Text color against the background
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 5),
|
|
Text(
|
|
formatDateWithTime(claimsDate),
|
|
textAlign: TextAlign.right,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context)
|
|
? 14
|
|
: 12,
|
|
fontWeight: FontWeight.w400,
|
|
color: Color(0xFF777777),
|
|
), // Ensure text automatically wraps
|
|
),
|
|
],
|
|
))
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 1,
|
|
child: Container(
|
|
alignment: Alignment.centerRight,
|
|
child: Icon(
|
|
Icons.chevron_right,
|
|
color: Color(0xFFE26728),
|
|
size: Responsive.isDesktop(context) ? 30 : 26,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
];
|
|
}
|
|
|
|
String formatDateWithTime(String timestamp) {
|
|
// Convert the timestamp string to milliseconds
|
|
int milliseconds = int.parse(timestamp) * 1000;
|
|
|
|
// Create a DateTime object from milliseconds
|
|
DateTime date = DateTime.fromMillisecondsSinceEpoch(milliseconds);
|
|
|
|
// Format the DateTime object with date and time
|
|
String formattedDate = DateFormat('d MMM, y HH:mm a').format(date);
|
|
|
|
return formattedDate;
|
|
}
|
|
}
|