[go: up one dir, main page]

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

Talk pages - iPad tweaks #4364

Merged
merged 5 commits into from
Oct 27, 2022
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
6 changes: 3 additions & 3 deletions Wikipedia/Code/TalkPageCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ final class TalkPageCell: UICollectionViewCell {
NSLayoutConstraint.activate([
rootContainer.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8),
rootContainerBottomConstraint,
rootContainer.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16),
rootContainer.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16),
rootContainer.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor, constant: 8),
rootContainer.trailingAnchor.constraint(equalTo: contentView.readableContentGuide.trailingAnchor, constant: -8),

stackView.topAnchor.constraint(equalTo: rootContainer.topAnchor, constant: 12),
stackView.bottomAnchor.constraint(equalTo: rootContainer.bottomAnchor, constant: -12),
Expand Down Expand Up @@ -149,7 +149,7 @@ final class TalkPageCell: UICollectionViewCell {
for commentViewModel in viewModel.replies {
let separator = TalkPageCellCommentSeparator()
separator.setContentHuggingPriority(.defaultLow, for: .horizontal)
separator.setContentCompressionResistancePriority(.required, for: .horizontal)
separator.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)

let commentView = TalkPageCellCommentView()
commentView.replyDelegate = replyDelegate
Expand Down
35 changes: 27 additions & 8 deletions Wikipedia/Code/TalkPageCoffeeRollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@ final class TalkPageCoffeeRollView: SetupView {
weak var linkDelegate: TalkPageTextViewLinkHandling?

// MARK: - UI Elements

lazy var scrollView: UIScrollView = {
let scrollView = UIScrollView(frame: .zero)
scrollView.translatesAutoresizingMaskIntoConstraints = false
return scrollView
}()

lazy var textView: UITextView = {
let textView = UITextView()
textView.translatesAutoresizingMaskIntoConstraints = false
textView.isScrollEnabled = true
textView.isScrollEnabled = false
textView.isEditable = false
textView.textContainerInset = UIEdgeInsets(top: 16, left: 0, bottom: 16, right: 0)

textView.textContainerInset = .zero
textView.textContainer.lineFragmentPadding = 0

textView.setContentCompressionResistancePriority(.required, for: .vertical)
textView.setContentHuggingPriority(.required, for: .vertical)

textView.delegate = self
return textView
}()
Expand All @@ -35,20 +47,27 @@ final class TalkPageCoffeeRollView: SetupView {
}

override func setup() {
addSubview(textView)
addSubview(scrollView)
scrollView.addSubview(textView)
NSLayoutConstraint.activate([
textView.topAnchor.constraint(equalTo: topAnchor),
textView.bottomAnchor.constraint(equalTo: bottomAnchor),
textView.leadingAnchor.constraint(equalTo: readableContentGuide.leadingAnchor),
textView.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor)
scrollView.topAnchor.constraint(equalTo: topAnchor),
scrollView.bottomAnchor.constraint(equalTo: bottomAnchor),
scrollView.leadingAnchor.constraint(equalTo: leadingAnchor),
scrollView.trailingAnchor.constraint(equalTo: trailingAnchor),
textView.topAnchor.constraint(equalTo: scrollView.topAnchor, constant: 16),
textView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor, constant: -16),
textView.leadingAnchor.constraint(equalTo: scrollView.readableContentGuide.leadingAnchor, constant: 16),
textView.trailingAnchor.constraint(equalTo: scrollView.readableContentGuide.trailingAnchor, constant: -16),
textView.widthAnchor.constraint(equalTo: scrollView.readableContentGuide.widthAnchor, constant: -32)
])
}

// MARK: - Configure

func configure(viewModel: TalkPageCoffeeRollViewModel) {
self.viewModel = viewModel
textView.attributedText = viewModel.coffeeRollText?.byAttributingHTML(with: .callout, boldWeight: .semibold, matching: traitCollection, color: theme.colors.primaryText, linkColor: theme.colors.link, handlingLists: true, handlingSuperSubscripts: true)

textView.attributedText = viewModel.coffeeRollText?.byAttributingHTML(with: .callout, boldWeight: .semibold, matching: traitCollection, color: theme.colors.primaryText, linkColor: theme.colors.link, handlingLists: true, handlingSuperSubscripts: true).removingInitialNewlineCharacters()

updateSemanticContentAttribute(viewModel.semanticContentAttribute)
}
Expand Down
2 changes: 1 addition & 1 deletion Wikipedia/Code/TalkPageCoffeeRollViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class TalkPageCoffeeRollViewController: ViewController {
let coffeeRollView = TalkPageCoffeeRollView(theme: theme, viewModel: viewModel, frame: UIScreen.main.bounds)
view = coffeeRollView
coffeeRollView.configure(viewModel: viewModel)
scrollView = coffeeRollView.textView
scrollView = coffeeRollView.scrollView
}

init(theme: Theme, viewModel: TalkPageCoffeeRollViewModel) {
Expand Down
6 changes: 3 additions & 3 deletions Wikipedia/Code/TalkPageEmptyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ final class TalkPageEmptyView: SetupView {
scrollView.bottomAnchor.constraint(equalTo: bottomAnchor),

stackView.topAnchor.constraint(equalTo: scrollView.topAnchor),
stackView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor),
stackView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor),
stackView.leadingAnchor.constraint(equalTo: scrollView.readableContentGuide.leadingAnchor),
stackView.trailingAnchor.constraint(equalTo: scrollView.readableContentGuide.trailingAnchor),
stackView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),
stackView.widthAnchor.constraint(equalTo: scrollView.widthAnchor),
stackView.widthAnchor.constraint(equalTo: scrollView.readableContentGuide.widthAnchor),

actionButton.heightAnchor.constraint(greaterThanOrEqualToConstant: 42)
])
Expand Down
4 changes: 2 additions & 2 deletions Wikipedia/Code/TalkPageHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ final class TalkPageHeaderView: SetupView {
coffeeRollLabel.topAnchor.constraint(equalTo: coffeeRollSeparator.topAnchor, constant: 12),
coffeeRollLabel.bottomAnchor.constraint(equalTo: coffeeRollReadMoreButton.topAnchor, constant: -4),

coffeeRollReadMoreButton.leadingAnchor.constraint(equalTo: coffeeRollContainer.readableContentGuide.leadingAnchor),
coffeeRollReadMoreButton.trailingAnchor.constraint(equalTo: coffeeRollContainer.readableContentGuide.trailingAnchor),
coffeeRollReadMoreButton.leadingAnchor.constraint(equalTo: coffeeRollContainer.readableContentGuide.leadingAnchor, constant: 8),
coffeeRollReadMoreButton.trailingAnchor.constraint(equalTo: coffeeRollContainer.readableContentGuide.trailingAnchor, constant: -8),
coffeeRollReadMoreButton.bottomAnchor.constraint(equalTo: coffeeRollContainer.bottomAnchor, constant: -8)
])

Expand Down