File Download Info UI_Changes

This commit is contained in:
venbaittech 2025-10-29 16:07:13 +05:30
parent 626b09e3c9
commit e16fec2619
12 changed files with 256 additions and 134 deletions

File diff suppressed because one or more lines are too long

View File

@ -220,9 +220,9 @@ class ApiService {
if (contentType.contains('application/json')) {
final jsonResponse = jsonDecode(response.body);
if (jsonResponse['code'] == 404 || jsonResponse['code'] == 500) {
ToastHelper.showInfoToast(context, 'File Not Found');
ToastHelper.show('File Not Found', Colors.red);
} else {
ToastHelper.showInfoToast(context, 'No File Found');
ToastHelper.show('No File Found', Colors.red);
}
return;
} else {
@ -272,9 +272,9 @@ class ApiService {
} else if (response.statusCode == 403) {
await clearLocalStorageAndRedirect();
} else if (response.statusCode == 500) {
ToastHelper.showInfoToast(context, 'No File Not Found');
ToastHelper.show('No File Found', Colors.red);
} else {
ToastHelper.showInfoToast(context, 'No File Not Found');
ToastHelper.show('No File Found', Colors.red);
throw Exception('Failed to download file');
}
}
@ -813,6 +813,8 @@ class ApiService {
query = 'manager_id=$id';
} else if (role == 'staff') {
query = 'staff_id=$id';
} else if (role == 'handler') {
query = 'handler_id=$id';
} else {
query = 'agent_id=$id';
}
@ -859,13 +861,14 @@ class ApiService {
if (role == 'manager') {
url = Uri.parse('${Env.apiUrl}claim/ClaimList?manager_id=$id');
}
// else if (role == 'staff') {
// url = Uri.parse('${Env.apiUrl}enquiry/enquiryList?staff_id=$id');
// }
else {
} else if (role == 'agent') {
url = Uri.parse('${Env.apiUrl}claim/ClaimList?agent_id=$id');
} else if (role == 'handler') {
url = Uri.parse('${Env.apiUrl}claim/ClaimList?handler_id=$id');
} else {
url = Uri.parse('${Env.apiUrl}claim/ClaimList?staff_id=$id');
}
// final url = Uri.parse(
// 'https://venbait.in/nhance/partner/dev/api/agent/agentList?manager_id=${managerId}',
// );
@ -907,12 +910,12 @@ class ApiService {
url = Uri.parse(
'${Env.apiUrl}endorsement/endorsementList?manager_id=$id',
);
}
// else if (role == 'staff') {
// url = Uri.parse('${Env.apiUrl}enquiry/enquiryList?staff_id=$id');
// }
else {
} else if (role == 'agent') {
url = Uri.parse('${Env.apiUrl}endorsement/endorsementList?agent_id=$id');
} else if (role == 'handler') {
url = Uri.parse('${Env.apiUrl}enquiry/enquiryList?handler_id=$id');
} else {
url = Uri.parse('${Env.apiUrl}endorsement/endorsementList?staff_id=$id');
}
// final url = Uri.parse(
// 'https://venbait.in/nhance/partner/dev/api/agent/agentList?manager_id=${managerId}',

View File

@ -1,6 +1,9 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
// import 'package:fluttertoast/fluttertoast.dart';
import 'package:toastification/toastification.dart';
import 'package:universal_html/html.dart' as html;
class ToastHelper {
static void showSuccessToast(BuildContext context, String message) {
@ -17,10 +20,7 @@ class ToastHelper {
direction: TextDirection.ltr,
animationDuration: const Duration(milliseconds: 100),
animationBuilder: (context, animation, alignment, child) {
return FadeTransition(
opacity: animation,
child: child,
);
return FadeTransition(opacity: animation, child: child);
},
icon: const Icon(Icons.check),
primaryColor: Colors.green,
@ -35,7 +35,7 @@ class ToastHelper {
blurRadius: 16,
offset: Offset(0, 16),
spreadRadius: 0,
)
),
],
showProgressBar: true,
closeButtonShowType: CloseButtonShowType.onHover,
@ -68,10 +68,7 @@ class ToastHelper {
direction: TextDirection.ltr,
animationDuration: const Duration(milliseconds: 100),
animationBuilder: (context, animation, alignment, child) {
return FadeTransition(
opacity: animation,
child: child,
);
return FadeTransition(opacity: animation, child: child);
},
icon: const Icon(Icons.warning),
primaryColor: Colors.amberAccent,
@ -86,7 +83,7 @@ class ToastHelper {
blurRadius: 16,
offset: Offset(0, 16),
spreadRadius: 0,
)
),
],
showProgressBar: true,
closeButtonShowType: CloseButtonShowType.onHover,
@ -119,10 +116,7 @@ class ToastHelper {
direction: TextDirection.ltr,
animationDuration: const Duration(milliseconds: 100),
animationBuilder: (context, animation, alignment, child) {
return FadeTransition(
opacity: animation,
child: child,
);
return FadeTransition(opacity: animation, child: child);
},
icon: const Icon(Icons.error),
primaryColor: Colors.redAccent,
@ -137,7 +131,7 @@ class ToastHelper {
blurRadius: 16,
offset: Offset(0, 16),
spreadRadius: 0,
)
),
],
showProgressBar: true,
closeButtonShowType: CloseButtonShowType.onHover,
@ -171,10 +165,7 @@ class ToastHelper {
direction: TextDirection.ltr,
animationDuration: const Duration(milliseconds: 100),
animationBuilder: (context, animation, alignment, child) {
return FadeTransition(
opacity: animation,
child: child,
);
return FadeTransition(opacity: animation, child: child);
},
icon: const Icon(Icons.info),
primaryColor: Colors.lightBlue,
@ -189,7 +180,7 @@ class ToastHelper {
blurRadius: 16,
offset: Offset(0, 16),
spreadRadius: 0,
)
),
],
showProgressBar: true,
closeButtonShowType: CloseButtonShowType.onHover,
@ -209,15 +200,78 @@ class ToastHelper {
// _showToast(context, message, Colors.red);
}
static void _showToast(BuildContext context, String message, Color color) {
// Fluttertoast.showToast(
// msg: message,
// toastLength: Toast.LENGTH_SHORT,
// gravity: ToastGravity.TOP,
// timeInSecForIosWeb: 5,
// backgroundColor: color,
// textColor: Colors.white,
// fontSize: 16.0,
// );
static void show(String message, Color backgroundColor) {
if (kIsWeb) {
_showWebToast(message, backgroundColor);
} else {
Fluttertoast.showToast(
msg: message,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
backgroundColor: backgroundColor,
textColor: Colors.white,
fontSize: 16.0,
);
}
}
static void _showWebToast(String message, Color backgroundColor) {
// Create toast element
final toast = html.DivElement()
..style.position = 'fixed'
..style.top =
'20px' // Top position
..style.right =
'20px' // Left position
..style.backgroundColor = _colorToRgba(backgroundColor)
..style.color = 'white'
..style.padding = '12px 24px'
..style.borderRadius = '8px'
// ..style.borderColor = _colorToRgba(backgroundColor)
..style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.2)'
..style.zIndex = '9999'
..style.fontSize = '12px'
..style.fontFamily = "'Inter', sans-serif"
..style.fontWeight =
'800' // Bold
..style.minWidth = '200px'
..style.maxWidth = '400px'
..style.textAlign = 'left'
..style.transition = 'all 0.3s ease-in-out'
..style.opacity = '0'
..text = message;
// Add to body
html.document.body?.append(toast);
// Fade in animation
Future.delayed(Duration(milliseconds: 10), () {
toast.style.opacity = '1';
});
// Auto remove after 3 seconds
Future.delayed(Duration(milliseconds: 2700), () {
toast.style.opacity = '0';
});
Future.delayed(Duration(seconds: 3), () {
toast.remove();
});
}
static String _colorToRgba(Color color) {
return 'rgba(${color.red}, ${color.green}, ${color.blue}, ${color.opacity})';
}
// static void _showToast(BuildContext context, String message, Color color) {
// Fluttertoast.showToast(
// msg: message,
// toastLength: Toast.LENGTH_SHORT,
// gravity: ToastGravity.TOP,
// timeInSecForIosWeb: 5,
// backgroundColor: color,
// textColor: Colors.white,
// fontSize: 16.0,
// );
// }
}

View File

@ -441,6 +441,7 @@ class PolicyTabState extends ConsumerState<PolicyTab> {
// 'api/agent/downloadAgentIncentiveFile?id=$selectedId';
final path =
'api/policy/downloadPolicyFile?policy_id=$selectedId&file_type=policy_pdf';
apiService.getPdfDownload(path, selectedId);
},
child: Container(

View File

@ -672,20 +672,20 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
children: [
Expanded(flex: 1, child: Text('S.No.', style: _headerStyle)),
Expanded(
flex: 2,
child: Text('Received Date & Time', style: _headerStyle),
flex: 3,
child: Text('Received Date', style: _headerStyle),
),
Expanded(
flex: 2,
flex: 3,
child: Text('Vehicle.No.', style: _headerStyle),
),
Expanded(flex: 3, child: Text('Insurer', style: _headerStyle)),
Expanded(
flex: 2,
flex: 3,
child: Text('Updated Date', style: _headerStyle),
),
Expanded(flex: 2, child: Text('Status', style: _headerStyle)),
Expanded(flex: 3, child: Text('Status', style: _headerStyle)),
Expanded(flex: 2, child: Text('Remarks', style: _headerStyle)),
Expanded(flex: 1, child: Text('Action', style: _headerStyle)),
],
@ -785,7 +785,7 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
children: [
Expanded(flex: 1, child: Text('$sno' ?? '-', style: _dataBold)),
Expanded(
flex: 2,
flex: 3,
child: Text(
_formatDate(item['created_on']) ?? '-',
style: _dataBold,
@ -793,36 +793,43 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
),
Expanded(
flex: 2,
flex: 3,
child: Text(item['reg_no'] ?? '-', style: _dataBold),
),
Expanded(
flex: 3,
child: Text(
item['insurer_name'] ?? '-',
// (item['insurer_name'] ?? '').length > 10
// ? '${item['insurer_name'].substring(0, 10)}...'
// : item['insurer_name'] ?? '',
style: _dataBold,
softWrap: true,
maxLines: 3,
),
),
Expanded(
flex: 2,
flex: 3,
child: Text(
_formatDate(item['updated_on']) ?? '-',
style: _dataBold,
),
),
Expanded(
flex: 2,
flex: 3,
child: Text(item['status'] ?? '-', style: _dataBold),
),
Expanded(
flex: 2,
child: Text(
item['remarks'] ?? '-',
// item['remarks'] ?? '-',
(item['remarks'] ?? '').length > 10
? '${item['remarks'].substring(0, 10)}...'
: item['remarks'] ?? '',
style: _dataBold,
softWrap: true,
maxLines: 3,
// softWrap: true,
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
),

View File

@ -81,28 +81,53 @@ class StaffListState extends ConsumerState<StaffList> {
return sortedData.sublist(startIndex, endIndex);
}
// void filterData(String query) {
// print("FilterDAta - $query");
// setState(() {
// filteredData = getStaffData.where((item) {
// final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive";
//
// return (item['name'] ?? '-').toLowerCase().contains(
// query.toLowerCase(),
// ) ||
// (item['email'] ?? '-').toLowerCase().contains(
// query.toLowerCase(),
// ) ||
// (item['mobile'] ?? '-').toLowerCase().contains(
// query.toLowerCase(),
// ) ||
// (item['address'] ?? '-').toLowerCase().contains(
// query.toLowerCase(),
// ) ||
// (item['emp_id'] ?? item['agent_code'] ?? '-')
// .toLowerCase()
// .contains(query.toLowerCase()) ||
// isActiveStatus.contains(query.toLowerCase());
// }).toList();
// });
// }
void filterData(String query) {
print("FilterDAta - $query");
setState(() {
final q = query.toLowerCase();
if (q.isEmpty) {
filteredData = getStaffData;
return;
}
filteredData = getStaffData.where((item) {
final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive";
return (item['name'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['email'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['mobile'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['address'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['emp_id'] ?? item['agent_code'] ?? '-')
return (item['name'] ?? '').toString().toLowerCase().contains(q) ||
(item['email'] ?? '').toString().toLowerCase().contains(q) ||
(item['mobile'] ?? '').toString().toLowerCase().contains(q) ||
(item['address'] ?? '').toString().toLowerCase().contains(q) ||
(item['emp_id'] ?? item['agent_code'] ?? '')
.toString()
.toLowerCase()
.contains(query.toLowerCase()) ||
isActiveStatus.contains(query.toLowerCase());
.contains(q) ||
isActiveStatus.contains(q);
}).toList();
});
}

View File

@ -150,25 +150,30 @@ class EnquiryHandlerState extends ConsumerState<EnquiryHandler> {
);
}
void refrshfilterDateRange() {
setState(() async {
final prefs = await SharedPreferences.getInstance();
Future<void> refrshfilterDateRange() async {
// setState(() async {
final prefs = await SharedPreferences.getInstance();
// Clear any old data
await prefs.remove('dashboardKeyProvider');
await prefs.remove('dashboardStatusProvider');
await prefs.remove('dashboardStaffIdProvider');
SelectedStatus = '';
SelectedStaffId = null;
controllers['startDate']!.clear();
controllers['endDate']!.clear();
// Clear any old data
await prefs.remove('dashboardKeyProvider');
await prefs.remove('dashboardStatusProvider');
await prefs.remove('dashboardStaffIdProvider');
SelectedStatus = '';
SelectedStaffId = null;
controllers['startDate']!.clear();
controllers['endDate']!.clear();
controllers['startDate']?.text = '';
controllers['endDate']?.text = '';
// Reset the FormField validation
_formKey.currentState?.reset();
});
getStaffList(managerId, roleId);
controllers['startDate']?.text = '';
controllers['endDate']?.text = '';
// Reset the FormField validation
_formKey.currentState?.reset();
// });
getStaffList(
managerId,
roleId,
SelectedStatus: SelectedStatus ?? '',
SelectedStaffId: SelectedStaffId ?? '',
);
}
Future<void> getStaffList(
@ -898,43 +903,43 @@ class EnquiryHandlerState extends ConsumerState<EnquiryHandler> {
children: [
Expanded(
flex: 2,
child: Text('Received Date', style: _headerStyle),
child: Text('Received Date ', style: _headerStyle),
),
Expanded(flex: 2, child: Text('Partner', style: _headerStyle)),
Expanded(flex: 2, child: Text('Partner ', style: _headerStyle)),
Expanded(
flex: 2,
child: Text('Assigned To', style: _headerStyle),
child: Text('Assigned To ', style: _headerStyle),
),
Expanded(flex: 3, child: Text('Insurer', style: _headerStyle)),
Expanded(flex: 3, child: Text('Insurer ', style: _headerStyle)),
Expanded(
flex: 2,
child: Text('Vehicle.No', style: _headerStyle),
),
Expanded(
flex: 2,
// child: Padding(
// padding: EdgeInsets.only(left: 8.0),
child: Text('Insured Name', style: _headerStyle),
// ),
child: Text('Vehicle.No ', style: _headerStyle),
),
// Expanded(
// flex: 2,
// // child: Padding(
// // padding: EdgeInsets.only(left: 8.0),
// child: Text('Insured Name ', style: _headerStyle),
// // ),
// ),
Expanded(
flex: 2,
child: Text('Assigned Date', style: _headerStyle),
child: Text('Assigned Date ', style: _headerStyle),
),
Expanded(flex: 2, child: Text('Premium', style: _headerStyle)),
Expanded(flex: 2, child: Text('Premium ', style: _headerStyle)),
Expanded(
flex: 2,
child: Text('Payment Mode', style: _headerStyle),
child: Text('Payment Mode ', style: _headerStyle),
),
Expanded(
flex: 2,
child: Text('Policy Number', style: _headerStyle),
child: Text('Policy Number ', style: _headerStyle),
),
Expanded(flex: 2, child: Text('Status', style: _headerStyle)),
Expanded(flex: 2, child: Text('Status ', style: _headerStyle)),
Expanded(flex: 1, child: Text('Action', style: _headerStyle)),
],
),
@ -1059,19 +1064,26 @@ class EnquiryHandlerState extends ConsumerState<EnquiryHandler> {
),
Expanded(
flex: 2,
child: Text(item['reg_no'] ?? '-', style: _dataBold),
),
Expanded(
flex: 2,
child: Text(
item['insured_name'] ?? '-',
style: _dataBold,
softWrap: true,
maxLines: 3,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(item['reg_no'] ?? '-', style: _dataBold),
Text(item['insured_name'] ?? '-', style: _dataBoldsmall),
],
),
),
// Expanded(
// flex: 2,
//
// child: Text(
// item['insured_name'] ?? '-',
// style: _dataBold,
// softWrap: true,
// maxLines: 3,
// ),
// ),
Expanded(
flex: 2,
child: Text(
@ -1350,6 +1362,12 @@ class EnquiryHandlerState extends ConsumerState<EnquiryHandler> {
fontWeight: FontWeight.w400,
color: Color(0xFF000000),
);
static final _dataBoldsmall = TextStyle(
fontSize: 12,
fontWeight: FontWeight.w400,
color: Color(0xFF000000),
);
static final _dataSub = TextStyle(
fontSize: 10,

View File

@ -866,8 +866,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
child: const Row(
children: [
Expanded(
flex: 3,
child: Text('Received Date & Time', style: _headerStyle),
flex: 2,
child: Text('Received Date', style: _headerStyle),
),
Expanded(flex: 2, child: Text('Partner ', style: _headerStyle)),
Expanded(
@ -884,8 +884,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
child: Text('Insured Name', style: _headerStyle),
),
Expanded(
flex: 3,
child: Text('Assigned Date & Time', style: _headerStyle),
flex: 2,
child: Text('Assigned Date', style: _headerStyle),
),
Expanded(flex: 3, child: Text('Status', style: _headerStyle)),
],
@ -952,7 +952,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
child: Row(
children: [
Expanded(
flex: 3,
flex: 2,
child: Text(
_formatDate(item['created_on']) ?? '-',
style: _dataBold,
@ -1018,7 +1018,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
position: RelativeRect.fromLTRB(
position.dx,
position.dy + button.size.height,
overlay.size.width - position.dx,
overlay.size.width,
// overlay.size.width - position.dx,
0,
),
items: [
@ -1067,7 +1068,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
),
Expanded(
flex: 3,
flex: 2,
child: Text(
_formatDate(item['updated_on']) ?? '-',
style: _dataBold,
@ -1303,12 +1304,12 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
Widget buildDocRC(BuildContext context, bool isMobile, selectedEnquiryId) {
return GestureDetector(
onTap: () {
// print("Upload $idget.id}{w");
final selectedId = selectedEnquiryId;
// final path =
// 'api/agent/downloadAgentIncentiveFile?id=$selectedId';
final path =
'api/enquiry/downloadEnquiryFile?enquiry_id=$selectedId&file_type=rc';
apiService.getPdfDownload(path, selectedId);
},
child: Container(

View File

@ -1217,12 +1217,16 @@ class PolicyScreenState extends ConsumerState<PolicyScreen> {
).format(date);
// auto set end date (1 year later - 1 day if needed)
// final endDate = DateTime(
// date.year + 1,
// date.month,
// date.day,
// ); // optional: subtract 1 day
final endDate = DateTime(
date.year + 1,
date.month,
date.day,
); // optional: subtract 1 day
).subtract(const Duration(days: 1));
controllers['endDate']?.text = DateFormat(
'dd-MM-yyyy',
).format(endDate);

View File

@ -664,13 +664,13 @@ class policylistState extends ConsumerState<policylist> {
child: Row(
children: [
Expanded(
flex: 4,
child: Text('Recieved Date/Time', style: _headerStyle),
flex: 2,
child: Text('Recieved Date', style: _headerStyle),
),
Expanded(flex: 3, child: Text('Partner', style: _headerStyle)),
Expanded(flex: 2, child: Text('Partner', style: _headerStyle)),
Expanded(
flex: 3,
flex: 2,
child: Text('Assigned To', style: _headerStyle),
),
Expanded(flex: 4, child: Text('Insurer', style: _headerStyle)),
@ -794,7 +794,7 @@ class policylistState extends ConsumerState<policylist> {
child: Row(
children: [
Expanded(
flex: 4,
flex: 2,
child: Text(
_formatDate(item['updated_on']) ?? '-',
style: _dataBold,
@ -804,14 +804,14 @@ class policylistState extends ConsumerState<policylist> {
),
Expanded(
flex: 3,
flex: 2,
child: Text(
_formatDate(item['agent_name']) ?? '-',
style: _dataBold,
),
),
Expanded(
flex: 3,
flex: 2,
child: Text(item['assigned_to_name'] ?? '-', style: _dataBold),
),
Expanded(

View File

@ -504,6 +504,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
fluttertoast:
dependency: "direct main"
description:
name: fluttertoast
sha256: "144ddd74d49c865eba47abe31cbc746c7b311c82d6c32e571fd73c4264b740e2"
url: "https://pub.dev"
source: hosted
version: "9.0.0"
frontend_server_client:
dependency: transitive
description:

View File

@ -68,6 +68,7 @@ dependencies:
excel: ^4.0.6
dropdown_search: ^6.0.2
file_picker: ^10.3.3
fluttertoast: ^9.0.0
dev_dependencies:
flutter_test: