diff --git a/lib/extensions/text_extensions.dart b/lib/extensions/text_extensions.dart index b89f6625..d09b3898 100644 --- a/lib/extensions/text_extensions.dart +++ b/lib/extensions/text_extensions.dart @@ -145,6 +145,7 @@ extension FilesExtension on String { BoxFit fit = BoxFit.contain, }) => Image.asset("assets/images/$this.png", width: width?.toScreenWidth, height: height?.toScreenHeight, color: color, fit: fit); + LottieBuilder toLottieAsset({ int width, int height, diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index 30c0842f..002c6dc5 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -48,9 +48,9 @@ extension WidgetExtensions on Widget { ).toShadowContainer(context) : this; - Widget toShadowContainer(BuildContext context, {bool showShadow = true}) => showShadow + Widget toShadowContainer(BuildContext context, {bool showShadow = true, double padding = 16}) => showShadow ? Container( - padding: const EdgeInsets.all(16), + padding: EdgeInsets.all(padding), decoration: ShapeDecoration( color: Theme.of(context).cardColor, shape: RoundedRectangleBorder( diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 01732e16..aa168e16 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -360,5 +360,6 @@ "requestGasRefill" : "Request Gas Refill", "trackGasRefill" : "Track Gas Refill", "trackAssetTransfer" : "Track Asset Transfer", - "total" : "Total" + "total" : "Total", + "noDataFound" : "No Data Found" } \ No newline at end of file diff --git a/lib/models/comment.dart b/lib/models/comment.dart index f0bebfd2..63cd4732 100644 --- a/lib/models/comment.dart +++ b/lib/models/comment.dart @@ -14,11 +14,13 @@ class Comment { createdBy = json['createdBy'] != null ? CreatedBy.fromJson(json['createdBy']) : null; comment = json['comment']; } + num id; num callRequestId; String createdOn; CreatedBy createdBy; String comment; + Comment copyWith({ num id, num callRequestId, @@ -33,6 +35,7 @@ class Comment { createdBy: createdBy ?? this.createdBy, comment: comment ?? this.comment, ); + Map toJson() { final map = {}; map['id'] = id; @@ -56,8 +59,10 @@ class CreatedBy { userId = json['userId']; userName = json['userName']; } + String userId; String userName; + CreatedBy copyWith({ String userId, String userName, @@ -66,6 +71,7 @@ class CreatedBy { userId: userId ?? this.userId, userName: userName ?? this.userName, ); + Map toJson() { final map = {}; map['userId'] = userId; diff --git a/lib/new_views/common_widgets/app_text_form_field.dart b/lib/new_views/common_widgets/app_text_form_field.dart index 29676754..405880ad 100644 --- a/lib/new_views/common_widgets/app_text_form_field.dart +++ b/lib/new_views/common_widgets/app_text_form_field.dart @@ -27,6 +27,7 @@ class AppTextFormField extends StatefulWidget { final VoidCallback onAction; final Color backgroundColor; final bool alignLabelWithHint; + final bool showShadow; const AppTextFormField( {Key key, @@ -51,6 +52,7 @@ class AppTextFormField extends StatefulWidget { this.textInputAction, this.onAction, this.backgroundColor, + this.showShadow = true, this.alignLabelWithHint}) : super(key: key); @@ -71,7 +73,7 @@ class _AppTextFormFieldState extends State { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], + boxShadow: widget.showShadow ? [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)] : null, ), child: TextFormField( focusNode: widget.node, 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 84444c5e..6f9e997d 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 @@ -5,7 +5,9 @@ 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/all_requests_and_count_model.dart'; +import 'package:test_sa/models/service_request/service_request.dart'; import 'package:test_sa/views/app_style/colors.dart'; +import 'package:test_sa/views/pages/user/requests/service_request_details.dart'; import 'package:test_sa/views/widgets/requests/request_status.dart'; class ServiceRequestItemView extends StatelessWidget { @@ -65,6 +67,11 @@ class ServiceRequestItemView extends StatelessWidget { ], ), ], - ).toShadowContainer(context, showShadow: showShadow).onPress(() {}); + ).toShadowContainer(context, showShadow: showShadow).onPress(() { + Navigator.of(context).push(MaterialPageRoute( + builder: (_) => ServiceRequestDetailsPage( + serviceRequest: ServiceRequest(id: request.id.toString()), + ))); + }); } } diff --git a/lib/views/pages/user/requests/comments_bottom_sheet.dart b/lib/views/pages/user/requests/comments_bottom_sheet.dart index 4675b2b4..a92d141b 100644 --- a/lib/views/pages/user/requests/comments_bottom_sheet.dart +++ b/lib/views/pages/user/requests/comments_bottom_sheet.dart @@ -19,6 +19,7 @@ import '../../../widgets/loaders/loading_manager.dart'; class CommentsBottomSheet extends StatefulWidget { final String requestId; + const CommentsBottomSheet({Key key, @required this.requestId}) : super(key: key); @override @@ -58,50 +59,53 @@ class _CommentsBottomSheetState extends State { await commentsProvider.getComments(callId: widget.requestId); }, child: Column( + crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( width: 40.toScreenWidth, height: 5.toScreenHeight, decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)), ), + 16.height, Align( alignment: AlignmentDirectional.centerStart, - child: context.translation.comments.heading3(context).custom(fontWeight: FontWeight.w600).paddingOnly(top: 16, bottom: 16), + child: context.translation.comments.heading3(context).custom(fontWeight: FontWeight.w600), ), commentsProvider.comments.isEmpty - ? NoItemFound(message: context.translation.noServiceRequestFound).expanded + ? NoItemFound(message: context.translation.noDataFound).expanded : LazyLoading( nextPage: commentsProvider.nextPage, onLazyLoad: () async => await commentsProvider.getComments(callId: widget.requestId), child: ListView.separated( itemCount: commentsProvider.comments.length, + padding: const EdgeInsets.only(top: 16, bottom: 8), separatorBuilder: (cxt, index) => 8.height, itemBuilder: (context, itemIndex) { final model = commentsProvider.comments[itemIndex]; - return Card( - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - (model?.createdBy?.userName ?? "Nurse").heading6(context), - 8.height, - (model?.comment ?? "").bodyText(context), - 8.height, - Align( - alignment: AlignmentDirectional.bottomEnd, - child: DateTime.tryParse(model.createdOn).toIso8601String().toServiceRequestDetailsFormat.tinyFont(context), - ), - ], - ).paddingAll(16), - ); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + (model?.createdBy?.userName ?? "Nurse").heading6(context), + 8.height, + (model?.comment ?? "").bodyText(context), + 8.height, + Align( + alignment: AlignmentDirectional.bottomEnd, + child: Text(DateTime.tryParse(model.createdOn).toIso8601String().toServiceRequestDetailsFormat, + style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50)), + ), + ], + ).toShadowContainer(context); }, ), ).expanded, - if (userProvider.user.type == UsersTypes.normal_user) 16.height, + if (userProvider.user.type == UsersTypes.normal_user) 8.height, if (userProvider.user.type == UsersTypes.normal_user) AppTextFormField( labelText: "Type any comment", backgroundColor: AppColor.neutral30, alignLabelWithHint: true, + showShadow: false, validator: (value) => Validator.hasValue(value) ? null : context.translation.requiredField, textInputType: TextInputType.multiline, suffixIcon: "comment_send".toSvgAsset().paddingOnly(end: 16).onPress(() { diff --git a/lib/views/pages/user/requests/service_request_details.dart b/lib/views/pages/user/requests/service_request_details.dart index d8252baf..c317a009 100644 --- a/lib/views/pages/user/requests/service_request_details.dart +++ b/lib/views/pages/user/requests/service_request_details.dart @@ -49,7 +49,7 @@ class _ServiceRequestDetailsPageState extends State { ServiceRequestsProvider _serviceRequestsProvider = Provider.of(context); // _serviceRequestsProvider.getServiceRequestObjectById(requestId: serviceRequest.id); - Widget informationCard() { + Widget informationCard(ServiceRequest serviceRequest) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -66,32 +66,32 @@ class _ServiceRequestDetailsPageState extends State { Row( children: [ StatusLabel( - label: widget.serviceRequest.priority.name, - id: widget.serviceRequest.priority.id, - textColor: AColors.getPriorityStatusTextColor(widget.serviceRequest.priority.id), - backgroundColor: AColors.getPriorityStatusColor(widget.serviceRequest.priority.id)), + label: serviceRequest.priority.name, + id: serviceRequest.priority.id, + textColor: AColors.getPriorityStatusTextColor(serviceRequest.priority.id), + backgroundColor: AColors.getPriorityStatusColor(serviceRequest.priority.id)), 8.width, StatusLabel( - label: widget.serviceRequest.statusLabel, - textColor: AColors.getRequestStatusTextColor(widget.serviceRequest.statusValue), - backgroundColor: AColors.getRequestStatusColor(widget.serviceRequest.statusValue)), + label: serviceRequest.statusLabel, + textColor: AColors.getRequestStatusTextColor(serviceRequest.statusValue), + backgroundColor: AColors.getRequestStatusColor(serviceRequest.statusValue)), 1.width.expanded, ], ), 8.height, - Text(widget.serviceRequest.deviceEnName, style: AppTextStyles.heading5.copyWith(color: context.isDark?AppColor.neutral30: const Color(0xFF3B3D4A))), + Text(serviceRequest.deviceEnName, style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : const Color(0xFF3B3D4A))), 8.height, Text( - '${context.translation.assetNumber}: ${widget.serviceRequest.device.assetNumber}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark?AppColor.neutral10:Color(0xFF757575)), + '${context.translation.assetNumber}: ${serviceRequest.device.assetNumber}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : Color(0xFF757575)), ), Text( - '${context.translation.requestType}: ${widget.serviceRequest.type.name}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark?AppColor.neutral10:Color(0xFF757575)), + '${context.translation.requestType}: ${serviceRequest.type.name}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : Color(0xFF757575)), ), Text( - '${context.translation.requestNo}: ${widget.serviceRequest.requestCode}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark?AppColor.neutral10:Color(0xFF757575)), + '${context.translation.requestNo}: ${serviceRequest.requestCode}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : Color(0xFF757575)), ), ], ).expanded, @@ -100,10 +100,11 @@ class _ServiceRequestDetailsPageState extends State { children: [ if (_userProvider.user.type == UsersTypes.normal_user) context.translation.code.toSvgAsset(width: 48).onPress(() { - Navigator.push(context, MaterialPageRoute(builder: (context) => UpdateServiceRequestPage(serviceRequest: widget.serviceRequest))); + Navigator.push(context, MaterialPageRoute(builder: (context) => UpdateServiceRequestPage(serviceRequest: serviceRequest))); }), if (_userProvider.user.type == UsersTypes.engineer) 16.height, - Text(widget.serviceRequest.date.toServiceRequestCardFormat, textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark?AppColor.neutral30:const Color(0xFF3B3D4A))), + Text(serviceRequest.date.toServiceRequestCardFormat, + textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : const Color(0xFF3B3D4A))), ], ) ], @@ -112,34 +113,35 @@ class _ServiceRequestDetailsPageState extends State { const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1), 8.height, Text( - '${context.translation.manufacture}: ${widget.serviceRequest.device.modelDefinition.manufacturerName}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark?AppColor.neutral10:Color(0xFF757575)), + '${context.translation.manufacture}: ${serviceRequest.device.modelDefinition.manufacturerName}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : Color(0xFF757575)), ), Text( - '${context.translation.model}: ${widget.serviceRequest.device.modelDefinition.modelName}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark?AppColor.neutral10:Color(0xFF757575)), + '${context.translation.model}: ${serviceRequest.device.modelDefinition.modelName}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : Color(0xFF757575)), ), 8.height, - if ((widget.serviceRequest.callComments ?? "").isNotEmpty) ...[ + if ((serviceRequest.callComments ?? "").isNotEmpty) ...[ const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1), 8.height, Text( - widget.serviceRequest.callComments, - style: AppTextStyles.bodyText.copyWith(color: context.isDark?AppColor.neutral10:Color(0xFF757575)), + serviceRequest.callComments, + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : Color(0xFF757575)), ), ], - if (widget.serviceRequest.devicePhotos.isNotEmpty) ...[ + if (serviceRequest.devicePhotos.isNotEmpty) ...[ 8.height, const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1), - FilesList(images: widget.serviceRequest.devicePhotos), + FilesList(images: serviceRequest.devicePhotos), ], - if (widget.serviceRequest.audio?.isNotEmpty ?? false) ...[ + if (serviceRequest.audio?.isNotEmpty ?? false) ...[ const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1), 16.height, - ASoundPlayer(audio: widget.serviceRequest.audio), + ASoundPlayer(audio: serviceRequest.audio), + 8.height, ], ], - ).paddingAll(16), + ).paddingOnly(start: 16, end: 16, top: 16, bottom: 8), (_userProvider.user.type == UsersTypes.normal_user ? Container( height: 50, @@ -158,12 +160,12 @@ class _ServiceRequestDetailsPageState extends State { child: Row( children: [ Text( - '${context.translation.viewComments}...', + '${context.translation.commentHere}...', style: AppTextStyles.heading6.copyWith( color: AppColor.neutral50.withOpacity(.6), ), ).expanded, - SvgPicture.asset("assets/images/comment_send.svg", width: 24 * AppStyle.getScaleFactor(context), height: 24 * AppStyle.getScaleFactor(context), color: AppColor.primary70), + SvgPicture.asset("assets/images/comment_send.svg", width: 24 * AppStyle.getScaleFactor(context), height: 20 * AppStyle.getScaleFactor(context), color: AppColor.primary70), ], ), ) @@ -190,17 +192,18 @@ class _ServiceRequestDetailsPageState extends State { ), ], ).paddingOnly(bottom: 16, start: 16, end: 16)) - .onPress(() async { - await showModalBottomSheet( + .onPress(() { + showModalBottomSheet( context: context, useSafeArea: true, isScrollControlled: true, + useRootNavigator: true, backgroundColor: Colors.transparent, - builder: (context) => CommentsBottomSheet(requestId: widget.serviceRequest.id), + builder: (context) => CommentsBottomSheet(requestId: serviceRequest.id), ); }), ], - ).toShadowContainer(context); + ).toShadowContainer(context, padding: 0); } return Scaffold( @@ -213,13 +216,13 @@ class _ServiceRequestDetailsPageState extends State { if (snap.connectionState == ConnectionState.waiting) { return const ALoading(); } else if (snap.hasData) { - final serviceRequest = snap.data; + ServiceRequest serviceRequest = snap.data; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SingleChildScrollView( padding: const EdgeInsets.all(16), - child: informationCard(), + child: informationCard(serviceRequest), ).expanded, if (_userProvider.user.type == UsersTypes.engineer || (serviceRequest.statusValue == 5 || serviceRequest.statusValue == 3)) (serviceRequest.firstAction == null diff --git a/lib/views/widgets/loaders/no_item_found.dart b/lib/views/widgets/loaders/no_item_found.dart index 3466f7e7..8da966cd 100644 --- a/lib/views/widgets/loaders/no_item_found.dart +++ b/lib/views/widgets/loaders/no_item_found.dart @@ -1,4 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:test_sa/extensions/context_extension.dart'; +import 'package:test_sa/extensions/text_extensions.dart'; +import 'package:test_sa/new_views/app_style/app_color.dart'; +import 'package:test_sa/new_views/app_style/app_text_style.dart'; import 'package:test_sa/views/app_style/sizing.dart'; class NoItemFound extends StatelessWidget { @@ -14,11 +18,7 @@ class NoItemFound extends StatelessWidget { return Stack( children: [ Center( - child: Text( - message ?? "no item found", - style: Theme.of(context).textTheme.headline6, - textScaleFactor: AppStyle.getScaleFactor(context), - ), + child: Text(message ?? "no item found", style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50)), ), ListView(), ], diff --git a/lib/views/widgets/requests/service_request_item.dart b/lib/views/widgets/requests/service_request_item.dart index ac1f26a2..ba250f67 100644 --- a/lib/views/widgets/requests/service_request_item.dart +++ b/lib/views/widgets/requests/service_request_item.dart @@ -27,11 +27,11 @@ class ServiceRequestItem extends StatelessWidget { @override Widget build(BuildContext context) { - User _user = Provider.of(context, listen: false).user; - final servicesProvider = Provider.of(context, listen: false); - final settingProvider = Provider.of(context, listen: false); - Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary; - Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary; + // User _user = Provider.of(context, listen: false).user; + // final servicesProvider = Provider.of(context, listen: false); + // final settingProvider = Provider.of(context, listen: false); + // Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary; + // Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary; return Column( children: [ @@ -50,26 +50,26 @@ class ServiceRequestItem extends StatelessWidget { 8.width, StatusLabel(label: request.statusLabel, textColor: AColors.getRequestStatusTextColor(request.statusValue), backgroundColor: AColors.getRequestStatusColor(request.statusValue)), 1.width.expanded, - Text(request.date.toServiceRequestCardFormat, textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark? AppColor.neutral30:const Color(0xFF3B3D4A))), + Text(request.date.toServiceRequestCardFormat, textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : const Color(0xFF3B3D4A))), ], ), 8.height, - Text(context.translation.serviceRequest, style: AppTextStyles.heading5.copyWith(color: context.isDark? AppColor.neutral30:const Color(0xFF3B3D4A))), + Text(context.translation.serviceRequest, style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : const Color(0xFF3B3D4A))), Text( '${context.translation.assetName}: ${request.deviceEnName}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark?AppColor.neutral10:Color(0xFF757575)), + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : Color(0xFF757575)), ), Text( '${context.translation.assetNumber}: ${request.device.assetNumber}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark?AppColor.neutral10:Color(0xFF757575)), + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : Color(0xFF757575)), ), Text( '${context.translation.requestType}: ${request.type.name}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark?AppColor.neutral10:Color(0xFF757575)), + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : Color(0xFF757575)), ), Text( '${context.translation.requestNo}: ${request.requestCode}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark?AppColor.neutral10:Color(0xFF757575)), + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : Color(0xFF757575)), ), 8.height, Row(