Skip to content

Commit

Permalink
Fix layout issues after trait collection changes on dashboard and cou…
Browse files Browse the repository at this point in the history
…rse area list
  • Loading branch information
mathebox committed Nov 22, 2019
1 parent 50ec6be commit cb834aa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class CourseAreaListViewController: UICollectionViewController {

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
self.collectionViewLayout.invalidateLayout()
if let selectedIndexPath = self.selectedIndexPath {
self.collectionView?.scrollToItem(at: selectedIndexPath, at: .centeredHorizontally, animated: false)
}
Expand Down
1 change: 1 addition & 0 deletions iOS/ViewControllers/Courses/CourseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class CourseViewController: UIViewController {
self.navigationController?.delegate = self

self.decideContent()
self.updateCourseAreaListContainerHeight()
self.updateHeaderConstraints()

SpotlightHelper.shared.setUserActivity(for: self.course)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ class CourseOverviewViewController: UIViewController {
})
}

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
self.collectionView.collectionViewLayout.invalidateLayout()
}

@objc private func updateCollectionViewHeight() {
let courseCellWidth = CourseCell.minimalWidth(for: self.collectionView.traitCollection)
let availableWidth = self.view.bounds.width - self.view.layoutMargins.left - self.view.layoutMargins.right
Expand Down
5 changes: 5 additions & 0 deletions iOS/Views/CourseAreaCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class CourseAreaCell: UICollectionViewCell {
}
}

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
self.titleView.font = Self.font(whenSelected: self.isSelected)
}

func configure(for content: CourseArea) {
self.titleView.text = content.title
}
Expand Down

0 comments on commit cb834aa

Please sign in to comment.