Skip to content

Commit

Permalink
Merge pull request #4152 from wikimedia/T286607
Browse files Browse the repository at this point in the history
Notification Center: iPad adjustments
  • Loading branch information
tonisevener committed Apr 15, 2022
2 parents c39d6ac + a523932 commit cfa2762
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
11 changes: 6 additions & 5 deletions Wikipedia/Code/NotificationsCenterCell.swift
Expand Up @@ -337,12 +337,13 @@ final class NotificationsCenterCell: UICollectionViewCell {
projectSourceContainer.addSubview(projectSourceLabel)
projectSourceContainer.addSubview(projectSourceImage)

let minimumSummaryHeight = (traitCollection.horizontalSizeClass == .regular) ? 40.0 : 64.0
internalVerticalNotificationContentStack.addArrangedSubview(VerticalSpacerView.spacerWith(space: 6))
internalVerticalNotificationContentStack.addArrangedSubview(subheaderLabel)
internalVerticalNotificationContentStack.addArrangedSubview(VerticalSpacerView.spacerWith(space: 6))
internalVerticalNotificationContentStack.addArrangedSubview(messageSummaryLabel)
NSLayoutConstraint.activate([
messageSummaryLabel.heightAnchor.constraint(greaterThanOrEqualToConstant: 64)
messageSummaryLabel.heightAnchor.constraint(greaterThanOrEqualToConstant: minimumSummaryHeight)
])
internalVerticalNotificationContentStack.addArrangedSubview(VerticalSpacerView.spacerWith(space: 3))
internalVerticalNotificationContentStack.addArrangedSubview(metaStackView)
Expand Down Expand Up @@ -375,16 +376,16 @@ final class NotificationsCenterCell: UICollectionViewCell {
// Primary Hierarchy Constraints

NSLayoutConstraint.activate([
leadingContainer.leadingAnchor.constraint(equalTo: foregroundContentContainer.leadingAnchor),
leadingContainer.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor),
leadingContainer.topAnchor.constraint(equalTo: mainVerticalStackView.topAnchor),
leadingContainer.bottomAnchor.constraint(equalTo: foregroundContentContainer.bottomAnchor),
leadingContainer.trailingAnchor.constraint(equalTo: mainVerticalStackView.leadingAnchor),

mainVerticalStackView.topAnchor.constraint(equalTo: foregroundContentContainer.topAnchor, constant: topMargin),
mainVerticalStackView.bottomAnchor.constraint(equalTo: foregroundContentContainer.bottomAnchor, constant: -edgeMargin),
mainVerticalStackView.trailingAnchor.constraint(equalTo: foregroundContentContainer.trailingAnchor),
mainVerticalStackView.trailingAnchor.constraint(equalTo: contentView.readableContentGuide.trailingAnchor),

headerTextContainer.trailingAnchor.constraint(equalTo: foregroundContentContainer.trailingAnchor, constant: -edgeMargin),
headerTextContainer.trailingAnchor.constraint(equalTo: contentView.readableContentGuide.trailingAnchor, constant: -edgeMargin),

cellSeparator.heightAnchor.constraint(equalToConstant: 0.5),
cellSeparator.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
Expand Down Expand Up @@ -420,7 +421,7 @@ final class NotificationsCenterCell: UICollectionViewCell {

NSLayoutConstraint.activate([
projectSourceContainer.widthAnchor.constraint(equalToConstant: 50),
projectSourceContainer.trailingAnchor.constraint(equalTo: foregroundContentContainer.trailingAnchor, constant: -edgeMargin),
projectSourceContainer.trailingAnchor.constraint(equalTo: contentView.readableContentGuide.trailingAnchor, constant: -edgeMargin),

projectSourceLabel.topAnchor.constraint(equalTo: subheaderLabel.topAnchor),
projectSourceLabel.trailingAnchor.constraint(equalTo: projectSourceContainer.trailingAnchor),
Expand Down
6 changes: 4 additions & 2 deletions Wikipedia/Code/NotificationsCenterFilterView.swift
Expand Up @@ -3,9 +3,10 @@ import SwiftUI
import WMF

struct NotificationsCenterFilterItemView: View {
@Environment (\.horizontalSizeClass) private var horizontalSizeClass
@ObservedObject var itemViewModel: NotificationsCenterFiltersViewModel.ItemViewModel
let theme: Theme

var body: some View {

Group {
Expand Down Expand Up @@ -65,6 +66,7 @@ struct NotificationsCenterFilterItemView: View {
}
}
}
.padding(.horizontal, horizontalSizeClass == .regular ? (UIFont.preferredFont(forTextStyle: .body).pointSize) : 0)
.listRowBackground(Color(theme.colors.paperBackground).edgesIgnoringSafeArea([.all]))
}
}
Expand All @@ -82,7 +84,7 @@ extension Binding {
}

struct NotificationsCenterFilterView: View {

let viewModel: NotificationsCenterFiltersViewModel
let doneAction: () -> Void

Expand Down
4 changes: 3 additions & 1 deletion Wikipedia/Code/NotificationsCenterInboxView.swift
Expand Up @@ -47,7 +47,8 @@ struct NotificationsCenterInboxItemView: View {
}

struct NotificationsCenterInboxView: View {


@Environment (\.horizontalSizeClass) private var horizontalSizeClass
let viewModel: NotificationsCenterInboxViewModel
let doneAction: () -> Void

Expand Down Expand Up @@ -76,6 +77,7 @@ struct NotificationsCenterInboxView: View {
.foregroundColor(Color(viewModel.theme.colors.primaryText))
}
)
.padding(.horizontal, horizontalSizeClass == .regular ? (UIFont.preferredFont(forTextStyle: .body).pointSize) : 0)
.background(Color(viewModel.theme.colors.baseBackground).edgesIgnoringSafeArea(.all))
.navigationBarTitle(Text(WMFLocalizedString("notifications-center-inbox-title", value: "Projects", comment: "Navigation bar title text for the inbox view presented from notifications center. Allows for filtering out notifications by Wikimedia project type.")), displayMode: .inline)
.onAppear(perform: {
Expand Down
4 changes: 4 additions & 0 deletions Wikipedia/Code/NotificationsCenterView.swift
Expand Up @@ -79,6 +79,10 @@ final class NotificationsCenterView: SetupView {
emptyOverlaySubheaderLabel.font = UIFont.wmf_font(.subheadline, compatibleWithTraitCollection: traitCollection)
calculatedCellHeight = nil
}

if previousTraitCollection?.horizontalSizeClass != traitCollection.horizontalSizeClass {
calculatedCellHeight = nil
}
}

override func layoutSubviews() {
Expand Down
2 changes: 1 addition & 1 deletion Wikipedia/Code/NotificationsCenterViewController.swift
Expand Up @@ -798,7 +798,7 @@ extension NotificationsCenterViewController: NotificationsCenterCellDelegate {
if let activeCell = cellSwipeData.activeCell(in: notificationsView.collectionView) {
let sourceView = activeCell.swipeMoreStack
popoverController.sourceView = sourceView
popoverController.sourceRect = CGRect(x: sourceView.bounds.midX, y: sourceView.bounds.midY, width: 0, height: 0)
popoverController.sourceRect = sourceView.bounds
} else {
popoverController.sourceView = cell
popoverController.sourceRect = CGRect(x: cell.bounds.midX, y: cell.bounds.midY, width: 0, height: 0)
Expand Down

0 comments on commit cfa2762

Please sign in to comment.