This repository has been archived by the owner on Feb 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ add post & comment mention notification tiles
- Loading branch information
1 parent
4cf7b1b
commit 99cd4ce
Showing
5 changed files
with
199 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
lib/widgets/tiles/notification_tile/widgets/post_comment_user_mention_notification_tile.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import 'package:Okuna/models/notifications/notification.dart'; | ||
import 'package:Okuna/models/notifications/post_comment_user_mention_notification.dart'; | ||
import 'package:Okuna/models/post.dart'; | ||
import 'package:Okuna/models/post_comment.dart'; | ||
import 'package:Okuna/models/post_comment_user_mention.dart'; | ||
import 'package:Okuna/provider.dart'; | ||
import 'package:Okuna/services/localization.dart'; | ||
import 'package:Okuna/widgets/avatars/avatar.dart'; | ||
import 'package:Okuna/widgets/theming/actionable_smart_text.dart'; | ||
import 'package:Okuna/widgets/theming/secondary_text.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_advanced_networkimage/provider.dart'; | ||
|
||
import 'notification_tile_skeleton.dart'; | ||
import 'notification_tile_title.dart'; | ||
|
||
class OBPostCommentUserMentionNotificationTile extends StatelessWidget { | ||
final OBNotification notification; | ||
final PostCommentUserMentionNotification postCommentUserMentionNotification; | ||
static final double postCommentImagePreviewSize = 40; | ||
final VoidCallback onPressed; | ||
|
||
const OBPostCommentUserMentionNotificationTile( | ||
{Key key, | ||
@required this.notification, | ||
@required this.postCommentUserMentionNotification, | ||
this.onPressed}) | ||
: super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
PostCommentUserMention postCommentUserMention = | ||
postCommentUserMentionNotification.postCommentUserMention; | ||
PostComment postComment = postCommentUserMention.postComment; | ||
Post post = postComment.post; | ||
|
||
Widget postCommentImagePreview; | ||
if (post.hasImage()) { | ||
postCommentImagePreview = ClipRRect( | ||
borderRadius: BorderRadius.circular(8.0), | ||
child: Image( | ||
image: AdvancedNetworkImage(post.getImage(), useDiskCache: true), | ||
height: postCommentImagePreviewSize, | ||
width: postCommentImagePreviewSize, | ||
fit: BoxFit.cover, | ||
), | ||
); | ||
} | ||
OpenbookProviderState openbookProvider = OpenbookProvider.of(context); | ||
var utilsService = openbookProvider.utilsService; | ||
|
||
Function navigateToMentionerProfile = () { | ||
openbookProvider.navigationService.navigateToUserProfile( | ||
user: postCommentUserMention.postComment.commenter, context: context); | ||
}; | ||
LocalizationService _localizationService = openbookProvider.localizationService; | ||
|
||
return OBNotificationTileSkeleton( | ||
onTap: () { | ||
if (onPressed != null) onPressed(); | ||
OpenbookProviderState openbookProvider = OpenbookProvider.of(context); | ||
|
||
PostComment parentComment = postComment.parentComment; | ||
if(parentComment!=null){ | ||
openbookProvider.navigationService.navigateToPostCommentRepliesLinked( | ||
postComment: postComment, | ||
context: context, | ||
parentComment: parentComment); | ||
}else { | ||
openbookProvider.navigationService.navigateToPostCommentsLinked( | ||
postComment: postComment, context: context); | ||
} | ||
}, | ||
leading: OBAvatar( | ||
onPressed: navigateToMentionerProfile, | ||
size: OBAvatarSize.medium, | ||
avatarUrl: postCommentUserMention.postComment.commenter.getProfileAvatar(), | ||
), | ||
title: OBNotificationTileTitle( | ||
text: TextSpan(text: _localizationService.notifications__mentioned_in_post_comment_tile), | ||
onUsernamePressed: navigateToMentionerProfile, | ||
user: postCommentUserMention.postComment.commenter, | ||
), | ||
subtitle: OBSecondaryText( | ||
utilsService.timeAgo(notification.created), | ||
size: OBTextSize.small, | ||
), | ||
); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
lib/widgets/tiles/notification_tile/widgets/post_user_mention_notification_tile.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import 'package:Okuna/models/notifications/notification.dart'; | ||
import 'package:Okuna/models/notifications/post_user_mention_notification.dart'; | ||
import 'package:Okuna/models/post.dart'; | ||
import 'package:Okuna/models/post_user_mention.dart'; | ||
import 'package:Okuna/provider.dart'; | ||
import 'package:Okuna/services/localization.dart'; | ||
import 'package:Okuna/widgets/avatars/avatar.dart'; | ||
import 'package:Okuna/widgets/theming/actionable_smart_text.dart'; | ||
import 'package:Okuna/widgets/theming/secondary_text.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_advanced_networkimage/provider.dart'; | ||
|
||
import 'notification_tile_skeleton.dart'; | ||
import 'notification_tile_title.dart'; | ||
|
||
class OBPostUserMentionNotificationTile extends StatelessWidget { | ||
final OBNotification notification; | ||
final PostUserMentionNotification postUserMentionNotification; | ||
static final double postImagePreviewSize = 40; | ||
final VoidCallback onPressed; | ||
|
||
const OBPostUserMentionNotificationTile( | ||
{Key key, | ||
@required this.notification, | ||
@required this.postUserMentionNotification, | ||
this.onPressed}) | ||
: super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
PostUserMention postUserMention = | ||
postUserMentionNotification.postUserMention; | ||
Post post = postUserMention.post; | ||
|
||
Widget postImagePreview; | ||
if (post.hasImage()) { | ||
postImagePreview = ClipRRect( | ||
borderRadius: BorderRadius.circular(8.0), | ||
child: Image( | ||
image: AdvancedNetworkImage(post.getImage(), useDiskCache: true), | ||
height: postImagePreviewSize, | ||
width: postImagePreviewSize, | ||
fit: BoxFit.cover, | ||
), | ||
); | ||
} | ||
OpenbookProviderState openbookProvider = OpenbookProvider.of(context); | ||
var utilsService = openbookProvider.utilsService; | ||
|
||
Function navigateToMentionerProfile = () { | ||
openbookProvider.navigationService.navigateToUserProfile( | ||
user: postUserMention.post.creator, context: context); | ||
}; | ||
LocalizationService _localizationService = openbookProvider.localizationService; | ||
|
||
return OBNotificationTileSkeleton( | ||
onTap: () { | ||
if (onPressed != null) onPressed(); | ||
OpenbookProviderState openbookProvider = OpenbookProvider.of(context); | ||
openbookProvider.navigationService | ||
.navigateToPost(post: postUserMention.post, context: context); | ||
}, | ||
leading: OBAvatar( | ||
onPressed: navigateToMentionerProfile, | ||
size: OBAvatarSize.medium, | ||
avatarUrl: postUserMention.post.creator.getProfileAvatar(), | ||
), | ||
title: OBNotificationTileTitle( | ||
text: TextSpan(text: _localizationService.notifications__mentioned_in_post_tile), | ||
onUsernamePressed: navigateToMentionerProfile, | ||
user: postUserMention.post.creator, | ||
), | ||
subtitle: OBSecondaryText( | ||
utilsService.timeAgo(notification.created), | ||
size: OBTextSize.small, | ||
), | ||
); | ||
} | ||
} |