|
|
|
@ -17,16 +17,37 @@ import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class NotificationsListPage extends StatelessWidget {
|
|
|
|
class NotificationsListPage extends StatefulWidget {
|
|
|
|
const NotificationsListPage({super.key});
|
|
|
|
const NotificationsListPage({super.key});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
State<NotificationsListPage> createState() => _NotificationsListPageState();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _NotificationsListPageState extends State<NotificationsListPage> {
|
|
|
|
|
|
|
|
final GlobalKey _bottomKey = GlobalKey();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _scrollToBottom() {
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
|
|
|
final ctx = _bottomKey.currentContext;
|
|
|
|
|
|
|
|
if (ctx != null) {
|
|
|
|
|
|
|
|
Scrollable.ensureVisible(
|
|
|
|
|
|
|
|
ctx,
|
|
|
|
|
|
|
|
duration: const Duration(milliseconds: 400),
|
|
|
|
|
|
|
|
curve: Curves.easeOut,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return CollapsingListView(
|
|
|
|
return CollapsingListView(
|
|
|
|
title: LocaleKeys.notification.tr(context: context),
|
|
|
|
title: LocaleKeys.notification.tr(context: context),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
|
|
|
child: Consumer<NotificationsViewModel>(builder: (context, notificationsVM, child) {
|
|
|
|
child: Consumer<NotificationsViewModel>(builder: (context, notificationsVM, child) {
|
|
|
|
return Container(
|
|
|
|
return Column(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 24.h),
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 24.h),
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
|
|
|
color: AppColors.whiteColor,
|
|
|
|
color: AppColors.whiteColor,
|
|
|
|
@ -34,19 +55,22 @@ class NotificationsListPage extends StatelessWidget {
|
|
|
|
hasShadow: false,
|
|
|
|
hasShadow: false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: ListView.builder(
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: notificationsVM.isNotificationsLoading ? 4 : notificationsVM.notificationsList.length,
|
|
|
|
itemCount: notificationsVM.isNotificationsLoading
|
|
|
|
|
|
|
|
? 4
|
|
|
|
|
|
|
|
: notificationsVM.notificationsList.length + (notificationsVM.hasMoreNotifications ? 1 : 0),
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
shrinkWrap: true,
|
|
|
|
shrinkWrap: true,
|
|
|
|
padding: EdgeInsetsGeometry.zero,
|
|
|
|
padding: EdgeInsetsGeometry.zero,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return notificationsVM.isNotificationsLoading
|
|
|
|
if (notificationsVM.isNotificationsLoading) {
|
|
|
|
? LabResultItemView(
|
|
|
|
return LabResultItemView(
|
|
|
|
onTap: () {},
|
|
|
|
onTap: () {},
|
|
|
|
labOrder: null,
|
|
|
|
labOrder: null,
|
|
|
|
index: index,
|
|
|
|
index: index,
|
|
|
|
isLoading: true,
|
|
|
|
isLoading: true,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
: AnimationConfiguration.staggeredList(
|
|
|
|
}
|
|
|
|
|
|
|
|
return AnimationConfiguration.staggeredList(
|
|
|
|
position: index,
|
|
|
|
position: index,
|
|
|
|
duration: const Duration(milliseconds: 500),
|
|
|
|
duration: const Duration(milliseconds: 500),
|
|
|
|
child: SlideAnimation(
|
|
|
|
child: SlideAnimation(
|
|
|
|
@ -187,9 +211,23 @@ class NotificationsListPage extends StatelessWidget {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}).paddingSymmetrical(16.w, 0.h),
|
|
|
|
}).paddingSymmetrical(16.w, 0.h),
|
|
|
|
).paddingSymmetrical(24.w, 0.h);
|
|
|
|
).paddingSymmetrical(24.w, 0.h),
|
|
|
|
|
|
|
|
SizedBox(height: 16.h),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
key: _bottomKey,
|
|
|
|
|
|
|
|
child: "Show more notifications".toText16(
|
|
|
|
|
|
|
|
color: AppColors.primaryRedColor,
|
|
|
|
|
|
|
|
isBold: true,
|
|
|
|
|
|
|
|
isUnderLine: true
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
).onPress(() async {
|
|
|
|
|
|
|
|
await notificationsVM.loadMoreNotifications();
|
|
|
|
|
|
|
|
_scrollToBottom();
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
SizedBox(height: 24.h),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|