modify pagination to make works on scroll

merge-requests/798/head
Elham Rababh 5 years ago
parent 943463b1d9
commit 64c98ba128

@ -8,6 +8,7 @@ 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/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:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@ -49,57 +50,61 @@ class _DoctorReplyScreenState extends State<DoctorReplyScreen> {
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: model.listDoctorWorkingHoursTable.map( scrollDirection: Axis.vertical,
(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(
builder: (BuildContext context) =>
DoctorReplayChat(
reply:
model.listDoctorWorkingHoursTable[
index],
previousModel: model,
),
settings: RouteSettings(
name: 'DoctorReplayChat'),
));
},
child: DoctorReplyWidget(
reply: model
.listDoctorWorkingHoursTable[index]),
), ),
settings: if(model.state == ViewState.BusyLocal &&index ==model.listDoctorWorkingHoursTable.length-1)
RouteSettings(name: 'DoctorReplayChat'), DrAppCircularProgressIndeicator()
));
}, ],
child: DoctorReplyWidget(reply: reply), );
); }),
}).toList() onNotification: (t) {
..add(InkWell( if (t is ScrollEndNotification &&
onTap: () async { model.state != ViewState.BusyLocal) {
print("${model.state}");
setState(() { setState(() {
pageIndex++; pageIndex++;
}); });
GifLoaderDialogUtils.showMyDialog(context); model.getDoctorReply(pageIndex: pageIndex);
await model.getDoctorReply(pageIndex: pageIndex); }
if (model.state == ViewState.ErrorLocal) { return;
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,),
),
),
)),
)
],
), ),
), ],
),
), ),
), ),
); );

Loading…
Cancel
Save