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

Reader: Fix layout for cross-post cells on iPad #23879

Closed
wants to merge 2 commits into from
Closed
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
@@ -1,8 +1,49 @@
import Foundation
import AutomatticTracks
import WordPressShared
import WordPressUI

final class ReaderCrossPostCell: ReaderStreamBaseCell {
private let view = ReaderCrossPostView()
private var contentViewConstraints: [NSLayoutConstraint] = []

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)

contentView.addSubview(view)
view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
view.topAnchor.constraint(equalTo: contentView.topAnchor),
view.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).withPriority(999),
])
}

required init?(coder: NSCoder) {
fatalError("Not implemented")
}

override func prepareForReuse() {
super.prepareForReuse()

view.prepareForReuse()
}

func configure(with post: ReaderPost) {
view.configure(with: post)
}

override func didUpdateCompact(_ isCompact: Bool) {
setNeedsUpdateConstraints()
}

override func updateConstraints() {
NSLayoutConstraint.deactivate(contentViewConstraints)
contentViewConstraints = view.pinEdges(.horizontal, to: isCompact ? contentView : contentView.readableContentGuide)
super.updateConstraints()
}
}

private final class ReaderCrossPostView: UIView {
private let avatarView = ReaderAvatarView()
private let iconView = ReaderAvatarView()
private let headerLabel = UILabel()
Expand All @@ -27,22 +68,18 @@ final class ReaderCrossPostCell: ReaderStreamBaseCell {
.foregroundColor: UIColor.secondaryLabel
]

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
override init(frame: CGRect) {
super.init(frame: frame)

setupStyle()
setupLayout()

selectedBackgroundView = ReaderPostCell.makeSelectedBackgroundView()
}

required init?(coder: NSCoder) {
fatalError("Not implemented")
}

override func prepareForReuse() {
super.prepareForReuse()

func prepareForReuse() {
avatarView.prepareForReuse()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import WordPressShared

final class ReaderPostCell: ReaderStreamBaseCell {
private let view = ReaderPostCellView()

private var contentViewConstraints: [NSLayoutConstraint] = []

static let avatarSize: CGFloat = SiteIconViewModel.Size.small.width
Expand All @@ -23,12 +22,6 @@ final class ReaderPostCell: ReaderStreamBaseCell {
])
}

static func makeSelectedBackgroundView() -> UIView {
let view = UIView()
view.backgroundColor = UIColor.opaqueSeparator.withAlphaComponent(0.2)
return view
}

required init?(coder: NSCoder) {
fatalError("Not implemented")
}
Expand Down
Loading