-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Reader: Collapse long comments #25156
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8ef592f
Collapse long comments
kean 5ba1589
Fix a race condition in WebCommentContentRenderer
kean 216532a
Expand automatically if the margin is too small
kean c28353d
Tweak the threshold
kean 2ea2c53
Increase threshold for P2 sites
kean File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
63 changes: 63 additions & 0 deletions
63
WordPress/Classes/ViewRelated/Comments/Views/Detail/CommentContentShowMoreOverlay.swift
This file contains hidden or 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,63 @@ | ||
| import UIKit | ||
|
|
||
| final class CommentContentShowMoreOverlay: UIView { | ||
| var onTap: (() -> Void)? | ||
|
|
||
| private let gradientLayer = CAGradientLayer() | ||
| private let button = UIButton() | ||
|
|
||
| override init(frame: CGRect) { | ||
| super.init(frame: frame) | ||
| setupView() | ||
| } | ||
|
|
||
| required init?(coder: NSCoder) { | ||
| super.init(coder: coder) | ||
| setupView() | ||
| } | ||
|
|
||
| private func setupView() { | ||
| isUserInteractionEnabled = true | ||
|
|
||
| // Setup gradient | ||
| gradientLayer.colors = [ | ||
| UIColor.systemBackground.withAlphaComponent(0).cgColor, | ||
| UIColor.systemBackground.withAlphaComponent(0.9).cgColor, | ||
| UIColor.systemBackground.cgColor | ||
| ] | ||
| gradientLayer.locations = [0.0, 0.5, 1.0] | ||
| layer.addSublayer(gradientLayer) | ||
|
|
||
| // Setup button | ||
| var configuration = UIButton.Configuration.plain() | ||
| configuration.attributedTitle = AttributedString(Strings.showMore, attributes: AttributeContainer([ | ||
| .font: UIFont.preferredFont(forTextStyle: .subheadline).withWeight(.medium) | ||
| ])) | ||
| configuration.image = UIImage(systemName: "chevron.up.chevron.down") | ||
| configuration.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(font: UIFont.preferredFont(forTextStyle: .caption2).withWeight(.medium)) | ||
| configuration.imagePlacement = .leading | ||
| configuration.imagePadding = 6 | ||
| configuration.contentInsets = NSDirectionalEdgeInsets(top: 20, leading: 12, bottom: 9, trailing: 12) | ||
|
|
||
| button.configuration = configuration | ||
| button.translatesAutoresizingMaskIntoConstraints = false | ||
| button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside) | ||
| button.maximumContentSizeCategory = .extraExtraExtraLarge | ||
|
|
||
| addSubview(button) | ||
| button.pinEdges([.horizontal, .bottom]) | ||
| } | ||
|
|
||
| @objc private func buttonTapped() { | ||
| onTap?() | ||
| } | ||
|
|
||
| override func layoutSubviews() { | ||
| super.layoutSubviews() | ||
| gradientLayer.frame = bounds | ||
| } | ||
| } | ||
|
|
||
| private enum Strings { | ||
| static let showMore = NSLocalizedString("reader.comments.showMore", value: "Show More", comment: "Button to expand a collapsed comment to show its full content.") | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this constraint may cause conflicts if the font is super large? Instead of hard-code a height here, would setting the
button.contentInsetsor the margins between the button and its parent view work?