|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/all_requests_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/comments_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/enums/user_types.dart';
|
|
|
|
|
import 'package:test_sa/models/service_request/service_request.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/components/action_button/footer_action_button.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/components/initial_visit_card.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/components/timer_widget.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/forms/asset_retired/asset_retired.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/forms/asset_retired/verify_asset_detail.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/forms/maintenance_request/maintenance_request_main.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/nurse/create_new_request_view.dart';
|
|
|
|
|
import 'package:test_sa/views/pages/user/requests/comments_bottom_sheet.dart';
|
|
|
|
|
import 'package:test_sa/views/pages/user/requests/update_service_request_page.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/images/files_list.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/sound/sound_player.dart';
|
|
|
|
|
|
|
|
|
|
import '../forms/spare_part/spare_part_request.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RequestDetailView extends StatefulWidget {
|
|
|
|
|
static const String id = "/call-details";
|
|
|
|
|
ServiceRequest serviceRequest;
|
|
|
|
|
bool fromTabView = false;
|
|
|
|
|
|
|
|
|
|
RequestDetailView({Key? key,required this.serviceRequest, this.fromTabView = false}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<RequestDetailView> createState() => _RequestDetailViewState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _RequestDetailViewState extends State<RequestDetailView> {
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
getServiceRequest(requestId: widget.serviceRequest.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getServiceRequest({@required dynamic requestId}) {
|
|
|
|
|
// setState(() {});
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized().addPostFrameCallback((timeStamp) async {
|
|
|
|
|
Provider.of<CommentsProvider>(context, listen: false).reset();
|
|
|
|
|
ServiceRequestsProvider serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context, listen: false);
|
|
|
|
|
serviceRequestsProvider.currentSelectedRequest = await serviceRequestsProvider.getServiceRequestObjectById(requestId: requestId);
|
|
|
|
|
// setState(() {});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
UserProvider _userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
|
|
|
|
|
|
return !widget.fromTabView
|
|
|
|
|
? Scaffold(
|
|
|
|
|
appBar: DefaultAppBar(title: context.translation.serviceDetails),
|
|
|
|
|
body: Padding(
|
|
|
|
|
padding: EdgeInsets.only(top: 12.toScreenHeight),
|
|
|
|
|
child: Consumer<ServiceRequestsProvider>(builder: (context, serviceRequestsProvider, child) {
|
|
|
|
|
return requestDetailCard(serviceRequestsProvider: serviceRequestsProvider, userProvider: _userProvider);
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: Consumer<ServiceRequestsProvider>(builder: (context, serviceRequestsProvider, child) {
|
|
|
|
|
return requestDetailCard(serviceRequestsProvider: serviceRequestsProvider, userProvider: _userProvider);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget requestDetailCard({required ServiceRequestsProvider serviceRequestsProvider, required UserProvider userProvider}) {
|
|
|
|
|
|
|
|
|
|
return SafeArea(
|
|
|
|
|
child: serviceRequestsProvider.isDetialLoading
|
|
|
|
|
? const ALoading().center
|
|
|
|
|
: serviceRequestsProvider.currentSelectedRequest == null
|
|
|
|
|
? Text(
|
|
|
|
|
context.translation.noDataFound,
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
).center
|
|
|
|
|
: Stack(
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
informationCard(serviceRequestsProvider.currentSelectedRequest!, userProvider),
|
|
|
|
|
|
|
|
|
|
40.height,
|
|
|
|
|
// skipForLater(serviceRequestsProvider.currentSelectedRequest),
|
|
|
|
|
// 20.height,
|
|
|
|
|
const InitialVisitCard(),
|
|
|
|
|
20.height,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
FooterActionButton.requestDetailsFooterWidget(status: 7, context: context),
|
|
|
|
|
TimerWidget(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget informationCard(ServiceRequest serviceRequest, UserProvider userProvider) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: serviceRequest.priority?.name,
|
|
|
|
|
id: serviceRequest.priority!.id!,
|
|
|
|
|
radius: 4,
|
|
|
|
|
textColor: AppColor.getPriorityStatusTextColor(context, serviceRequest.priority!.id!),
|
|
|
|
|
backgroundColor: AppColor.getPriorityStatusColor(context, serviceRequest.priority!.id!),
|
|
|
|
|
),
|
|
|
|
|
8.width,
|
|
|
|
|
StatusLabel(
|
|
|
|
|
radius: 4,
|
|
|
|
|
label: serviceRequest.statusLabel,
|
|
|
|
|
textColor: AppColor.getRequestStatusTextColor(context, serviceRequest.statusValue!),
|
|
|
|
|
backgroundColor: AppColor.getRequestStatusColor(context, serviceRequest.statusValue!),
|
|
|
|
|
),
|
|
|
|
|
1.width.expanded,
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
if (userProvider.user!.type == UsersTypes.normal_user)
|
|
|
|
|
context.translation.code.toSvgAsset(width: 48).onPress(() {
|
|
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (context) => UpdateServiceRequestPage(serviceRequest: serviceRequest)));
|
|
|
|
|
}),
|
|
|
|
|
if (userProvider.user!.type == UsersTypes.engineer) 16.height,
|
|
|
|
|
Text(
|
|
|
|
|
serviceRequest.date!.toServiceRequestCardFormat,
|
|
|
|
|
textAlign: TextAlign.end,
|
|
|
|
|
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
context.translation.assetDetails,
|
|
|
|
|
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
'${context.translation.assetName}: ${serviceRequest.deviceEnName?.cleanupWhitespace?.capitalizeFirstOfEach}'.bodyText(context),
|
|
|
|
|
// 8.height,
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.assetNumber}: ${serviceRequest.device?.assetNumber}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.equipmentStatus}: ${serviceRequest.defectType?.name}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.manufacture}: ${serviceRequest.device?.modelDefinition?.manufacturerName?.cleanupWhitespace?.capitalizeFirstOfEach}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.model}: ${serviceRequest.device?.modelDefinition?.modelName?.cleanupWhitespace?.capitalizeFirstOfEach}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.site}: ${serviceRequest.device?.site?.custName?.cleanupWhitespace?.capitalizeFirstOfEach}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.building}: ${serviceRequest.device?.building?.name?.cleanupWhitespace?.capitalizeFirstOfEach}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.floor}: ${serviceRequest.device?.floor?.name?.cleanupWhitespace?.capitalizeFirstOfEach ?? ""}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.department}: ${serviceRequest.device?.department?.departmentName?.cleanupWhitespace?.capitalizeFirstOfEach}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.room}: ${(serviceRequest.device?.room?.name ?? "").cleanupWhitespace?.capitalizeFirstOfEach}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
|
|
|
|
|
//... request details starts here....
|
|
|
|
|
Text(
|
|
|
|
|
context.translation.requestDetail,
|
|
|
|
|
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.requestType}: ${serviceRequest.type?.name}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.requestNo}: ${serviceRequest.requestCode}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.requesterName}: ${serviceRequest.callCreatedBy?.name ?? "-"}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
8.height,
|
|
|
|
|
if ((serviceRequest.callComments ?? "").isNotEmpty) ...[
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
8.height,
|
|
|
|
|
Text(
|
|
|
|
|
serviceRequest.callComments!,
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
if (serviceRequest.devicePhotos?.isNotEmpty ?? false) ...[
|
|
|
|
|
8.height,
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
FilesList(images: serviceRequest.devicePhotos!),
|
|
|
|
|
],
|
|
|
|
|
if (serviceRequest.audio?.isNotEmpty ?? false) ...[
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
16.height,
|
|
|
|
|
ASoundPlayer(audio: serviceRequest.audio!),
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(start: 16, end: 16, top: 16, bottom: 8),
|
|
|
|
|
(userProvider.user!.type == UsersTypes.normal_user
|
|
|
|
|
? Container(
|
|
|
|
|
height: 50,
|
|
|
|
|
padding: const EdgeInsets.only(left: 16, right: 16),
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
decoration: ShapeDecoration(
|
|
|
|
|
color: context.isDark ? AppColor.neutral50 : AppColor.neutral30,
|
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
|
bottomLeft: Radius.circular(20),
|
|
|
|
|
bottomRight: Radius.circular(20),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.commentHere}...',
|
|
|
|
|
style: AppTextStyles.heading6.copyWith(
|
|
|
|
|
color: (context.isDark ? AppColor.neutral30 : AppColor.neutral50).withOpacity(.6),
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
"comment_send".toSvgAsset(width: 24, color: context.isDark ? AppColor.primary50 : AppColor.primary70),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
16.height,
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
context.translation.viewComments,
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)),
|
|
|
|
|
),
|
|
|
|
|
4.width,
|
|
|
|
|
Icon(Icons.arrow_forward, color: AppColor.blueStatus(context), size: 14)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(bottom: 16, start: 16, end: 16))
|
|
|
|
|
.onPress(() {
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
useSafeArea: true,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
useRootNavigator: true,
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
builder: (context) => CommentsBottomSheet(requestId: serviceRequest.id!),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
//set condition for show asset detail button...
|
|
|
|
|
if (true) ...[
|
|
|
|
|
assetRetiredButton(serviceRequest: serviceRequest),
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context, padding: 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget assetRetiredButton({required ServiceRequest serviceRequest}) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.toScreenHeight, vertical: 12.toScreenWidth),
|
|
|
|
|
child: AppFilledButton(
|
|
|
|
|
label: context.translation.assetToBeRetired,
|
|
|
|
|
maxWidth: true,
|
|
|
|
|
buttonColor: Colors.white54,
|
|
|
|
|
textColor: AppColor.red30,
|
|
|
|
|
showBorder: true,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
// Navigator.push(context, MaterialPageRoute(builder: (context) => AssetRetired()));
|
|
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (context) => const CreateNewRequest()));
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget skipForLater(ServiceRequest serviceRequest) {
|
|
|
|
|
return Center(
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: () async {
|
|
|
|
|
try {
|
|
|
|
|
//use a common list
|
|
|
|
|
AllRequestsProvider allRequestProvider = Provider.of<AllRequestsProvider>(context, listen: false);
|
|
|
|
|
int index = allRequestProvider.requestDetailList!.requestsDetails!.indexWhere((element) => element.id.toString() == serviceRequest.id);
|
|
|
|
|
if (index != -1 && index != allRequestProvider.requestDetailList!.requestsDetails!.length) {
|
|
|
|
|
getServiceRequest(requestId: allRequestProvider.requestDetailList!.requestsDetails![index + 1].id.toString());
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
print(e);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: Text(
|
|
|
|
|
context.translation.skipForLater,
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20, decoration: TextDecoration.underline, fontSize: 16),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|