fixed pagination
This commit is contained in:
@@ -24,6 +24,7 @@ class _MobileNotificationPageState extends State<MobileNotificationPage>
|
||||
|
||||
final ScrollController _scrollAll = ScrollController();
|
||||
final ScrollController _scrollUnread = ScrollController();
|
||||
final ScrollController _scrollImportant = ScrollController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -55,6 +56,18 @@ class _MobileNotificationPageState extends State<MobileNotificationPage>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
_scrollImportant.addListener(() {
|
||||
if (_scrollImportant.position.pixels >=
|
||||
_scrollImportant.position.maxScrollExtent - 100 &&
|
||||
!viewModel.isLoadingImportant &&
|
||||
viewModel.hasMoreImportant) {
|
||||
viewModel.getImportantNotifications(
|
||||
page: viewModel.currentPageImportant + 1,
|
||||
isPagination: true,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -62,6 +75,7 @@ class _MobileNotificationPageState extends State<MobileNotificationPage>
|
||||
controller.dispose();
|
||||
_scrollAll.dispose();
|
||||
_scrollUnread.dispose();
|
||||
_scrollImportant.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -83,45 +97,13 @@ class _MobileNotificationPageState extends State<MobileNotificationPage>
|
||||
],
|
||||
),
|
||||
SizedBox(height: 12.0.h()),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.only(end: 24.0.w()),
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
viewModel.markAllAsRead(context);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
child: Container(
|
||||
width: 132.0.w(),
|
||||
height: 32.0.h(),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primary20,
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
NotificationStrings.markAllAsReadButton,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.mainBlue,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 12.0.h()),
|
||||
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: controller,
|
||||
children: [
|
||||
NotificationAllTab(scrollController: _scrollAll),
|
||||
NotificationUnreadTab(scrollController: _scrollUnread),
|
||||
const NotificationImportantTab(),
|
||||
NotificationImportantTab(scrollController: _scrollImportant),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -142,11 +124,9 @@ class _MobileNotificationPageState extends State<MobileNotificationPage>
|
||||
),
|
||||
),
|
||||
|
||||
if ((viewModel.isLoadingAll &&
|
||||
(viewModel.allNotificationResponse?.data?.isEmpty ?? true)) ||
|
||||
(viewModel.isLoadingUnread &&
|
||||
(viewModel.unreadNotificationResponse?.data?.isEmpty ?? true)))
|
||||
const Expanded(
|
||||
if (viewModel.isMoreLoadingImportant)
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(color: AppColors.secondary50),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user