add pagination to doctor replay

implement_copy
Elham Rababh 3 years ago
parent 1c2ccd9149
commit 943463b1d9

@ -709,5 +709,6 @@ const Map<String, Map<String, String>> localizedValues = {
"Completed": {"en": "Completed", "ar": "مكتمل"},
"Locked": {"en": "Locked", "ar": "مقفل"},
"textCopiedSuccessfully": {"en": "Text copied successfully", "ar": "تم نسخ النص بنجاح"},
"seeMore": {"en": "See More ...", "ar": "شاهد المزيد..."},
};

@ -13,15 +13,15 @@ class DoctorReplyService extends BaseService {
List<ListGtMyPatientsQuestions> _listDoctorWorkingHoursTable = [];
RequestDoctorReply _requestDoctorReply = RequestDoctorReply();
List<MyReferralPatientModel> _listMyReferralPatientModel = [];
List<MyReferralPatientModel> get listMyReferralPatientModel => _listMyReferralPatientModel;
int notRepliedCount = 0;
Future getDoctorReply() async {
Future getDoctorReply(RequestDoctorReply _requestDoctorReply,{bool clearData = false}) async {
hasError = false;
await baseAppClient.post(GT_MY_PATIENT_QUESTION,
onSuccess: (dynamic response, int statusCode) {
if(clearData)
_listDoctorWorkingHoursTable.clear();
response['List_GtMyPatientsQuestions'].forEach((v) {
_listDoctorWorkingHoursTable

@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/service/home/doctor_reply_service.dart';
import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart';
import 'package:doctor_app_flutter/models/doctor/replay/request_create_doctor_response.dart';
import 'package:doctor_app_flutter/models/doctor/replay/request_doctor_reply.dart';
import '../../locator.dart';
import 'base_view_model.dart';
@ -12,13 +13,25 @@ class DoctorReplayViewModel extends BaseViewModel {
List<ListGtMyPatientsQuestions> get listDoctorWorkingHoursTable =>
_doctorReplyService.listDoctorWorkingHoursTable;
Future getDoctorReply() async {
setState(ViewState.Busy);
Future getDoctorReply(
{int pageSize = 10, int pageIndex = 1, bool isLocalBusy = true}) async {
if (isLocalBusy) {
setState(ViewState.BusyLocal);
} else {
setState(ViewState.Busy);
}
await getDoctorProfile();
await _doctorReplyService.getDoctorReply();
RequestDoctorReply _requestDoctorReply =
RequestDoctorReply(pageIndex: pageIndex, pageSize: pageSize);
await _doctorReplyService.getDoctorReply(_requestDoctorReply, clearData:!isLocalBusy );
if (_doctorReplyService.hasError) {
error = _doctorReplyService.error;
setState(ViewState.Error);
if (isLocalBusy) {
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Error);
}
} else
setState(ViewState.Idle);
}
@ -28,13 +41,12 @@ class DoctorReplayViewModel extends BaseViewModel {
await getDoctorProfile();
CreateDoctorResponseModel createDoctorResponseModel =
CreateDoctorResponseModel(
transactionNo: model.transactionNo.toString(),
doctorResponse: response,
infoStatus: 6,
createdBy:this.doctorProfile.doctorID,
infoEnteredBy: this.doctorProfile.doctorID,
setupID:"010266"
);
transactionNo: model.transactionNo.toString(),
doctorResponse: response,
infoStatus: 6,
createdBy: this.doctorProfile.doctorID,
infoEnteredBy: this.doctorProfile.doctorID,
setupID: "010266");
setState(ViewState.BusyLocal);
await _doctorReplyService.createDoctorResponse(createDoctorResponseModel);
if (_doctorReplyService.hasError) {
@ -43,7 +55,6 @@ class DoctorReplayViewModel extends BaseViewModel {
} else {
setState(ViewState.Idle);
_doctorReplyService.getNotRepliedCount();
}
}
}

@ -13,20 +13,24 @@ class RequestDoctorReply {
String sessionID;
bool isLoginForDoctorApp;
bool patientOutSA;
int pageIndex;
int pageSize;
RequestDoctorReply(
{this.projectID ,
this.doctorID ,
this.transactionNo = TRANSACTION_NO ,
this.languageID ,
this.stamp ,
{this.projectID,
this.doctorID,
this.transactionNo = TRANSACTION_NO,
this.languageID,
this.stamp,
this.iPAdress,
this.versionID ,
this.versionID,
this.channel,
this.tokenID ,
this.tokenID,
this.sessionID,
this.isLoginForDoctorApp ,
this.patientOutSA });
this.isLoginForDoctorApp,
this.patientOutSA,
this.pageIndex,
this.pageSize});
RequestDoctorReply.fromJson(Map<String, dynamic> json) {
projectID = json['ProjectID'];
@ -41,6 +45,8 @@ class RequestDoctorReply {
sessionID = json['SessionID'];
isLoginForDoctorApp = json['IsLoginForDoctorApp'];
patientOutSA = json['PatientOutSA'];
pageIndex = json['PageIndex'];
pageSize = json['PageSize'];
}
Map<String, dynamic> toJson() {
@ -57,6 +63,8 @@ class RequestDoctorReply {
data['SessionID'] = this.sessionID;
data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp;
data['PatientOutSA'] = this.patientOutSA;
data['PageIndex'] = this.pageIndex;
data['PageSize'] = this.pageSize;
return data;
}
}

@ -370,7 +370,7 @@ class DoctorReplayChat extends StatelessWidget {
Helpers.showErrorToast(previousModel.error);
} else {
DrAppToastMsg.showSuccesToast("Thank you for your replay ");
await previousModel.getDoctorReply();
await previousModel.getDoctorReply(isLocalBusy: false);
Navigator.pop(context);
}
GifLoaderDialogUtils.hideDialog(context);

@ -1,10 +1,15 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/doctor/doctor_repaly_chat.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/doctor/doctor_reply_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -15,21 +20,27 @@ import 'package:flutter/material.dart';
*@return:
*@desc: Doctor Reply Screen display data from GtMyPatientsQuestions service
*/
class DoctorReplyScreen extends StatelessWidget {
class DoctorReplyScreen extends StatefulWidget {
final Function changeCurrentTab;
const DoctorReplyScreen({Key key, this.changeCurrentTab}) : super(key: key);
@override
_DoctorReplyScreenState createState() => _DoctorReplyScreenState();
}
class _DoctorReplyScreenState extends State<DoctorReplyScreen> {
int pageIndex = 1;
@override
Widget build(BuildContext context) {
return BaseView<DoctorReplayViewModel>(
onModelReady: (model) {
model.getDoctorReply();
model.getDoctorReply(isLocalBusy: false);
},
builder: (_, model, w) => WillPopScope(
onWillPop: ()async{
changeCurrentTab();
onWillPop: () async {
widget.changeCurrentTab();
return false;
},
child: AppScaffold(
@ -45,22 +56,46 @@ class DoctorReplyScreen extends StatelessWidget {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children:
model.listDoctorWorkingHoursTable.map((reply) {
children: model.listDoctorWorkingHoursTable.map(
(reply) {
return InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
DoctorReplayChat(
reply: reply,
previousModel: model,
), settings: RouteSettings(name: 'DoctorReplayChat'),));
},
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
DoctorReplayChat(
reply: reply,
previousModel: model,
),
settings:
RouteSettings(name: 'DoctorReplayChat'),
));
},
child: DoctorReplyWidget(reply: reply),
);
}).toList(),
}).toList()
..add(InkWell(
onTap: () async {
setState(() {
pageIndex++;
});
GifLoaderDialogUtils.showMyDialog(context);
await model.getDoctorReply(pageIndex: pageIndex);
if (model.state == ViewState.ErrorLocal) {
GifLoaderDialogUtils.hideDialog(context);
Helpers.showErrorToast(model.error);
} else
GifLoaderDialogUtils.hideDialog(context);
},
child: Center(
child: Container(
padding: EdgeInsets.all(20),
child: AppText("${TranslationBase.of(context).seeMore}", fontSize: SizeConfig.getTextMultiplierBasedOnWidth()*4,),
),
),
)),
)
],
),
@ -68,6 +103,5 @@ class DoctorReplyScreen extends StatelessWidget {
),
),
);
}
}

@ -1371,6 +1371,7 @@ class TranslationBase {
String get summeryReply => localizedValues['summeryReply'][locale.languageCode];
String get severityValidationError => localizedValues['severityValidationError'][locale.languageCode];
String get textCopiedSuccessfully => localizedValues['textCopiedSuccessfully'][locale.languageCode];
String get seeMore => localizedValues['seeMore'][locale.languageCode];
}
class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> {

@ -664,7 +664,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.4"
version: "1.3.0-nullsafety.3"
mime:
dependency: transitive
description:
@ -956,7 +956,7 @@ packages:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.2"
version: "1.10.0-nullsafety.1"
sticky_headers:
dependency: "direct main"
description:
@ -1154,5 +1154,5 @@ packages:
source: hosted
version: "2.2.1"
sdks:
dart: ">=2.10.0 <=2.11.0-213.1.beta"
dart: ">=2.10.0 <2.11.0"
flutter: ">=1.22.0 <2.0.0"

Loading…
Cancel
Save