Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- part of 'notification_page.dart';
- class CommentsContentView extends StatelessWidget {
- const CommentsContentView({
- Key? key,
- this.notif,
- }) : super(key: key);
- final NotifComment? notif;
- @override
- Widget build(BuildContext context) {
- debugPrint('Build: $runtimeType');
- final _lang = LangUtil.of(context);
- final _refreshController = RefreshController(initialRefresh: false);
- Future<void> _onHide(int index) async {
- final result = await showOkCancelAlertDialog(
- context: context,
- title: _lang.trans('global_confirm_delete_header'),
- message: _lang.trans('global_confirm_delete'),
- okLabel: _lang.trans('global_ok'),
- cancelLabel: _lang.trans('global_cancel'),
- );
- debugPrint(result.toString());
- if (result.toString() == 'OkCancelResult.ok') {
- getIt<ContentCommentBloc>().add(
- ContentCommentSaveEv(
- moduleId: notif!.data[index].moduleId,
- hideInNotif: '1',
- id: notif!.data[index].id,
- ),
- );
- debugPrint('OkCancelResult.ok');
- Future.delayed(const Duration(seconds: 2), () {
- context.read<UserNotificationCubit>().fetchUserNotification();
- });
- }
- }
- if (notif != null && notif!.data.isEmpty) {
- return PullRefreshWidget(
- controller: _refreshController,
- onRefresh: () {
- context.read<UserNotificationCubit>().fetchUserNotification();
- _refreshController.refreshCompleted();
- },
- child: const InfoWidgetNoData());
- } else {
- if (notif != null) {
- return PullRefreshWidget(
- controller: _refreshController,
- onRefresh: () {
- context.read<UserNotificationCubit>().fetchUserNotification();
- _refreshController.refreshCompleted();
- },
- child: ListView.builder(
- itemBuilder: (BuildContext context, int index) {
- _refreshController.refreshCompleted();
- return ContentWidgetNotif(
- title: notif!.data[index].title,
- message: notif!.data[index].message,
- widgetMessage: notif!.data[index].parentData != null
- ? Dismissible(
- direction: DismissDirection.endToStart,
- key: Key(notif!.data[index].id),
- background: ContainerWidgetSlideBackgroud(
- title: _lang.trans('global_delete'),
- iconData: Icons.delete,
- color: Colors.red,
- ),
- onDismissed: (direction) {
- debugPrint('onDismissed');
- },
- confirmDismiss: (direction) async {
- if (direction == DismissDirection.endToStart) {
- await _onHide(index);
- }
- },
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Expanded(
- child: ContainerWidgetBox(
- color: Colors.transparent,
- boxBorder: Border.all(
- color: Colors.grey.shade300,
- width: 0.5.r,
- style: BorderStyle.solid,
- ),
- padding: 5.r,
- child: Column(
- children: [
- CommentWidgetList2(
- authorName: notif!
- .data[index].parentData!.authorName,
- authorAvatarUrl: notif!.data[index]
- .parentData!.authorAvatarUrl,
- dateTime: notif!
- .data[index].parentData!.datetime,
- comment: notif!
- .data[index].parentData!.comment,
- avatarSize: 'small',
- bgColor:
- Theme.of(context).backgroundColor,
- ),
- CommentWidgetList2(
- authorName: notif!.data[index].authorName,
- authorAvatarUrl:
- notif!.data[index].authorAvatarUrl,
- dateTime:
- notif!.data[index].createdDatetime!,
- comment: notif!.data[index].message,
- avatarSize: 'small',
- ),
- ],
- ),
- ),
- ),
- SpaceWidgetWidth(width: 5.r),
- if (notif!.data[index].notif == '1') ...[
- Icon(
- Icons.circle,
- size: 7.sp,
- color: Colors.blue,
- ),
- ] else ...[
- SpaceWidgetWidth(width: 5.r),
- ]
- ],
- ),
- )
- : Dismissible(
- direction: DismissDirection.endToStart,
- key: Key(notif!.data[index].id),
- background: ContainerWidgetSlideBackgroud(
- title: _lang.trans('global_delete'),
- iconData: Icons.delete,
- color: Colors.red,
- ),
- onDismissed: (direction) {
- debugPrint('onDismissed');
- },
- confirmDismiss: (direction) async {
- if (direction == DismissDirection.endToStart) {
- await _onHide(index);
- }
- },
- child: Container(
- padding: EdgeInsets.only(left: 5.r, right: 5.r),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Expanded(
- child: CommentWidgetList2(
- authorName: notif!.data[index].authorName,
- authorAvatarUrl:
- notif!.data[index].authorAvatarUrl,
- dateTime: notif!.data[index].createdDatetime!,
- comment: notif!.data[index].message,
- avatarSize: 'small',
- ),
- ),
- SpaceWidgetWidth(width: 5.r),
- if (notif!.data[index].notif == '1') ...[
- Icon(
- Icons.circle,
- size: 7.sp,
- color: Colors.blue,
- ),
- ] else ...[
- SpaceWidgetWidth(width: 5.r),
- ]
- ],
- ),
- ),
- ),
- datetime: notif!.data[index].createdDatetime!,
- onTitleTap: () {
- if (notif!.data[index].module ==
- 'content_articles_posts_new') {
- nextScreenPopupUtil(
- context,
- ContentPostCommentPage(
- module: notif!.data[index].module,
- moduleId: notif!.data[index].moduleId,
- moduleTitle: notif!.data[index].moduleTitle,
- moduleAuthorName: notif!.data[index].moduleAuthorName,
- moduleAuthorAvatarUrl:
- notif!.data[index].moduleAuthorAvatarUrl,
- moduleAuthorId: notif!.data[index].moduleAuthorId,
- moduleTotalLike: notif!.data[index].moduleTotalLike,
- moduleTotalComment:
- notif!.data[index].moduleTotalComment,
- ),
- );
- }
- },
- onMessageTap: () async {
- if (notif!.data[index].module ==
- 'content_articles_posts_new') {
- if (notif!.data[index].notif == '1') {
- debugPrint('notifs: ${notif!.data[index].notif}');
- getIt<ContentCommentBloc>().add(
- ContentCommentSaveEv(
- moduleId: notif!.data[index].moduleId,
- isNotif: '0',
- id: notif!.data[index].id,
- ),
- );
- }
- if (notif!.data[index].parentData != null) {
- nextScreenUtil(
- context,
- ContentPostCommentPage(
- module: notif!.data[index].module,
- moduleId: notif!.data[index].moduleId,
- moduleTitle: notif!.data[index].moduleTitle,
- moduleAuthorName: notif!.data[index].moduleAuthorName,
- moduleAuthorAvatarUrl:
- notif!.data[index].moduleAuthorAvatarUrl,
- moduleAuthorId: notif!.data[index].moduleAuthorId,
- moduleTotalLike: notif!.data[index].moduleTotalLike,
- moduleTotalComment:
- notif!.data[index].moduleTotalComment,
- redirectReply: () {
- nextScreenUtil(
- context,
- ContentPostCommentPage(
- module: notif!.data[index].module,
- moduleId: notif!.data[index].moduleId,
- moduleTitle: notif!.data[index].moduleTitle,
- moduleAuthorName:
- notif!.data[index].moduleAuthorName,
- moduleAuthorAvatarUrl:
- notif!.data[index].moduleAuthorAvatarUrl,
- moduleAuthorId:
- notif!.data[index].moduleAuthorId,
- moduleTotalLike:
- notif!.data[index].moduleTotalLike,
- moduleTotalComment:
- notif!.data[index].moduleTotalComment,
- parentData: notif!.data[index].parentData,
- ),
- );
- },
- ),
- ).then((value) {
- if (notif!.data[index].notif == '1') {
- debugPrint(
- 'refresh notifs: ${notif!.data[index].notif}');
- context
- .read<UserNotificationCubit>()
- .fetchUserNotification();
- }
- });
- } else {
- nextScreenUtil(
- context,
- ContentPostCommentPage(
- module: notif!.data[index].module,
- moduleId: notif!.data[index].moduleId,
- moduleTitle: notif!.data[index].moduleTitle,
- moduleAuthorName: notif!.data[index].moduleAuthorName,
- moduleAuthorAvatarUrl:
- notif!.data[index].moduleAuthorAvatarUrl,
- moduleAuthorId: notif!.data[index].moduleAuthorId,
- moduleTotalLike: notif!.data[index].moduleTotalLike,
- moduleTotalComment:
- notif!.data[index].moduleTotalComment,
- ),
- ).then((value) {
- if (notif!.data[index].notif == '1') {
- debugPrint(
- 'refresh notifs: ${notif!.data[index].notif}');
- context
- .read<UserNotificationCubit>()
- .fetchUserNotification();
- }
- });
- }
- }
- },
- );
- },
- itemCount: notif!.data.length,
- ),
- );
- }
- return const SizedBox();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement