From d5ee12abbb8e8fbe234b2a1c9cbd216657b87ed4 Mon Sep 17 00:00:00 2001 From: "muhammad.abbasi" Date: Tue, 3 Sep 2024 10:24:08 +0300 Subject: [PATCH] flow changed ui improvement according to new design --- lib/l10n/app_ar.arb | 2 + lib/l10n/app_en.arb | 2 + lib/new_views/app_style/app_color.dart | 5 +- .../requests/service_request_item_view.dart | 7 +- .../bottom_sheets/action_bottomsheet.dart | 2 +- .../service_request_bottomsheet.dart | 356 ++++++++-------- .../views/components/history_log_view.dart | 12 +- .../views/components/request_detail_view.dart | 398 ++++++++++++++++++ .../views/request_detail_main_view.dart | 64 +++ .../views/request_detail_view.dart | 396 ----------------- 10 files changed, 660 insertions(+), 584 deletions(-) create mode 100644 lib/service_request_latest/views/components/request_detail_view.dart create mode 100644 lib/service_request_latest/views/request_detail_main_view.dart delete mode 100644 lib/service_request_latest/views/request_detail_view.dart diff --git a/lib/l10n/app_ar.arb b/lib/l10n/app_ar.arb index 673ff6ad..b97076ed 100644 --- a/lib/l10n/app_ar.arb +++ b/lib/l10n/app_ar.arb @@ -8,6 +8,8 @@ "confirm": "تاكيد", "done": "تم", "exit": "إغلاق", + "requestDetails": "تفاصيل الطلب", + "historyLogs": "سجلات التاريخ", "exitAlert": "هل انت متاكد من رغبتك في إغلاق التطبيق؟", "signOut": "تسجيل الخروج", "logoutAlert": "هل انت متاكد من رغبتك في تسجيل الخروج؟", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 882498e7..af57bfe4 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -342,6 +342,8 @@ "askOtpFromRequester" : "Ask OTP From Requester", "checkOutOtherMethods": "Check out other methods.", "otpSentToNumber": "An OTP sent to the number", + "requestDetails": "Request Details", + "historyLogs": "History Logs", "pickTime" : "Pick Time", "readCompleteThread" : "Read Complete thread", "pickADate" : "Pick a date", diff --git a/lib/new_views/app_style/app_color.dart b/lib/new_views/app_style/app_color.dart index 7dccad98..417a7ce1 100644 --- a/lib/new_views/app_style/app_color.dart +++ b/lib/new_views/app_style/app_color.dart @@ -24,6 +24,8 @@ class AppColor { static const Color neutral80 = Color(0xffF3F3F3); static const Color neutral90 = Color(0xffF7F9FB); static const Color neutral100 = Color(0xffF4F6FC); + static const Color neutral110 = Color(0xffF3F5FB); + static const Color neutral120 = Color(0xff7D859A); //background @@ -37,7 +39,8 @@ class AppColor { static const Color white40 = Color(0xffE4EBEE); //black - static const Color balck10 = Color(0xff3B3D4A); + static const Color black10 = Color(0xff3B3D4A); + static const Color black20 = Color(0xff212936); //red static const Color red30 = Color(0xffF63939); diff --git a/lib/new_views/pages/land_page/requests/service_request_item_view.dart b/lib/new_views/pages/land_page/requests/service_request_item_view.dart index 3fe215b4..d48d0c66 100644 --- a/lib/new_views/pages/land_page/requests/service_request_item_view.dart +++ b/lib/new_views/pages/land_page/requests/service_request_item_view.dart @@ -7,7 +7,8 @@ import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/all_requests_and_count_model.dart'; import 'package:test_sa/models/service_request/service_request.dart'; -import 'package:test_sa/service_request_latest/views/request_detail_view.dart'; +import 'package:test_sa/service_request_latest/views/components/request_detail_view.dart'; +import 'package:test_sa/service_request_latest/views/request_detail_main_view.dart'; import '../../../../views/widgets/requests/request_status.dart'; import '../../../app_style/app_color.dart'; @@ -71,8 +72,8 @@ class ServiceRequestItemView extends StatelessWidget { //Older code... Navigator.of(context).push(MaterialPageRoute( - builder: (_) => ServiceRequestDetailView( - serviceRequest: ServiceRequest(id: request.id.toString()), + builder: (_) => RequestDetailMain( + requestId:request.id, ))); // Navigator.of(context).push(MaterialPageRoute( // builder: (_) => const HistoryLogView())); diff --git a/lib/service_request_latest/views/components/bottom_sheets/action_bottomsheet.dart b/lib/service_request_latest/views/components/bottom_sheets/action_bottomsheet.dart index ffb56002..e7c1e563 100644 --- a/lib/service_request_latest/views/components/bottom_sheets/action_bottomsheet.dart +++ b/lib/service_request_latest/views/components/bottom_sheets/action_bottomsheet.dart @@ -59,7 +59,7 @@ class ActionBottomSheet extends StatelessWidget { label: button1Text ?? context.translation.no, loading: false, buttonColor: AppColor.neutral40, - textColor: AppColor.balck10, + textColor: AppColor.black10, onPressed: button1Tap ?? () async { Navigator.pop(context); diff --git a/lib/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart b/lib/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart index cb6ad769..5a17b604 100644 --- a/lib/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart +++ b/lib/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart @@ -247,188 +247,185 @@ class ServiceRequestBottomSheet { child: Form( key: _formKey, child: SingleChildScrollView( - child: StatefulBuilder( - builder: (context, setState) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Center( - child: Container( - width: 40.toScreenWidth, - height: 5.toScreenHeight, - decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)), - ), - ), - Align( - alignment: AlignmentDirectional.centerStart, - child: context.translation.fillDetails.heading5(context).custom(fontWeight: FontWeight.w500).paddingOnly(top: 16, bottom: 16), + child: StatefulBuilder(builder: (context, setState) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Center( + child: Container( + width: 40.toScreenWidth, + height: 5.toScreenHeight, + decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)), ), - 8.height, - ADatePicker( - label: context.translation.date, - hideShadow: true, - height: 80.toScreenHeight, - backgroundColor: AppColor.neutral90, - date: DateTime.tryParse(serviceRequestProvider.currentSelectedRequest.startDate ?? ""), - formatDateWithTime: true, - onDatePicker: (selectedDate) { - if (selectedDate != null) { - showTimePicker( - context: context, - initialTime: TimeOfDay.now(), - ).then((selectedTime) { - // Handle the selected date and time here. - if (selectedTime != null) { - DateTime selectedDateTime = DateTime( - selectedDate.year, - selectedDate.month, - selectedDate.day, - selectedTime.hour, - selectedTime.minute, - ); - if (selectedDateTime != null) { - if (selectedDateTime.isBefore(DateTime.parse(serviceRequestProvider.currentSelectedRequest.date))) { - "Visit Date time must be greater then request date".showToast; - return; - } + ), + Align( + alignment: AlignmentDirectional.centerStart, + child: context.translation.fillDetails.heading5(context).custom(fontWeight: FontWeight.w500).paddingOnly(top: 16, bottom: 16), + ), + 8.height, + ADatePicker( + label: context.translation.date, + hideShadow: true, + height: 80.toScreenHeight, + backgroundColor: AppColor.neutral90, + date: DateTime.tryParse(serviceRequestProvider.currentSelectedRequest.startDate ?? ""), + formatDateWithTime: true, + onDatePicker: (selectedDate) { + if (selectedDate != null) { + showTimePicker( + context: context, + initialTime: TimeOfDay.now(), + ).then((selectedTime) { + // Handle the selected date and time here. + if (selectedTime != null) { + DateTime selectedDateTime = DateTime( + selectedDate.year, + selectedDate.month, + selectedDate.day, + selectedTime.hour, + selectedTime.minute, + ); + if (selectedDateTime != null) { + if (selectedDateTime.isBefore(DateTime.parse(serviceRequestProvider.currentSelectedRequest.date))) { + "Visit Date time must be greater then request date".showToast; + return; + } - setState(() { + setState(() { serviceRequestProvider.currentSelectedRequest.startDate = selectedDateTime?.toIso8601String(); - }); - print('start date i got is ${serviceRequestProvider.currentSelectedRequest.startDate}'); - } + }); + print('start date i got is ${serviceRequestProvider.currentSelectedRequest.startDate}'); } - }); - } - }, - ), + } + }); + } + }, + ), - // ATimePicker( - // label: context.translation.startTime, - // height: 80.toScreenHeight, - // backgroundColor: AppColor.neutral90, - // hint: context.translation.pickTime, - // time: serviceRequestProvider.selectedTime, - // onTimePicker: (selectedTime) { - // //TODO handle selected time here. - // if (selectedTime != null) { - // // setState(() { - // serviceRequestProvider.selectedTime = selectedTime; - // // }); - // // DateTime selectedDateTime = DateTime( - // // selectedDate.year, - // // selectedDate.month, - // // selectedDate.day, - // // selectedTime.hour, - // // selectedTime.minute, - // // ); - // // if (selectedDateTime != null) { - // // if (selectedDateTime.isBefore(DateTime.parse(serviceRequestProvider.serviceRequest.date))) { - // // "Visit Date time must be greater then request date".showToast; - // // return; - // // } - // // - // - // // } - // } - // }, - // ), - // 8.height, - // ATimePicker( - // label: context.translation.endTime, - // height: 80.toScreenHeight, - // backgroundColor: AppColor.neutral90, - // hint: context.translation.pickTime, - // time: serviceRequestProvider.selectedTime, - // onTimePicker: (selectedTime) { - // //TODO handle selected time here. - // if (selectedTime != null) { - // // setState(() { - // serviceRequestProvider.selectedTime = selectedTime; - // // }); - // } - // }, - // ), - 8.height, - SizedBox( - width: double.infinity, - height: 80.toScreenHeight, - // padding: EdgeInsets.symmetric(horizontal: 20.toScreenWidth, vertical: 10.toScreenHeight), - child: - AppTimer( - label: context.translation.workingHours, - timer: TimerModel(), - decoration: BoxDecoration( - color: context.isDark ? AppColor.neutral20 : AppColor.neutral90, - borderRadius: BorderRadius.circular(10), - // boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], - ), - // enabled: serviceRequestProvider.currentSelectedRequest.date == null, - enabled: true, - onChange: (timer) async { - print('timer i got is ${timer.toString()}'); - return true; - }, + // ATimePicker( + // label: context.translation.startTime, + // height: 80.toScreenHeight, + // backgroundColor: AppColor.neutral90, + // hint: context.translation.pickTime, + // time: serviceRequestProvider.selectedTime, + // onTimePicker: (selectedTime) { + // //TODO handle selected time here. + // if (selectedTime != null) { + // // setState(() { + // serviceRequestProvider.selectedTime = selectedTime; + // // }); + // // DateTime selectedDateTime = DateTime( + // // selectedDate.year, + // // selectedDate.month, + // // selectedDate.day, + // // selectedTime.hour, + // // selectedTime.minute, + // // ); + // // if (selectedDateTime != null) { + // // if (selectedDateTime.isBefore(DateTime.parse(serviceRequestProvider.serviceRequest.date))) { + // // "Visit Date time must be greater then request date".showToast; + // // return; + // // } + // // + // + // // } + // } + // }, + // ), + // 8.height, + // ATimePicker( + // label: context.translation.endTime, + // height: 80.toScreenHeight, + // backgroundColor: AppColor.neutral90, + // hint: context.translation.pickTime, + // time: serviceRequestProvider.selectedTime, + // onTimePicker: (selectedTime) { + // //TODO handle selected time here. + // if (selectedTime != null) { + // // setState(() { + // serviceRequestProvider.selectedTime = selectedTime; + // // }); + // } + // }, + // ), + 8.height, + SizedBox( + width: double.infinity, + height: 80.toScreenHeight, + // padding: EdgeInsets.symmetric(horizontal: 20.toScreenWidth, vertical: 10.toScreenHeight), + child: AppTimer( + label: context.translation.workingHours, + timer: TimerModel(), + decoration: BoxDecoration( + color: context.isDark ? AppColor.neutral20 : AppColor.neutral90, + borderRadius: BorderRadius.circular(10), + // boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], ), - // Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // mainAxisAlignment: MainAxisAlignment.start, - // children: [ - // context.translation.workingHours.bodyText2(context), - // //TODo calculate the hours and write here. - // 'No of hours'.bodyText(context).custom(color: AppColor.balck10), - // ], - // ), - ), - 8.height, - AppTextFormField( - labelText: context.translation.comments, - textInputType: TextInputType.multiline, - showWithoutDecoration: true, - backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, - alignLabelWithHint: true, - onChange: (text) { - serviceRequestProvider.currentSelectedRequest.comments = text; - }, - onSaved: (text) { - serviceRequestProvider.currentSelectedRequest.comments = text; + // enabled: serviceRequestProvider.currentSelectedRequest.date == null, + enabled: true, + onChange: (timer) async { + print('timer i got is ${timer.toString()}'); + return true; }, ), - 16.height, - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SizedBox( - width: 200.toScreenHeight, - child: AppFilledButton( - label: context.translation.cancel, - loading: false, - buttonColor: Colors.transparent, - showBorder: true, - textColor: AppColor.balck10, - onPressed: () async { - Navigator.pop(context); - // await snapshot.updateRequest(user: userProvider.user, request: serviceRequestProvider.serviceRequest); - // Navigator.pop(context, true); - }, - ), + // Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // context.translation.workingHours.bodyText2(context), + // //TODo calculate the hours and write here. + // 'No of hours'.bodyText(context).custom(color: AppColor.balck10), + // ], + // ), + ), + 8.height, + AppTextFormField( + labelText: context.translation.comments, + textInputType: TextInputType.multiline, + showWithoutDecoration: true, + backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, + alignLabelWithHint: true, + onChange: (text) { + serviceRequestProvider.currentSelectedRequest.comments = text; + }, + onSaved: (text) { + serviceRequestProvider.currentSelectedRequest.comments = text; + }, + ), + 16.height, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + SizedBox( + width: 200.toScreenHeight, + child: AppFilledButton( + label: context.translation.cancel, + loading: false, + buttonColor: Colors.transparent, + showBorder: true, + textColor: AppColor.black10, + onPressed: () async { + Navigator.pop(context); + // await snapshot.updateRequest(user: userProvider.user, request: serviceRequestProvider.serviceRequest); + // Navigator.pop(context, true); + }, ), - SizedBox( - width: 200.toScreenHeight, - child: AppFilledButton( - label: context.translation.fixed, - buttonColor: AppColor.green70, - loading: false, - onPressed: () {}, - ), + ), + SizedBox( + width: 200.toScreenHeight, + child: AppFilledButton( + label: context.translation.fixed, + buttonColor: AppColor.green70, + loading: false, + onPressed: () {}, ), - ], - ), - 16.height, - ], - ); - } - ), + ), + ], + ), + 16.height, + ], + ); + }), ), ), ); @@ -553,12 +550,13 @@ class ServiceRequestBottomSheet { ); if (selectedDateTime != null) { serviceRequestProvider.currentSelectedRequest.endDate = selectedDateTime?.toIso8601String(); - serviceRequestProvider.currentSelectedRequest.workingHours = - (((DateTime.parse(serviceRequestProvider.currentSelectedRequest.endDate).difference(DateTime.parse(serviceRequestProvider.currentSelectedRequest.startDate)).inSeconds ?? - 0) / - 60) / - 60) - .toStringAsFixed(2); + serviceRequestProvider.currentSelectedRequest.workingHours = (((DateTime.parse(serviceRequestProvider.currentSelectedRequest.endDate) + .difference(DateTime.parse(serviceRequestProvider.currentSelectedRequest.startDate)) + .inSeconds ?? + 0) / + 60) / + 60) + .toStringAsFixed(2); } } }); @@ -832,7 +830,7 @@ class ServiceRequestBottomSheet { label: button1Text ?? context.translation.no, loading: false, buttonColor: AppColor.neutral40, - textColor: AppColor.balck10, + textColor: AppColor.black10, onPressed: button1Tap ?? () async { Navigator.pop(context); diff --git a/lib/service_request_latest/views/components/history_log_view.dart b/lib/service_request_latest/views/components/history_log_view.dart index d1e4633a..0e92e25f 100644 --- a/lib/service_request_latest/views/components/history_log_view.dart +++ b/lib/service_request_latest/views/components/history_log_view.dart @@ -27,7 +27,11 @@ class HistoryLogView extends StatelessWidget { return Scaffold( backgroundColor: AppColor.neutral100, body: Padding( - padding: EdgeInsets.only(top: 50.toScreenHeight, bottom: 20.toScreenHeight), + padding: EdgeInsets.only( + left: 16.toScreenWidth, + right: 16.toScreenWidth, + bottom: 12.toScreenHeight, + ), child: Stack( children: [ Padding( @@ -46,7 +50,7 @@ class HistoryLogView extends StatelessWidget { // ), ListView.builder( itemCount: dummyList.length, - padding: EdgeInsets.all(16), + padding: EdgeInsets.zero, itemBuilder: (context, index) { return historyLogCard(context: context, historyLogModel: dummyList[index]); }, @@ -84,11 +88,11 @@ class HistoryLogView extends StatelessWidget { Text( historyLogModel.date.toString().toServiceRequestCardFormat, textAlign: TextAlign.end, - style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral20), + style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120), ), 50.width, Expanded( - child: historyLogModel.message.heading6(context), + child: historyLogModel.message.bodyText(context).custom(color: AppColor.black10), ), ], ), diff --git a/lib/service_request_latest/views/components/request_detail_view.dart b/lib/service_request_latest/views/components/request_detail_view.dart new file mode 100644 index 00000000..6f51e5a3 --- /dev/null +++ b/lib/service_request_latest/views/components/request_detail_view.dart @@ -0,0 +1,398 @@ +import 'package:another_flushbar/flushbar.dart'; +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/bottom_sheets/service_request_bottomsheet.dart'; +import 'package:test_sa/service_request_latest/views/components/bottom_sheets/reject_request_bottomsheet.dart'; +import 'package:test_sa/service_request_latest/views/components/verify_otp_view.dart'; +import 'package:test_sa/utilities/general_utils.dart'; +import 'package:test_sa/views/pages/user/requests/comments_bottom_sheet.dart'; +import 'package:test_sa/views/pages/user/requests/first_action_bottom_sheet.dart'; +import 'package:test_sa/views/pages/user/requests/update_service_request_page.dart'; +import 'package:test_sa/views/pages/user/requests/work_order/work_orders_list_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 'bottom_sheets/initial_visit_bottomsheet.dart'; + +class RequestDetailView extends StatefulWidget { + static const String id = "/call-details"; + ServiceRequest serviceRequest; + bool fromTabView=false; + + RequestDetailView({Key key, this.serviceRequest,this.fromTabView=false}) : super(key: key); + + @override + State createState() => _RequestDetailViewState(); +} + +class _RequestDetailViewState extends State { + @override + void initState() { + super.initState(); + getServiceRequest(requestId: widget.serviceRequest.id); + } + + void getServiceRequest({@required dynamic requestId}) { + // setState(() {}); + WidgetsFlutterBinding.ensureInitialized().addPostFrameCallback((timeStamp) async { + Provider.of(context, listen: false).reset(); + ServiceRequestsProvider serviceRequestsProvider = Provider.of(context, listen: false); + serviceRequestsProvider.currentSelectedRequest = await serviceRequestsProvider.getServiceRequestObjectById(requestId: requestId); + // setState(() {}); + }); + } + + @override + Widget build(BuildContext context) { + UserProvider _userProvider = Provider.of(context, listen: false); + return !widget.fromTabView? Scaffold( + appBar:DefaultAppBar(title: context.translation.serviceDetails), + body: Padding( + padding: EdgeInsets.only(top: 12.toScreenHeight), + child: Consumer(builder: (context, serviceRequestsProvider, child) { + return requestDetailCard(serviceRequestsProvider: serviceRequestsProvider,userProvider: _userProvider); + }), + ), + ):Consumer(builder: (context, serviceRequestsProvider, child) { + return requestDetailCard(serviceRequestsProvider: serviceRequestsProvider,userProvider: _userProvider); + }); + } + Widget requestDetailCard({ ServiceRequestsProvider serviceRequestsProvider,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 + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SingleChildScrollView( + padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), + child: informationCard(serviceRequestsProvider.currentSelectedRequest,userProvider), + ).expanded, + Center( + child: InkWell( + onTap: () async { + try{ + //use a common list + AllRequestsProvider allRequestProvider = Provider.of(context, listen: false); + int index = allRequestProvider.requestDetailList.requestsDetails.indexWhere((element) => element.id.toString() == serviceRequestsProvider.currentSelectedRequest.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), + ), + ), + ), + 20.height, + if (userProvider.user.type == UsersTypes.engineer || + (serviceRequestsProvider.currentSelectedRequest.statusValue == 5 || serviceRequestsProvider.currentSelectedRequest.statusValue == 3)) + (serviceRequestsProvider.currentSelectedRequest?.firstAction == null + ? Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.min, + children: [ + AppFilledButton( + label: context.translation.reject, + maxWidth: true, + buttonColor: Colors.white54, + textColor: AppColor.red50, + showBorder: true, + onPressed: () async { + ServiceRequestBottomSheet.rejectRequestBottomSheet(context: context); + // bool shouldReloadData = (await showModalBottomSheet( + // context: context, + // useSafeArea: true, + // isScrollControlled: true, + // backgroundColor: Colors.transparent, + // builder: (context) => RejectRequestBottomSheet(), + // )) as bool; + // if (shouldReloadData ?? false) { + // getServiceRequest(); + // } + }, + ).expanded, + const SizedBox( + width: 20, + ), + AppFilledButton( + label: context.translation.accept, + maxWidth: true, + buttonColor: AppColor.green70, + onPressed: () async { + // GeneralUtils.showFlushBar(context: context); + Navigator.of(context).push(MaterialPageRoute(builder: (_) => const VerifyOtpView())); + + // ServiceRequestBottomSheet.fixRemotelyBottomSheet(context: context); + // bool shouldReloadData = (await showModalBottomSheet( + // context: context, + // useSafeArea: true, + // isScrollControlled: true, + // backgroundColor: Colors.transparent, + // builder: (context) => InitialVisitBottomSheet(), + // )) as bool; + // if (shouldReloadData ?? false) { + // getServiceRequest(); + // } + }, + ).expanded, + ], + ) + // ? AppFilledButton( + // label: context.translation.firstAction, + // maxWidth: true, + // onPressed: () async { + // bool shouldReloadData = (await showModalBottomSheet( + // context: context, + // useSafeArea: true, + // isScrollControlled: true, + // backgroundColor: Colors.transparent, + // builder: (context) => FirstActionBottomSheet(request: serviceRequestsProvider.serviceRequest), + // )) as bool; + // if (shouldReloadData ?? false) { + // getServiceRequest(); + // } + // }, + // ) + : AppFilledButton( + label: context.translation.viewWorkOrder, + maxWidth: true, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => WorkOrderListPage(serviceRequest: serviceRequestsProvider.currentSelectedRequest)), + ); + // Navigator.of(context).pushNamed(WorkOrderListPage.id, arguments: serviceRequest); + }, + )) + .paddingOnly(start: 16, end: 16, bottom: 24), + ], + ), + ); + } + 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) ...[ + 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), + ); + }), + ], + ).toShadowContainer(context, padding: 0); + } +} diff --git a/lib/service_request_latest/views/request_detail_main_view.dart b/lib/service_request_latest/views/request_detail_main_view.dart new file mode 100644 index 00000000..1ab3c9d9 --- /dev/null +++ b/lib/service_request_latest/views/request_detail_main_view.dart @@ -0,0 +1,64 @@ +import 'package:flutter/material.dart'; +import 'package:test_sa/extensions/context_extension.dart'; +import 'package:test_sa/extensions/int_extensions.dart'; +import 'package:test_sa/extensions/text_extensions.dart'; +import 'package:test_sa/extensions/widget_extensions.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/default_app_bar.dart'; +import 'package:test_sa/service_request_latest/views/components/history_log_view.dart'; + +import 'components/request_detail_view.dart'; + +class RequestDetailMain extends StatelessWidget { + final int requestId; + const RequestDetailMain({Key key,this.requestId}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColor.neutral100, + appBar: DefaultAppBar(title: context.translation.serviceDetails), + body: DefaultTabController( + length: 2, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: EdgeInsets.only(left: 16.toScreenWidth, right: 16.toScreenWidth,top: 12.toScreenHeight), + decoration: BoxDecoration(color: context.isDark ? AppColor.neutral50 : AppColor.white10, borderRadius: BorderRadius.circular(10)), + child: TabBar( + //controller: _tabController, + padding: EdgeInsets.symmetric(vertical: 4.toScreenHeight,horizontal: 4.toScreenWidth), + labelColor: context.isDark ? AppColor.neutral30 : AppColor.black20, + unselectedLabelColor: context.isDark ? AppColor.neutral30 : AppColor.black20, + unselectedLabelStyle: AppTextStyles.bodyText, + labelStyle: AppTextStyles.bodyText, + indicatorPadding: EdgeInsets.zero, + indicator: BoxDecoration(color: context.isDark ? AppColor.neutral60 : AppColor.neutral110, borderRadius: BorderRadius.circular(7)), + onTap: (index) { + // setState(() {}); + }, + tabs: [ + Tab(text: context.translation.requestDetail, height: 57.toScreenHeight), + Tab(text: context.translation.historyLogs, height: 57.toScreenHeight), + ], + ), + ), + 12.height, + TabBarView( + children: [ + RequestDetailView( + serviceRequest: ServiceRequest(id: requestId.toString()), + fromTabView: true, + ), + // HistoryLogView(), + const HistoryLogView(), + ], + ).expanded, + ], + ), + ), + ); + } +} diff --git a/lib/service_request_latest/views/request_detail_view.dart b/lib/service_request_latest/views/request_detail_view.dart deleted file mode 100644 index 83be1193..00000000 --- a/lib/service_request_latest/views/request_detail_view.dart +++ /dev/null @@ -1,396 +0,0 @@ -import 'package:another_flushbar/flushbar.dart'; -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/bottom_sheets/service_request_bottomsheet.dart'; -import 'package:test_sa/service_request_latest/views/components/bottom_sheets/reject_request_bottomsheet.dart'; -import 'package:test_sa/service_request_latest/views/components/verify_otp_view.dart'; -import 'package:test_sa/utilities/general_utils.dart'; -import 'package:test_sa/views/pages/user/requests/comments_bottom_sheet.dart'; -import 'package:test_sa/views/pages/user/requests/first_action_bottom_sheet.dart'; -import 'package:test_sa/views/pages/user/requests/update_service_request_page.dart'; -import 'package:test_sa/views/pages/user/requests/work_order/work_orders_list_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 'components/bottom_sheets/initial_visit_bottomsheet.dart'; - -class ServiceRequestDetailView extends StatefulWidget { - static const String id = "/call-details"; - ServiceRequest serviceRequest; - - ServiceRequestDetailView({Key key, this.serviceRequest}) : super(key: key); - - @override - State createState() => _ServiceRequestDetailViewState(); -} - -class _ServiceRequestDetailViewState extends State { - bool loading = false; - - // ServiceRequest serviceRequest; - - @override - void initState() { - super.initState(); - getServiceRequest(requestId: widget.serviceRequest.id); - } - - void getServiceRequest({@required dynamic requestId}) { - // setState(() {}); - WidgetsFlutterBinding.ensureInitialized().addPostFrameCallback((timeStamp) async { - Provider.of(context, listen: false).reset(); - ServiceRequestsProvider serviceRequestsProvider = Provider.of(context, listen: false); - serviceRequestsProvider.currentSelectedRequest = await serviceRequestsProvider.getServiceRequestObjectById(requestId: requestId); - // setState(() {}); - }); - } - - @override - Widget build(BuildContext context) { - UserProvider _userProvider = Provider.of(context, listen: false); - - Widget informationCard(ServiceRequest serviceRequest) { - 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) ...[ - 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), - ); - }), - ], - ).toShadowContainer(context, padding: 0); - } - - return Scaffold( - appBar: DefaultAppBar(title: context.translation.serviceDetails), - //backgroundColor: const Color(0xfff8f9fb), - body: Consumer(builder: (context, serviceRequestsProvider, child) { - 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 - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SingleChildScrollView( - padding: const EdgeInsets.all(16), - child: informationCard(serviceRequestsProvider.currentSelectedRequest), - ).expanded, - Center( - child: InkWell( - onTap: () async { - try{ - //use a common list - AllRequestsProvider allRequestProvider = Provider.of(context, listen: false); - int index = allRequestProvider.requestDetailList.requestsDetails.indexWhere((element) => element.id.toString() == serviceRequestsProvider.currentSelectedRequest.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), - ), - ), - ), - 20.height, - if (_userProvider.user.type == UsersTypes.engineer || - (serviceRequestsProvider.currentSelectedRequest.statusValue == 5 || serviceRequestsProvider.currentSelectedRequest.statusValue == 3)) - (serviceRequestsProvider.currentSelectedRequest?.firstAction == null - ? Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.min, - children: [ - AppFilledButton( - label: context.translation.reject, - maxWidth: true, - buttonColor: Colors.white54, - textColor: AppColor.red50, - showBorder: true, - onPressed: () async { - ServiceRequestBottomSheet.rejectRequestBottomSheet(context: context); - // bool shouldReloadData = (await showModalBottomSheet( - // context: context, - // useSafeArea: true, - // isScrollControlled: true, - // backgroundColor: Colors.transparent, - // builder: (context) => RejectRequestBottomSheet(), - // )) as bool; - // if (shouldReloadData ?? false) { - // getServiceRequest(); - // } - }, - ).expanded, - const SizedBox( - width: 20, - ), - AppFilledButton( - label: context.translation.accept, - maxWidth: true, - buttonColor: AppColor.green70, - onPressed: () async { - // GeneralUtils.showFlushBar(context: context); - Navigator.of(context).push(MaterialPageRoute(builder: (_) => const VerifyOtpView())); - - // ServiceRequestBottomSheet.fixRemotelyBottomSheet(context: context); - // bool shouldReloadData = (await showModalBottomSheet( - // context: context, - // useSafeArea: true, - // isScrollControlled: true, - // backgroundColor: Colors.transparent, - // builder: (context) => InitialVisitBottomSheet(), - // )) as bool; - // if (shouldReloadData ?? false) { - // getServiceRequest(); - // } - }, - ).expanded, - ], - ) - // ? AppFilledButton( - // label: context.translation.firstAction, - // maxWidth: true, - // onPressed: () async { - // bool shouldReloadData = (await showModalBottomSheet( - // context: context, - // useSafeArea: true, - // isScrollControlled: true, - // backgroundColor: Colors.transparent, - // builder: (context) => FirstActionBottomSheet(request: serviceRequestsProvider.serviceRequest), - // )) as bool; - // if (shouldReloadData ?? false) { - // getServiceRequest(); - // } - // }, - // ) - : AppFilledButton( - label: context.translation.viewWorkOrder, - maxWidth: true, - onPressed: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => WorkOrderListPage(serviceRequest: serviceRequestsProvider.currentSelectedRequest)), - ); - // Navigator.of(context).pushNamed(WorkOrderListPage.id, arguments: serviceRequest); - }, - )) - .paddingOnly(start: 16, end: 16, bottom: 24), - ], - ), - ); - }), - ); - } -}