Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colorize voting icons and text in compact posts and comments #800

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,19 @@ struct CommentBodyView: View {
Image(systemName: myVote == .upvote ? Icons.upvoteSquareFill : Icons.upvoteSquare)
Text(String(commentView.counts.upvotes))
}
.foregroundColor(myVote == .upvote ? .upvoteColor : .secondary)

HStack(spacing: AppConstants.iconToTextSpacing) {
Image(systemName: myVote == .downvote ? Icons.downvoteSquareFill : Icons.downvoteSquare)
Text(String(commentView.counts.downvotes))
}
.foregroundColor(myVote == .downvote ? .downvoteColor : .secondary)
} else {
HStack(spacing: AppConstants.iconToTextSpacing) {
Image(systemName: myVote == .resetVote ? Icons.upvoteSquare : myVote.iconNameFill)
Text(String(commentView.counts.score))
}
.foregroundColor(.secondary)
.foregroundColor(myVote.color ?? .secondary)
.font(.footnote)
}
}
Expand Down
4 changes: 4 additions & 0 deletions Mlem/Views/Shared/Components/Components/InfoStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct InfoStackView: View {
let commentCount: Int?
let saved: Bool?
let alignment: HorizontalAlignment
let colorizeVotes: Bool

var body: some View {
HStack {
Expand Down Expand Up @@ -70,6 +71,7 @@ struct InfoStackView: View {
Image(systemName: votes.myVote == .resetVote ? Icons.upvoteSquare : votes.myVote.iconNameFill)
Text(String(votes.score))
}
.foregroundColor(colorizeVotes ? votes.myVote.color ?? .secondary : .secondary)
.accessibilityAddTraits(.isStaticText)
.accessibilityElement(children: .ignore)
.accessibilityLabel("\(votes.score) net votes")
Expand All @@ -81,6 +83,7 @@ struct InfoStackView: View {
Image(systemName: votes.myVote == .upvote ? Icons.upvoteSquareFill : Icons.upvoteSquare)
Text(String(votes.upvotes))
}
.foregroundColor(colorizeVotes && votes.myVote == .upvote ? .upvoteColor : .secondary)
.accessibilityAddTraits(.isStaticText)
.accessibilityElement(children: .ignore)
.accessibilityLabel("\(votes.upvotes) upvotes")
Expand All @@ -94,6 +97,7 @@ struct InfoStackView: View {
: Icons.downvoteSquare)
Text(String(votes.downvotes))
}
.foregroundColor(colorizeVotes && votes.myVote == .downvote ? .downvoteColor : .secondary)
.accessibilityAddTraits(.isStaticText)
.accessibilityElement(children: .ignore)
.accessibilityLabel("\(votes.downvotes) downvotes")
Expand Down
3 changes: 2 additions & 1 deletion Mlem/Views/Shared/Components/InteractionBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ struct InteractionBarView: View {
updated: shouldShowTime ? updated : nil,
commentCount: shouldShowReplies ? numReplies : nil,
saved: shouldShowSaved ? saved : nil,
alignment: infoStackAlignment(offset)
alignment: infoStackAlignment(offset),
colorizeVotes: false
)
.padding(AppConstants.postAndCommentSpacing)
.frame(minWidth: 0, maxWidth: .infinity)
Expand Down
3 changes: 2 additions & 1 deletion Mlem/Views/Shared/Posts/Post Sizes/Compact Post.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ struct CompactPost: View {
updated: post.updated,
commentCount: post.numReplies,
saved: post.saved,
alignment: .center
alignment: .center,
colorizeVotes: true
)
}
.frame(maxWidth: .infinity, alignment: .leading)
Expand Down
Loading