From b0c0d41b72de8ac7273b45c2a5492f00275819b0 Mon Sep 17 00:00:00 2001 From: Eric Andrews Date: Sat, 30 Sep 2023 12:11:44 -0400 Subject: [PATCH] Added updated time display (#678) --- Mlem.xcodeproj/project.pbxproj | 16 ++++++++----- Mlem/Icons.swift | 4 +++- Mlem/Models/Content/Post Model.swift | 6 ++++- .../Views/Shared/Accounts/Accounts Page.swift | 2 +- .../Shared/Comments/Comment Item Logic.swift | 18 +++++++------- Mlem/Views/Shared/Comments/Comment Item.swift | 1 + .../Comments/Components/CommentBodyView.swift | 6 ++++- .../Components/Components/InfoStackView.swift | 7 ++++-- .../Components/InteractionBarView.swift | 2 ++ Mlem/Views/Shared/Posts/Expanded Post.swift | 2 ++ .../Shared/Posts/ExpandedPostLogic.swift | 18 +++++++------- Mlem/Views/Shared/Posts/Feed Post.swift | 15 ++++++------ .../Posts/Post Sizes/Compact Post.swift | 1 + ...iew.swift => PublishedTimestampView.swift} | 2 +- Mlem/Views/Shared/UpdatedTimestampView.swift | 24 +++++++++++++++++++ .../Feed/Item Types/Inbox Mention View.swift | 2 +- .../Feed/Item Types/Inbox Message View.swift | 2 +- .../Feed/Item Types/Inbox Reply View.swift | 2 +- 18 files changed, 91 insertions(+), 39 deletions(-) rename Mlem/Views/Shared/{TimestampView.swift => PublishedTimestampView.swift} (93%) create mode 100644 Mlem/Views/Shared/UpdatedTimestampView.swift diff --git a/Mlem.xcodeproj/project.pbxproj b/Mlem.xcodeproj/project.pbxproj index 30971fcd5..27fb7495e 100644 --- a/Mlem.xcodeproj/project.pbxproj +++ b/Mlem.xcodeproj/project.pbxproj @@ -30,7 +30,7 @@ 03A1B3F72A84000400AB0DE0 /* APIContentAggregatesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A1B3F62A84000400AB0DE0 /* APIContentAggregatesProtocol.swift */; }; 03A1B3F92A8400DD00AB0DE0 /* APIContentViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A1B3F82A8400DD00AB0DE0 /* APIContentViewProtocol.swift */; }; 03B643572A6864CD00F65700 /* TabBarSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03B643562A6864CD00F65700 /* TabBarSettingsView.swift */; }; - 03BAA23A2A57DC1400D48252 /* TimestampView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BAA2392A57DC1400D48252 /* TimestampView.swift */; }; + 03BAA23A2A57DC1400D48252 /* PublishedTimestampView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BAA2392A57DC1400D48252 /* PublishedTimestampView.swift */; }; 03CB329E2A6D8E910021EF27 /* PostDetailEditorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03CB329D2A6D8E910021EF27 /* PostDetailEditorView.swift */; }; 03E0B9C82A61F0F400FED265 /* AdvancedSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E0B9C72A61F0F400FED265 /* AdvancedSettingsView.swift */; }; 03E0B9CA2A62B4A400FED265 /* ContributorsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E0B9C92A62B4A400FED265 /* ContributorsView.swift */; }; @@ -300,6 +300,7 @@ CD18DC6B2A5202D4002C56BC /* MarkPersonMentionAsReadRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD18DC6A2A5202D4002C56BC /* MarkPersonMentionAsReadRequest.swift */; }; CD18DC6F2A5209C3002C56BC /* MarkPrivateMessageAsReadRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD18DC6E2A5209C3002C56BC /* MarkPrivateMessageAsReadRequest.swift */; }; CD18DC732A522A7C002C56BC /* CreatePrivateMessageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD18DC722A522A7C002C56BC /* CreatePrivateMessageRequest.swift */; }; + CD2053102AC878B50000AA38 /* UpdatedTimestampView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD20530F2AC878B50000AA38 /* UpdatedTimestampView.swift */; }; CD2BD6782A79F55800ECFF89 /* ImageSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD2BD6772A79F55800ECFF89 /* ImageSize.swift */; }; CD2E182B2A3B708500224F8A /* Settings Options.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD2E182A2A3B708500224F8A /* Settings Options.swift */; }; CD309C462A93FBD300988F95 /* Logo View.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD309C452A93FBD300988F95 /* Logo View.swift */; }; @@ -436,8 +437,8 @@ E4D4DBA22A7F233200C4F3DE /* FancyTabNavigationSelectionHashValueEnvironmentKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4D4DBA12A7F233200C4F3DE /* FancyTabNavigationSelectionHashValueEnvironmentKey.swift */; }; E4DDB4322A81819300B3A7E0 /* Double.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4DDB4312A81819300B3A7E0 /* Double.swift */; }; E4DDB4342A819C8000B3A7E0 /* QuickLookView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4DDB4332A819C8000B3A7E0 /* QuickLookView.swift */; }; - E4F0B5722AC2581800BC3E4A /* RoutableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4F0B5712AC2581800BC3E4A /* RoutableTests.swift */; }; E4F0B56F2ABD00A000BC3E4A /* PresentationBackgroundInteraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4F0B56E2ABD00A000BC3E4A /* PresentationBackgroundInteraction.swift */; }; + E4F0B5722AC2581800BC3E4A /* RoutableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4F0B5712AC2581800BC3E4A /* RoutableTests.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -481,7 +482,7 @@ 03A1B3F62A84000400AB0DE0 /* APIContentAggregatesProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIContentAggregatesProtocol.swift; sourceTree = ""; }; 03A1B3F82A8400DD00AB0DE0 /* APIContentViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIContentViewProtocol.swift; sourceTree = ""; }; 03B643562A6864CD00F65700 /* TabBarSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarSettingsView.swift; sourceTree = ""; }; - 03BAA2392A57DC1400D48252 /* TimestampView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimestampView.swift; sourceTree = ""; }; + 03BAA2392A57DC1400D48252 /* PublishedTimestampView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishedTimestampView.swift; sourceTree = ""; }; 03CB329D2A6D8E910021EF27 /* PostDetailEditorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostDetailEditorView.swift; sourceTree = ""; }; 03E0B9C72A61F0F400FED265 /* AdvancedSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedSettingsView.swift; sourceTree = ""; }; 03E0B9C92A62B4A400FED265 /* ContributorsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContributorsView.swift; sourceTree = ""; }; @@ -749,6 +750,7 @@ CD18DC6A2A5202D4002C56BC /* MarkPersonMentionAsReadRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkPersonMentionAsReadRequest.swift; sourceTree = ""; }; CD18DC6E2A5209C3002C56BC /* MarkPrivateMessageAsReadRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkPrivateMessageAsReadRequest.swift; sourceTree = ""; }; CD18DC722A522A7C002C56BC /* CreatePrivateMessageRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreatePrivateMessageRequest.swift; sourceTree = ""; }; + CD20530F2AC878B50000AA38 /* UpdatedTimestampView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdatedTimestampView.swift; sourceTree = ""; }; CD2BD6772A79F55800ECFF89 /* ImageSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageSize.swift; sourceTree = ""; }; CD2E182A2A3B708500224F8A /* Settings Options.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Settings Options.swift"; sourceTree = ""; }; CD309C452A93FBD300988F95 /* Logo View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logo View.swift"; sourceTree = ""; }; @@ -885,8 +887,8 @@ E4D4DBA12A7F233200C4F3DE /* FancyTabNavigationSelectionHashValueEnvironmentKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FancyTabNavigationSelectionHashValueEnvironmentKey.swift; sourceTree = ""; }; E4DDB4312A81819300B3A7E0 /* Double.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Double.swift; sourceTree = ""; }; E4DDB4332A819C8000B3A7E0 /* QuickLookView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickLookView.swift; sourceTree = ""; }; - E4F0B5712AC2581800BC3E4A /* RoutableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoutableTests.swift; sourceTree = ""; }; E4F0B56E2ABD00A000BC3E4A /* PresentationBackgroundInteraction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentationBackgroundInteraction.swift; sourceTree = ""; }; + E4F0B5712AC2581800BC3E4A /* RoutableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoutableTests.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1791,11 +1793,12 @@ 6322A5CA27F77A4D00135D4F /* Loading View.swift */, 6386E03F2A045723006B3C1D /* Website Icon Complex.swift */, 63D24EDD2A169F2A005CCA81 /* Markdown View.swift */, - 03BAA2392A57DC1400D48252 /* TimestampView.swift */, + 03BAA2392A57DC1400D48252 /* PublishedTimestampView.swift */, 6374570F2A18CB6600B69C03 /* Custom Text Field.swift */, B11D72822A49FAA7009DC22F /* Cached Image.swift */, 50F2851B2A5C5C1500CF8865 /* TokenRefreshView.swift */, CD863FBB2A6B026400A31ED9 /* DocumentView.swift */, + CD20530F2AC878B50000AA38 /* UpdatedTimestampView.swift */, ); path = Shared; sourceTree = ""; @@ -2595,6 +2598,7 @@ CDF1EF142A6B6D6E003594B6 /* Feed View Logic.swift in Sources */, 6DFF50432A48DED3001E648D /* Inbox View.swift in Sources */, CDF8426F2A4A385A00723DA0 /* Inbox Item Type.swift in Sources */, + CD2053102AC878B50000AA38 /* UpdatedTimestampView.swift in Sources */, CD1446232A5B336900610EF1 /* LicensesView.swift in Sources */, CDDCF6432A66343D003DA3AC /* FancyTabBar.swift in Sources */, 505240E52A86E32700EA4558 /* CommunityListModel.swift in Sources */, @@ -2727,7 +2731,7 @@ CD9DD8852A62302A0044EA8E /* ConcreteEditorModel.swift in Sources */, CD4E98A32A69BEDC0026C4D9 /* IconSettingsView.swift in Sources */, 637218692A3A2AAD008C4816 /* CreateCommentLike.swift in Sources */, - 03BAA23A2A57DC1400D48252 /* TimestampView.swift in Sources */, + 03BAA23A2A57DC1400D48252 /* PublishedTimestampView.swift in Sources */, B157E0C42A507B8000B02C8B /* Window.swift in Sources */, 6372185A2A3A2AAD008C4816 /* APISubscribedStatus.swift in Sources */, CDDCF6452A66375E003DA3AC /* FancyTabItemViewModifier.swift in Sources */, diff --git a/Mlem/Icons.swift b/Mlem/Icons.swift index 8f033bb42..8d442da3f 100644 --- a/Mlem/Icons.swift +++ b/Mlem/Icons.swift @@ -125,6 +125,7 @@ struct Icons { static let noContent: String = "binoculars" static let noPosts: String = "text.bubble" static let time: String = "clock" + static let updated: String = "clock.arrow.2.circlepath" static let favorite: String = "star" static let favoriteFill: String = "star.fill" @@ -136,6 +137,8 @@ struct Icons { static let filterFill: String = "line.3.horizontal.decrease.circle.fill" static let menu: String = "ellipsis" static let importSymbol: String = "square.and.arrow.down" // Just "import" can't be used :( + static let edit: String = "pencil" + static let delete: String = "trash" // settings static let upvoteOnSave: String = "arrow.up.heart" @@ -170,6 +173,5 @@ struct Icons { static let emptySquare: String = "square" static let dropdown: String = "chevron.down" static let noFile: String = "questionmark.folder" - static let delete: String = "trash" static let forward: String = "chevron.right" } diff --git a/Mlem/Models/Content/Post Model.swift b/Mlem/Models/Content/Post Model.swift index b9cb4300d..806d51a8b 100644 --- a/Mlem/Models/Content/Post Model.swift +++ b/Mlem/Models/Content/Post Model.swift @@ -19,6 +19,7 @@ struct PostModel { let saved: Bool let read: Bool let published: Date + let updated: Date? var uid: ContentModelIdentifier { .init(contentType: .post, contentId: postId) } @@ -34,6 +35,7 @@ struct PostModel { self.saved = apiPostView.saved self.read = apiPostView.read self.published = apiPostView.published + self.updated = apiPostView.post.updated } /// Creates a PostModel from another PostModel. Any provided field values will override values in post. @@ -58,7 +60,8 @@ struct PostModel { numReplies: Int? = nil, saved: Bool? = nil, read: Bool? = nil, - published: Date? = nil + published: Date? = nil, + updated: Date? = nil ) { self.postId = postId ?? other.postId self.post = post ?? other.post @@ -69,6 +72,7 @@ struct PostModel { self.saved = saved ?? other.saved self.read = read ?? other.read self.published = published ?? other.published + self.updated = updated ?? other.updated } var postType: PostType { diff --git a/Mlem/Views/Shared/Accounts/Accounts Page.swift b/Mlem/Views/Shared/Accounts/Accounts Page.swift index 93a0bb96f..6f9c74f5d 100644 --- a/Mlem/Views/Shared/Accounts/Accounts Page.swift +++ b/Mlem/Views/Shared/Accounts/Accounts Page.swift @@ -75,7 +75,7 @@ struct AccountsPage: View { Button(role: .destructive) { accountForDeletion = account } label: { - Label("Delete Current Account", systemImage: "trash") + Label("Delete Current Account", systemImage: Icons.delete) .foregroundColor(.red) } } diff --git a/Mlem/Views/Shared/Comments/Comment Item Logic.swift b/Mlem/Views/Shared/Comments/Comment Item Logic.swift index b4983623e..cb752dc1b 100644 --- a/Mlem/Views/Shared/Comments/Comment Item Logic.swift +++ b/Mlem/Views/Shared/Comments/Comment Item Logic.swift @@ -147,8 +147,8 @@ extension CommentItem { // upvote let (upvoteText, upvoteImg) = hierarchicalComment.commentView.myVote == .upvote ? - ("Undo upvote", "arrow.up.square.fill") : - ("Upvote", "arrow.up.square") + ("Undo upvote", Icons.upvoteSquareFill) : + ("Upvote", Icons.upvoteSquare) ret.append(MenuFunction.standardMenuFunction( text: upvoteText, imageName: upvoteImg, @@ -162,8 +162,8 @@ extension CommentItem { // downvote let (downvoteText, downvoteImg) = hierarchicalComment.commentView.myVote == .downvote ? - ("Undo downvote", "arrow.down.square.fill") : - ("Downvote", "arrow.down.square") + ("Undo downvote", Icons.downvoteSquareFill) : + ("Downvote", Icons.downvoteSquare) ret.append(MenuFunction.standardMenuFunction( text: downvoteText, imageName: downvoteImg, @@ -176,7 +176,9 @@ extension CommentItem { }) // save - let (saveText, saveImg) = hierarchicalComment.commentView.saved ? ("Unsave", "bookmark.slash") : ("Save", "bookmark") + let (saveText, saveImg) = hierarchicalComment.commentView.saved ? + ("Unsave", Icons.unsave) : + ("Save", Icons.save) ret.append(MenuFunction.standardMenuFunction( text: saveText, imageName: saveImg, @@ -191,7 +193,7 @@ extension CommentItem { // reply ret.append(MenuFunction.standardMenuFunction( text: "Reply", - imageName: "arrowshape.turn.up.left", + imageName: Icons.reply, destructiveActionPrompt: nil, enabled: true ) { @@ -202,7 +204,7 @@ extension CommentItem { if appState.isCurrentAccountId(hierarchicalComment.commentView.creator.id) { ret.append(MenuFunction.standardMenuFunction( text: "Edit", - imageName: "pencil", + imageName: Icons.edit, destructiveActionPrompt: nil, enabled: true ) { @@ -214,7 +216,7 @@ extension CommentItem { if appState.isCurrentAccountId(hierarchicalComment.commentView.creator.id) { ret.append(MenuFunction.standardMenuFunction( text: "Delete", - imageName: "trash", + imageName: Icons.delete, destructiveActionPrompt: "Are you sure you want to delete this comment? This cannot be undone.", enabled: !hierarchicalComment.commentView.comment.deleted ) { diff --git a/Mlem/Views/Shared/Comments/Comment Item.swift b/Mlem/Views/Shared/Comments/Comment Item.swift index 292efbea1..d1bf0ec87 100644 --- a/Mlem/Views/Shared/Comments/Comment Item.swift +++ b/Mlem/Views/Shared/Comments/Comment Item.swift @@ -162,6 +162,7 @@ struct CommentItem: View { InteractionBarView( votes: VotesModel(from: hierarchicalComment.commentView.counts, myVote: hierarchicalComment.commentView.myVote), published: hierarchicalComment.commentView.comment.published, + updated: hierarchicalComment.commentView.comment.updated, numReplies: hierarchicalComment.commentView.counts.childCount, saved: hierarchicalComment.commentView.saved, accessibilityContext: "comment", diff --git a/Mlem/Views/Shared/Comments/Components/CommentBodyView.swift b/Mlem/Views/Shared/Comments/Components/CommentBodyView.swift index ffc6593e3..9865b1532 100644 --- a/Mlem/Views/Shared/Comments/Components/CommentBodyView.swift +++ b/Mlem/Views/Shared/Comments/Components/CommentBodyView.swift @@ -108,7 +108,11 @@ struct CommentBodyView: View { func compactScoreDisplay() -> some View { Group { // time - TimestampView(date: commentView.comment.published) + if let updated = commentView.comment.updated { + UpdatedTimestampView(date: updated, spacing: AppConstants.iconToTextSpacing) + } else { + PublishedTimestampView(date: commentView.comment.published) + } // votes if showCommentDownvotesSeparately { diff --git a/Mlem/Views/Shared/Components/Components/InfoStackView.swift b/Mlem/Views/Shared/Components/Components/InfoStackView.swift index 8ff52db88..39ec69ccd 100644 --- a/Mlem/Views/Shared/Components/Components/InfoStackView.swift +++ b/Mlem/Views/Shared/Components/Components/InfoStackView.swift @@ -20,6 +20,7 @@ struct DetailedVotes { struct InfoStackView: View { let votes: DetailedVotes? let published: Date? + let updated: Date? let commentCount: Int? let saved: Bool? let alignment: HorizontalAlignment @@ -38,8 +39,10 @@ struct InfoStackView: View { } } - if let published { - TimestampView(date: published, spacing: AppConstants.iconToTextSpacing) + if let updated { + UpdatedTimestampView(date: updated, spacing: AppConstants.iconToTextSpacing) + } else if let published { + PublishedTimestampView(date: published, spacing: AppConstants.iconToTextSpacing) } if let saved { diff --git a/Mlem/Views/Shared/Components/InteractionBarView.swift b/Mlem/Views/Shared/Components/InteractionBarView.swift index 401811b78..2fe2fdcca 100644 --- a/Mlem/Views/Shared/Components/InteractionBarView.swift +++ b/Mlem/Views/Shared/Components/InteractionBarView.swift @@ -19,6 +19,7 @@ struct InteractionBarView: View { // metadata let votes: VotesModel let published: Date + let updated: Date? let numReplies: Int let saved: Bool @@ -109,6 +110,7 @@ struct InteractionBarView: View { ) : nil, published: shouldShowTime ? published : nil, + updated: shouldShowTime ? updated : nil, commentCount: shouldShowReplies ? numReplies : nil, saved: shouldShowSaved ? saved : nil, alignment: infoStackAlignment(offset) diff --git a/Mlem/Views/Shared/Posts/Expanded Post.swift b/Mlem/Views/Shared/Posts/Expanded Post.swift index b828c95ef..4a60a1ffc 100644 --- a/Mlem/Views/Shared/Posts/Expanded Post.swift +++ b/Mlem/Views/Shared/Posts/Expanded Post.swift @@ -230,6 +230,7 @@ struct ExpandedPost: View { InteractionBarView( votes: post.votes, published: post.published, + updated: post.updated, numReplies: post.numReplies, saved: post.saved, accessibilityContext: "post", @@ -317,4 +318,5 @@ struct ExpandedPost: View { } } } + // swiftlint:enable type_body_length diff --git a/Mlem/Views/Shared/Posts/ExpandedPostLogic.swift b/Mlem/Views/Shared/Posts/ExpandedPostLogic.swift index 8fad29a38..d731aa01a 100644 --- a/Mlem/Views/Shared/Posts/ExpandedPostLogic.swift +++ b/Mlem/Views/Shared/Posts/ExpandedPostLogic.swift @@ -96,8 +96,8 @@ extension ExpandedPost { // upvote let (upvoteText, upvoteImg) = post.votes.myVote == .upvote ? - ("Undo upvote", "arrow.up.square.fill") : - ("Upvote", "arrow.up.square") + ("Undo upvote", Icons.upvoteSquareFill) : + ("Upvote", Icons.upvoteSquare) ret.append(MenuFunction.standardMenuFunction( text: upvoteText, imageName: upvoteImg, @@ -111,8 +111,8 @@ extension ExpandedPost { // downvote let (downvoteText, downvoteImg) = post.votes.myVote == .downvote ? - ("Undo downvote", "arrow.down.square.fill") : - ("Downvote", "arrow.down.square") + ("Undo downvote", Icons.downvoteSquareFill) : + ("Downvote", Icons.downvoteSquare) ret.append(MenuFunction.standardMenuFunction( text: downvoteText, imageName: downvoteImg, @@ -125,7 +125,9 @@ extension ExpandedPost { }) // save - let (saveText, saveImg) = post.saved ? ("Unsave", "bookmark.slash") : ("Save", "bookmark") + let (saveText, saveImg) = post.saved ? + ("Unsave", Icons.unsave) : + ("Save", Icons.save) ret.append(MenuFunction.standardMenuFunction( text: saveText, imageName: saveImg, @@ -140,7 +142,7 @@ extension ExpandedPost { // reply ret.append(MenuFunction.standardMenuFunction( text: "Reply", - imageName: "arrowshape.turn.up.left", + imageName: Icons.reply, destructiveActionPrompt: nil, enabled: true ) { @@ -151,7 +153,7 @@ extension ExpandedPost { // edit ret.append(MenuFunction.standardMenuFunction( text: "Edit", - imageName: "pencil", + imageName: Icons.edit, destructiveActionPrompt: nil, enabled: true ) { @@ -166,7 +168,7 @@ extension ExpandedPost { // delete ret.append(MenuFunction.standardMenuFunction( text: "Delete", - imageName: "trash", + imageName: Icons.delete, destructiveActionPrompt: "Are you sure you want to delete this post? This cannot be undone.", enabled: !post.post.deleted ) { diff --git a/Mlem/Views/Shared/Posts/Feed Post.swift b/Mlem/Views/Shared/Posts/Feed Post.swift index 89d1e6a5e..d478199be 100644 --- a/Mlem/Views/Shared/Posts/Feed Post.swift +++ b/Mlem/Views/Shared/Posts/Feed Post.swift @@ -194,6 +194,7 @@ struct FeedPost: View { InteractionBarView( votes: post.votes, published: post.published, + updated: post.updated, numReplies: post.numReplies, saved: post.saved, accessibilityContext: "post", @@ -299,8 +300,8 @@ struct FeedPost: View { // upvote let (upvoteText, upvoteImg) = post.votes.myVote == .upvote ? - ("Undo upvote", "arrow.up.square.fill") : - ("Upvote", "arrow.up.square") + ("Undo upvote", Icons.upvoteSquareFill) : + ("Upvote", Icons.upvoteSquare) ret.append(MenuFunction.standardMenuFunction( text: upvoteText, imageName: upvoteImg, @@ -314,8 +315,8 @@ struct FeedPost: View { // downvote let (downvoteText, downvoteImg) = post.votes.myVote == .downvote ? - ("Undo downvote", "arrow.down.square.fill") : - ("Downvote", "arrow.down.square") + ("Undo downvote", Icons.downvoteSquareFill) : + ("Downvote", Icons.downvoteSquare) ret.append(MenuFunction.standardMenuFunction( text: downvoteText, imageName: downvoteImg, @@ -343,7 +344,7 @@ struct FeedPost: View { // reply ret.append(MenuFunction.standardMenuFunction( text: "Reply", - imageName: "arrowshape.turn.up.left", + imageName: Icons.reply, destructiveActionPrompt: nil, enabled: true ) { @@ -354,7 +355,7 @@ struct FeedPost: View { // edit ret.append(MenuFunction.standardMenuFunction( text: "Edit", - imageName: "pencil", + imageName: Icons.edit, destructiveActionPrompt: nil, enabled: true ) { @@ -364,7 +365,7 @@ struct FeedPost: View { // delete ret.append(MenuFunction.standardMenuFunction( text: "Delete", - imageName: "trash", + imageName: Icons.delete, destructiveActionPrompt: "Are you sure you want to delete this post? This cannot be undone.", enabled: !post.post.deleted ) { diff --git a/Mlem/Views/Shared/Posts/Post Sizes/Compact Post.swift b/Mlem/Views/Shared/Posts/Post Sizes/Compact Post.swift index 5fafda933..722ce690b 100644 --- a/Mlem/Views/Shared/Posts/Post Sizes/Compact Post.swift +++ b/Mlem/Views/Shared/Posts/Post Sizes/Compact Post.swift @@ -112,6 +112,7 @@ struct CompactPost: View { showDownvotes: showDownvotesSeparately ), published: post.published, + updated: post.updated, commentCount: post.numReplies, saved: post.saved, alignment: .center diff --git a/Mlem/Views/Shared/TimestampView.swift b/Mlem/Views/Shared/PublishedTimestampView.swift similarity index 93% rename from Mlem/Views/Shared/TimestampView.swift rename to Mlem/Views/Shared/PublishedTimestampView.swift index f0db95fe9..acbcf36aa 100644 --- a/Mlem/Views/Shared/TimestampView.swift +++ b/Mlem/Views/Shared/PublishedTimestampView.swift @@ -7,7 +7,7 @@ import SwiftUI -struct TimestampView: View { +struct PublishedTimestampView: View { let date: Date var spacing: CGFloat = 4 diff --git a/Mlem/Views/Shared/UpdatedTimestampView.swift b/Mlem/Views/Shared/UpdatedTimestampView.swift new file mode 100644 index 000000000..aa8e8578b --- /dev/null +++ b/Mlem/Views/Shared/UpdatedTimestampView.swift @@ -0,0 +1,24 @@ +// +// UpdatedTimestampView.swift +// Mlem +// +// Created by Eric Andrews on 2023-09-30. +// + +import SwiftUI + +struct UpdatedTimestampView: View { + let date: Date + var spacing: CGFloat = 4 + + var body: some View { + HStack(spacing: spacing) { + Image(systemName: Icons.updated) + Text(getTimeIntervalFromNow(date: date)) + } + .foregroundColor(.secondary) + .accessibilityAddTraits(.isStaticText) + .accessibilityElement(children: .ignore) + .accessibilityLabel("Updated \(getTimeIntervalFromNow(date: date, unitsStyle: .full)) ago") + } +} diff --git a/Mlem/Views/Tabs/Inbox/Feed/Item Types/Inbox Mention View.swift b/Mlem/Views/Tabs/Inbox/Feed/Item Types/Inbox Mention View.swift index 176712775..b080951a3 100644 --- a/Mlem/Views/Tabs/Inbox/Feed/Item Types/Inbox Mention View.swift +++ b/Mlem/Views/Tabs/Inbox/Feed/Item Types/Inbox Mention View.swift @@ -71,7 +71,7 @@ struct InboxMentionView: View { Spacer() - TimestampView(date: mention.comment.published) + PublishedTimestampView(date: mention.comment.published) } } .frame(maxWidth: .infinity, alignment: .leading) diff --git a/Mlem/Views/Tabs/Inbox/Feed/Item Types/Inbox Message View.swift b/Mlem/Views/Tabs/Inbox/Feed/Item Types/Inbox Message View.swift index ea2e69827..5f4bcd9ee 100644 --- a/Mlem/Views/Tabs/Inbox/Feed/Item Types/Inbox Message View.swift +++ b/Mlem/Views/Tabs/Inbox/Feed/Item Types/Inbox Message View.swift @@ -48,7 +48,7 @@ struct InboxMessageView: View { Spacer() - TimestampView(date: message.privateMessage.published) + PublishedTimestampView(date: message.privateMessage.published) } } .frame(maxWidth: .infinity, alignment: .leading) diff --git a/Mlem/Views/Tabs/Inbox/Feed/Item Types/Inbox Reply View.swift b/Mlem/Views/Tabs/Inbox/Feed/Item Types/Inbox Reply View.swift index d1bbe1f5d..8a9dcdb29 100644 --- a/Mlem/Views/Tabs/Inbox/Feed/Item Types/Inbox Reply View.swift +++ b/Mlem/Views/Tabs/Inbox/Feed/Item Types/Inbox Reply View.swift @@ -69,7 +69,7 @@ struct InboxReplyView: View { Spacer() - TimestampView(date: reply.commentReply.published) + PublishedTimestampView(date: reply.commentReply.published) } } .frame(maxWidth: .infinity, alignment: .leading)