Merge branch 'pagination_doctor_repay' into 'development'

add pagination to doctor replay

See merge request Cloud_Solution/doctor_app_flutter!798
merge-requests/799/merge
Mohammad Aljammal 5 years ago
commit 047acd7116

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

@ -13,15 +13,15 @@ class DoctorReplyService extends BaseService {
List<ListGtMyPatientsQuestions> _listDoctorWorkingHoursTable = []; List<ListGtMyPatientsQuestions> _listDoctorWorkingHoursTable = [];
RequestDoctorReply _requestDoctorReply = RequestDoctorReply();
List<MyReferralPatientModel> _listMyReferralPatientModel = []; List<MyReferralPatientModel> _listMyReferralPatientModel = [];
List<MyReferralPatientModel> get listMyReferralPatientModel => _listMyReferralPatientModel; List<MyReferralPatientModel> get listMyReferralPatientModel => _listMyReferralPatientModel;
int notRepliedCount = 0; int notRepliedCount = 0;
Future getDoctorReply() async { Future getDoctorReply(RequestDoctorReply _requestDoctorReply,{bool clearData = false}) async {
hasError = false; hasError = false;
await baseAppClient.post(GT_MY_PATIENT_QUESTION, await baseAppClient.post(GT_MY_PATIENT_QUESTION,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
if(clearData)
_listDoctorWorkingHoursTable.clear(); _listDoctorWorkingHoursTable.clear();
response['List_GtMyPatientsQuestions'].forEach((v) { response['List_GtMyPatientsQuestions'].forEach((v) {
_listDoctorWorkingHoursTable _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/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/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_create_doctor_response.dart';
import 'package:doctor_app_flutter/models/doctor/replay/request_doctor_reply.dart';
import '../../locator.dart'; import '../../locator.dart';
import 'base_view_model.dart'; import 'base_view_model.dart';
@ -12,13 +13,25 @@ class DoctorReplayViewModel extends BaseViewModel {
List<ListGtMyPatientsQuestions> get listDoctorWorkingHoursTable => List<ListGtMyPatientsQuestions> get listDoctorWorkingHoursTable =>
_doctorReplyService.listDoctorWorkingHoursTable; _doctorReplyService.listDoctorWorkingHoursTable;
Future getDoctorReply() async { Future getDoctorReply(
setState(ViewState.Busy); {int pageSize = 10, int pageIndex = 1, bool isLocalBusy = true}) async {
if (isLocalBusy) {
setState(ViewState.BusyLocal);
} else {
setState(ViewState.Busy);
}
await getDoctorProfile(); await getDoctorProfile();
await _doctorReplyService.getDoctorReply(); RequestDoctorReply _requestDoctorReply =
RequestDoctorReply(pageIndex: pageIndex, pageSize: pageSize);
await _doctorReplyService.getDoctorReply(_requestDoctorReply, clearData:!isLocalBusy );
if (_doctorReplyService.hasError) { if (_doctorReplyService.hasError) {
error = _doctorReplyService.error; error = _doctorReplyService.error;
setState(ViewState.Error); if (isLocalBusy) {
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Error);
}
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
} }
@ -28,13 +41,12 @@ class DoctorReplayViewModel extends BaseViewModel {
await getDoctorProfile(); await getDoctorProfile();
CreateDoctorResponseModel createDoctorResponseModel = CreateDoctorResponseModel createDoctorResponseModel =
CreateDoctorResponseModel( CreateDoctorResponseModel(
transactionNo: model.transactionNo.toString(), transactionNo: model.transactionNo.toString(),
doctorResponse: response, doctorResponse: response,
infoStatus: 6, infoStatus: 6,
createdBy:this.doctorProfile.doctorID, createdBy: this.doctorProfile.doctorID,
infoEnteredBy: this.doctorProfile.doctorID, infoEnteredBy: this.doctorProfile.doctorID,
setupID:"010266" setupID: "010266");
);
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
await _doctorReplyService.createDoctorResponse(createDoctorResponseModel); await _doctorReplyService.createDoctorResponse(createDoctorResponseModel);
if (_doctorReplyService.hasError) { if (_doctorReplyService.hasError) {
@ -43,7 +55,6 @@ class DoctorReplayViewModel extends BaseViewModel {
} else { } else {
setState(ViewState.Idle); setState(ViewState.Idle);
_doctorReplyService.getNotRepliedCount(); _doctorReplyService.getNotRepliedCount();
} }
} }
} }

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

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

@ -1,10 +1,16 @@
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/core/viewModel/doctor_replay_view_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.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/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/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/doctor/doctor_reply_widget.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_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -15,21 +21,27 @@ import 'package:flutter/material.dart';
*@return: *@return:
*@desc: Doctor Reply Screen display data from GtMyPatientsQuestions service *@desc: Doctor Reply Screen display data from GtMyPatientsQuestions service
*/ */
class DoctorReplyScreen extends StatelessWidget { class DoctorReplyScreen extends StatefulWidget {
final Function changeCurrentTab; final Function changeCurrentTab;
const DoctorReplyScreen({Key key, this.changeCurrentTab}) : super(key: key); const DoctorReplyScreen({Key key, this.changeCurrentTab}) : super(key: key);
@override
_DoctorReplyScreenState createState() => _DoctorReplyScreenState();
}
class _DoctorReplyScreenState extends State<DoctorReplyScreen> {
int pageIndex = 1;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<DoctorReplayViewModel>( return BaseView<DoctorReplayViewModel>(
onModelReady: (model) { onModelReady: (model) {
model.getDoctorReply(); model.getDoctorReply(isLocalBusy: false);
}, },
builder: (_, model, w) => WillPopScope( builder: (_, model, w) => WillPopScope(
onWillPop: ()async{ onWillPop: () async {
changeCurrentTab(); widget.changeCurrentTab();
return false; return false;
}, },
child: AppScaffold( child: AppScaffold(
@ -38,36 +50,63 @@ class DoctorReplyScreen extends StatelessWidget {
isShowAppBar: false, isShowAppBar: false,
body: model.listDoctorWorkingHoursTable.isEmpty body: model.listDoctorWorkingHoursTable.isEmpty
? DrAppEmbeddedError(error: TranslationBase.of(context).noItem) ? DrAppEmbeddedError(error: TranslationBase.of(context).noItem)
: Container( : Column(
padding: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0), children: [
child: ListView( Expanded(
children: [ child: Container(
Column( padding: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0),
crossAxisAlignment: CrossAxisAlignment.start, child: NotificationListener(
mainAxisAlignment: MainAxisAlignment.spaceBetween, child: ListView.builder(
children: scrollDirection: Axis.vertical,
model.listDoctorWorkingHoursTable.map((reply) { shrinkWrap: true,
return InkWell(
onTap: () { itemBuilder: (BuildContext ctxt, int index) {
Navigator.push( return Column(
context, children: [
MaterialPageRoute( InkWell(
builder: (BuildContext context) => onTap: () {
DoctorReplayChat( Navigator.push(
reply: reply, context,
previousModel: model, MaterialPageRoute(
), settings: RouteSettings(name: 'DoctorReplayChat'),)); builder: (BuildContext context) =>
}, DoctorReplayChat(
child: DoctorReplyWidget(reply: reply), reply:
); model.listDoctorWorkingHoursTable[
}).toList(), index],
) previousModel: model,
], ),
settings: RouteSettings(
name: 'DoctorReplayChat'),
));
},
child: DoctorReplyWidget(
reply: model
.listDoctorWorkingHoursTable[index]),
),
if(model.state == ViewState.BusyLocal &&index ==model.listDoctorWorkingHoursTable.length-1)
DrAppCircularProgressIndeicator()
],
);
}),
onNotification: (t) {
if (t is ScrollEndNotification &&
model.state != ViewState.BusyLocal) {
print("${model.state}");
setState(() {
pageIndex++;
});
model.getDoctorReply(pageIndex: pageIndex);
}
return;
},
),
),
), ),
), ],
),
), ),
), ),
); );
} }
} }

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

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

Loading…
Cancel
Save