|
|
|
|
@ -129,16 +129,14 @@ class _SiteRequestHistoryScreenState extends State<SiteRequestHistoryScreen> {
|
|
|
|
|
|
|
|
|
|
return RefreshIndicator(
|
|
|
|
|
onRefresh: _refreshData,
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
separatorBuilder: (context, index) => 12.height,
|
|
|
|
|
controller: _scrollController,
|
|
|
|
|
padding: EdgeInsets.all(16.toScreenWidth),
|
|
|
|
|
itemCount: _provider.requestHistory.length + (_provider.isLoadingMore ? 1 : 0),
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
if (index == _provider.requestHistory.length) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 16.toScreenHeight),
|
|
|
|
|
child: const Center(child: CircularProgressIndicator()),
|
|
|
|
|
);
|
|
|
|
|
return const Center(child: CircularProgressIndicator());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _buildRequestCard(_provider.requestHistory[index]);
|
|
|
|
|
@ -153,22 +151,18 @@ class _SiteRequestHistoryScreenState extends State<SiteRequestHistoryScreen> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
_buildRequestHeader(request),
|
|
|
|
|
InfoHeaderWidget("Site Request #${request.id ?? 'N/A'}"),
|
|
|
|
|
InfoHeaderWidget("Request No: ${request.requestNumber ?? '-'}"),
|
|
|
|
|
_buildUserInfo(request),
|
|
|
|
|
// Show old sites if present (for Change Site requests)
|
|
|
|
|
if (request.oldSiteNames != null && request.oldSiteNames!.isNotEmpty)
|
|
|
|
|
_buildOldSitesSection(request),
|
|
|
|
|
if (request.oldSiteNames != null && request.oldSiteNames!.isNotEmpty) _buildOldSitesSection(request),
|
|
|
|
|
// Show new/current sites only if they are not empty and not all null
|
|
|
|
|
if (_hasValidSiteNames(request.siteNames))
|
|
|
|
|
_buildSitesSection(request),
|
|
|
|
|
if (_hasValidSiteNames(request.siteNames)) _buildSitesSection(request),
|
|
|
|
|
// Show old departments if present (for Change Site requests)
|
|
|
|
|
if (request.oldDepartmentNames != null && request.oldDepartmentNames!.isNotEmpty)
|
|
|
|
|
_buildOldDepartmentsSection(request),
|
|
|
|
|
if (request.oldDepartmentNames != null && request.oldDepartmentNames!.isNotEmpty) _buildOldDepartmentsSection(request),
|
|
|
|
|
// Show new departments only if they are not empty and not all null
|
|
|
|
|
if (_hasValidDepartmentNames(request.departmentNames))
|
|
|
|
|
_buildDepartmentsSection(request),
|
|
|
|
|
if (_hasValidDepartmentNames(request.departmentNames)) _buildDepartmentsSection(request),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context).paddingOnly(bottom: 16);
|
|
|
|
|
).toShadowContainer(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Helper method to check if site names list has valid (non-null, non-empty) values
|
|
|
|
|
@ -178,9 +172,7 @@ class _SiteRequestHistoryScreenState extends State<SiteRequestHistoryScreen> {
|
|
|
|
|
|
|
|
|
|
// Helper method to check if department names list has valid (non-null, non-empty) values
|
|
|
|
|
bool _hasValidDepartmentNames(List<String>? departmentNames) {
|
|
|
|
|
return departmentNames != null &&
|
|
|
|
|
departmentNames.isNotEmpty &&
|
|
|
|
|
departmentNames.any((name) => name.isNotEmpty);
|
|
|
|
|
return departmentNames != null && departmentNames.isNotEmpty && departmentNames.any((name) => name.isNotEmpty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildRequestHeader(SiteRequestModel request) {
|
|
|
|
|
@ -212,7 +204,9 @@ class _SiteRequestHistoryScreenState extends State<SiteRequestHistoryScreen> {
|
|
|
|
|
InfoTextWidget(label: "Employee ID", value: request.employeeId),
|
|
|
|
|
InfoTextWidget(label: "Email", value: request.emailAddress),
|
|
|
|
|
InfoTextWidget(label: "Mobile", value: request.mobileNumber, showEmptyValue: true),
|
|
|
|
|
if (request.extensionNumber != null && request.extensionNumber!.isNotEmpty) InfoTextWidget(label: "Extension", value: request.extensionNumber!, showEmptyValue: true),
|
|
|
|
|
if (request.extensionNumber != null && request.extensionNumber!.isNotEmpty) ...[
|
|
|
|
|
InfoTextWidget(label: "Extension", value: request.extensionNumber!, showEmptyValue: true),
|
|
|
|
|
],
|
|
|
|
|
InfoTextWidget(label: "Role", value: request.role),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
@ -222,13 +216,8 @@ class _SiteRequestHistoryScreenState extends State<SiteRequestHistoryScreen> {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
"Old Sites:",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: AppColor.labelTextStyleColor(context),
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
InfoTextLabelWidget(
|
|
|
|
|
label: "Old Sites:",
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
Wrap(
|
|
|
|
|
@ -242,9 +231,7 @@ class _SiteRequestHistoryScreenState extends State<SiteRequestHistoryScreen> {
|
|
|
|
|
|
|
|
|
|
Widget _buildSitesSection(SiteRequestModel request) {
|
|
|
|
|
// Determine label based on whether old sites exist
|
|
|
|
|
final label = (request.oldSiteNames != null && request.oldSiteNames!.isNotEmpty)
|
|
|
|
|
? "New Sites:"
|
|
|
|
|
: "Sites:";
|
|
|
|
|
final label = (request.oldSiteNames != null && request.oldSiteNames!.isNotEmpty) ? "New Sites:" : "Sites:";
|
|
|
|
|
|
|
|
|
|
// Filter out null or empty site names
|
|
|
|
|
final validSiteNames = request.siteNames.where((site) => site.isNotEmpty).toList();
|
|
|
|
|
@ -252,13 +239,8 @@ class _SiteRequestHistoryScreenState extends State<SiteRequestHistoryScreen> {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
label,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: AppColor.labelTextStyleColor(context),
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
InfoTextLabelWidget(
|
|
|
|
|
label: label,
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
Wrap(
|
|
|
|
|
@ -267,7 +249,7 @@ class _SiteRequestHistoryScreenState extends State<SiteRequestHistoryScreen> {
|
|
|
|
|
children: validSiteNames.map((site) => _buildChip(site)).toList(),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(bottom: 8);
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildOldDepartmentsSection(SiteRequestModel request) {
|
|
|
|
|
@ -294,9 +276,7 @@ class _SiteRequestHistoryScreenState extends State<SiteRequestHistoryScreen> {
|
|
|
|
|
|
|
|
|
|
Widget _buildDepartmentsSection(SiteRequestModel request) {
|
|
|
|
|
// Determine label based on whether old departments exist
|
|
|
|
|
final label = (request.oldDepartmentNames != null && request.oldDepartmentNames!.isNotEmpty)
|
|
|
|
|
? "New Departments:"
|
|
|
|
|
: "Departments:";
|
|
|
|
|
final label = (request.oldDepartmentNames != null && request.oldDepartmentNames!.isNotEmpty) ? "New Departments:" : "Departments:";
|
|
|
|
|
|
|
|
|
|
// Filter out null or empty department names
|
|
|
|
|
final validDepartmentNames = request.departmentNames!.where((dept) => dept.isNotEmpty).toList();
|
|
|
|
|
@ -324,20 +304,14 @@ class _SiteRequestHistoryScreenState extends State<SiteRequestHistoryScreen> {
|
|
|
|
|
|
|
|
|
|
Widget _buildChip(String label, {bool isOld = false}) {
|
|
|
|
|
return Chip(
|
|
|
|
|
backgroundColor: isOld
|
|
|
|
|
? AppColor.redStatusColor.withValues(alpha: 0.1)
|
|
|
|
|
: AppColor.backgroundTabBarColor(context),
|
|
|
|
|
backgroundColor: isOld ? AppColor.redStatusColor.withValues(alpha: 0.1) : AppColor.backgroundTabBarColor(context),
|
|
|
|
|
side: BorderSide(
|
|
|
|
|
color: isOld
|
|
|
|
|
? AppColor.redStatusColor.withValues(alpha: 0.3)
|
|
|
|
|
: AppColor.border2Color(context),
|
|
|
|
|
color: isOld ? AppColor.redStatusColor.withValues(alpha: 0.3) : AppColor.border2Color(context),
|
|
|
|
|
),
|
|
|
|
|
label: Text(label),
|
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
|
|
|
|
|
labelStyle: AppTextStyles.tinyFont2.copyWith(
|
|
|
|
|
color: isOld
|
|
|
|
|
? AppColor.redStatusTextColor
|
|
|
|
|
: AppColor.labelTextStyleColor(context),
|
|
|
|
|
color: isOld ? AppColor.redStatusTextColor : AppColor.labelTextStyleColor(context),
|
|
|
|
|
),
|
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 8.toScreenWidth, vertical: 4.toScreenHeight),
|
|
|
|
|
|