improvements

main_design2.0
Sikander Saleem 2 years ago
parent e8415399ed
commit 0b2ef3d114

@ -48,7 +48,7 @@ class GasRefillCommentsProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
Response response; Response response;
try { try {
response = await ApiManager.instance.get(URLs.getGazRefillComments + "?callRequestId=$callId"); response = await ApiManager.instance.get(URLs.getGazRefillComments + "?gasRefillId=$callId");
stateCode = response.statusCode; stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) { if (response.statusCode >= 200 && response.statusCode < 300) {
@ -56,6 +56,9 @@ class GasRefillCommentsProvider extends ChangeNotifier {
List<GasRefillComment> commentsPage = requestsListJson.map((request) => GasRefillComment.fromJson(request)).toList(); List<GasRefillComment> commentsPage = requestsListJson.map((request) => GasRefillComment.fromJson(request)).toList();
comments ??= []; comments ??= [];
comments.addAll(commentsPage); comments.addAll(commentsPage);
comments.sort((a,b) {
return b.createdOn.compareTo(a.createdOn);
});
if (commentsPage.length == pageItemNumber) { if (commentsPage.length == pageItemNumber) {
nextPage = true; nextPage = true;
} else { } else {
@ -79,20 +82,19 @@ class GasRefillCommentsProvider extends ChangeNotifier {
/// return state code if request complete may be 200, 404 or 403 /// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager /// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart /// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> addComment(BuildContext context, {@required GasRefillComment comment}) async { Future<int> addComment(BuildContext context, {@required String comment, int id}) async {
if (isLoading == true) return -2; if (isLoading == true) return -2;
isLoading = true; isLoading = true;
Response response; Response response;
try { try {
comment.id = 0;
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
response = await ApiManager.instance.post(URLs.addGazRefillComment, body: comment.toJson()); response = await ApiManager.instance.post(URLs.addGazRefillComment, body: {"id": 0, "gasRefillId": id, "comment": comment});
stateCode = response.statusCode; stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) { if (response.statusCode >= 200 && response.statusCode < 300) {
reset(); //visit.status = pentry.ppmVisitStatus; reset(); //visit.status = pentry.ppmVisitStatus;
notifyListeners(); notifyListeners();
Fluttertoast.showToast(msg: context.translation.successfulRequestMessage); Fluttertoast.showToast(msg: context.translation.commentAdded);
Navigator.of(context).pop(); Navigator.of(context).pop();
} else { } else {
Fluttertoast.showToast(msg: "${context.translation.failedToCompleteRequest} ${jsonDecode(response.body)["message"]}"); Fluttertoast.showToast(msg: "${context.translation.failedToCompleteRequest} ${jsonDecode(response.body)["message"]}");

@ -2,6 +2,7 @@
"serverErrorMessage": "الخدمة غير متاحة حاليا", "serverErrorMessage": "الخدمة غير متاحة حاليا",
"failedRequestMessage": "فشل إكمال الطلب", "failedRequestMessage": "فشل إكمال الطلب",
"successfulRequestMessage": "تم إكمال الطلب بنجاح", "successfulRequestMessage": "تم إكمال الطلب بنجاح",
"commentAdded": "تم إضافة التعليق",
"requestLockMessage": "انتظر حتى إكمال الطلب", "requestLockMessage": "انتظر حتى إكمال الطلب",
"cancel": "إلغاء", "cancel": "إلغاء",
"confirm": "تاكيد", "confirm": "تاكيد",

@ -2,6 +2,7 @@
"serverErrorMessage": "Currently, Service not available", "serverErrorMessage": "Currently, Service not available",
"failedRequestMessage": "Failed to complete request", "failedRequestMessage": "Failed to complete request",
"successfulRequestMessage": "Request complete successfully", "successfulRequestMessage": "Request complete successfully",
"commentAdded": "Comment Added",
"requestLockMessage": "Wait until your request complete", "requestLockMessage": "Wait until your request complete",
"cancel": "Cancel", "cancel": "Cancel",
"confirm": "Confirm", "confirm": "Confirm",

@ -165,7 +165,7 @@ class _CreateSubWorkOrderPageState extends State<CreateSubWorkOrderPage> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
(widget.workOrder?.callRequest?.asset?.site?.name ?? "").heading5(context), (widget.workOrder?.callRequest?.asset?.site?.custName ?? "").heading5(context),
8.height, 8.height,
"${context.translation.assetNo}: ${widget.workOrder?.callRequest?.asset?.assetNumber ?? ""}".bodyText(context), "${context.translation.assetNo}: ${widget.workOrder?.callRequest?.asset?.assetNumber ?? ""}".bodyText(context),
"${context.translation.callId}: ${widget.workOrder?.callRequest?.id}".bodyText(context), "${context.translation.callId}: ${widget.workOrder?.callRequest?.id}".bodyText(context),

@ -39,10 +39,8 @@ class _GasRefillCommentsBottomSheetState extends State<GasRefillCommentsBottomSh
Widget build(BuildContext context) { Widget build(BuildContext context) {
final commentsProvider = Provider.of<GasRefillCommentsProvider>(context); final commentsProvider = Provider.of<GasRefillCommentsProvider>(context);
final userProvider = Provider.of<UserProvider>(context, listen: false); final userProvider = Provider.of<UserProvider>(context, listen: false);
return SingleChildScrollView( return Container(
child: Wrap( height: MediaQuery.of(context).size.height * 0.6,
children: [
Container(
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -53,17 +51,6 @@ class _GasRefillCommentsBottomSheetState extends State<GasRefillCommentsBottomSh
child: Form( child: Form(
key: _formKey, key: _formKey,
child: Column( child: Column(
children: [
LoadingManager(
isLoading: commentsProvider.isLoading,
isFailedLoading: commentsProvider.comments == null,
stateCode: commentsProvider.stateCode,
onRefresh: () async {
commentsProvider.reset();
await commentsProvider.getComments(callId: widget.requestId);
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Container( Container(
width: 40.toScreenWidth, width: 40.toScreenWidth,
@ -75,7 +62,15 @@ class _GasRefillCommentsBottomSheetState extends State<GasRefillCommentsBottomSh
alignment: AlignmentDirectional.centerStart, alignment: AlignmentDirectional.centerStart,
child: context.translation.comments.heading3(context).custom(fontWeight: FontWeight.w600), child: context.translation.comments.heading3(context).custom(fontWeight: FontWeight.w600),
), ),
commentsProvider.comments.isEmpty LoadingManager(
isLoading: commentsProvider.isLoading,
isFailedLoading: commentsProvider.comments == null,
stateCode: commentsProvider.stateCode,
onRefresh: () async {
commentsProvider.reset();
await commentsProvider.getComments(callId: widget.requestId);
},
child: commentsProvider.comments.isEmpty
? SizedBox( ? SizedBox(
height: MediaQuery.of(context).size.height * 0.25, height: MediaQuery.of(context).size.height * 0.25,
child: NoItemFound(message: context.translation.noDataFound), child: NoItemFound(message: context.translation.noDataFound),
@ -86,8 +81,8 @@ class _GasRefillCommentsBottomSheetState extends State<GasRefillCommentsBottomSh
child: ListView.separated( child: ListView.separated(
itemCount: commentsProvider.comments.length, itemCount: commentsProvider.comments.length,
padding: const EdgeInsets.only(top: 16, bottom: 8), padding: const EdgeInsets.only(top: 16, bottom: 8),
shrinkWrap: true, // shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), // physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (cxt, index) => 8.height, separatorBuilder: (cxt, index) => 8.height,
itemBuilder: (context, itemIndex) { itemBuilder: (context, itemIndex) {
final model = commentsProvider.comments[itemIndex]; final model = commentsProvider.comments[itemIndex];
@ -95,9 +90,9 @@ class _GasRefillCommentsBottomSheetState extends State<GasRefillCommentsBottomSh
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
(model?.createdBy?.userName ?? "Nurse").heading6(context), (model?.createdBy?.userName ?? "Nurse").heading6(context),
8.height, // 8.height,
(model?.comment ?? "").bodyText(context), (model?.comment ?? "").bodyText(context),
8.height, //8.height,
Align( Align(
alignment: AlignmentDirectional.bottomEnd, alignment: AlignmentDirectional.bottomEnd,
child: Text(DateTime.tryParse(model.createdOn).toIso8601String().toServiceRequestDetailsFormat, child: Text(DateTime.tryParse(model.createdOn).toIso8601String().toServiceRequestDetailsFormat,
@ -108,9 +103,7 @@ class _GasRefillCommentsBottomSheetState extends State<GasRefillCommentsBottomSh
}, },
), ),
), ),
], ).expanded,
),
),
if (userProvider.user.type == UsersTypes.normal_user) 8.height, if (userProvider.user.type == UsersTypes.normal_user) 8.height,
if (userProvider.user.type == UsersTypes.normal_user) if (userProvider.user.type == UsersTypes.normal_user)
AppTextFormField( AppTextFormField(
@ -123,8 +116,8 @@ class _GasRefillCommentsBottomSheetState extends State<GasRefillCommentsBottomSh
suffixIcon: "comment_send".toSvgAsset().paddingOnly(end: 16).onPress(() { suffixIcon: "comment_send".toSvgAsset().paddingOnly(end: 16).onPress(() {
if (_formKey.currentState.validate()) { if (_formKey.currentState.validate()) {
_formKey.currentState.save(); _formKey.currentState.save();
final comment = GasRefillComment(id: 0, gasRefillId: num.tryParse(widget.requestId ?? ""), comment: text); // final comment = GasRefillComment(id: 0, gasRefillId: num.tryParse(widget.requestId ?? ""), comment: text);
commentsProvider.addComment(context, comment: comment); commentsProvider.addComment(context, comment: text, id: num.tryParse(widget.requestId ?? ""));
} }
}), }),
onSaved: (value) { onSaved: (value) {
@ -135,9 +128,6 @@ class _GasRefillCommentsBottomSheetState extends State<GasRefillCommentsBottomSh
], ],
), ),
), ),
),
],
),
); );
} }
} }

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:test_sa/controllers/providers/api/gas_refill_comments.dart';
import 'package:test_sa/controllers/providers/api/gas_refill_provider.dart'; import 'package:test_sa/controllers/providers/api/gas_refill_provider.dart';
import 'package:test_sa/controllers/providers/api/user_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/context_extension.dart';
@ -40,6 +41,7 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
void initState() { void initState() {
// _model.fromGasRefillModel(gasRefillModel); // _model.fromGasRefillModel(gasRefillModel);
super.initState(); super.initState();
Provider.of<GasRefillCommentsProvider>(context, listen: false).reset();
} }
@override @override

Loading…
Cancel
Save