Skip to content

Commit

Permalink
Remove code for iOS versions below 11
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtop committed Mar 20, 2023
1 parent ca4050e commit 9b6f7e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 33 deletions.
41 changes: 14 additions & 27 deletions Sources/DayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,20 @@ public class DayView: UIView, TimelinePagerViewDelegate {
}

private func configureLayout() {
if #available(iOS 11.0, *) {
dayHeaderView.translatesAutoresizingMaskIntoConstraints = false
timelinePagerView.translatesAutoresizingMaskIntoConstraints = false

dayHeaderView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor).isActive = true
dayHeaderView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor).isActive = true
dayHeaderView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor).isActive = true
let heightConstraint = dayHeaderView.heightAnchor.constraint(equalToConstant: headerHeight)
heightConstraint.priority = .defaultLow
heightConstraint.isActive = true

timelinePagerView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor).isActive = true
timelinePagerView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor).isActive = true
timelinePagerView.topAnchor.constraint(equalTo: dayHeaderView.bottomAnchor).isActive = true
timelinePagerView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
}
dayHeaderView.translatesAutoresizingMaskIntoConstraints = false
timelinePagerView.translatesAutoresizingMaskIntoConstraints = false

dayHeaderView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor).isActive = true
dayHeaderView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor).isActive = true
dayHeaderView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor).isActive = true
let heightConstraint = dayHeaderView.heightAnchor.constraint(equalToConstant: headerHeight)
heightConstraint.priority = .defaultLow
heightConstraint.isActive = true

timelinePagerView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor).isActive = true
timelinePagerView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor).isActive = true
timelinePagerView.topAnchor.constraint(equalTo: dayHeaderView.bottomAnchor).isActive = true
timelinePagerView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
}

public func updateStyle(_ newStyle: CalendarStyle) {
Expand Down Expand Up @@ -153,17 +151,6 @@ public class DayView: UIView, TimelinePagerViewDelegate {
state?.move(to: date)
}

override public func layoutSubviews() {
super.layoutSubviews()
if #available(iOS 11, *) {} else {
dayHeaderView.frame = CGRect(origin: CGPoint(x: 0, y: layoutMargins.top),
size: CGSize(width: bounds.width, height: headerHeight))
let timelinePagerHeight = bounds.height - dayHeaderView.frame.maxY
timelinePagerView.frame = CGRect(origin: CGPoint(x: 0, y: dayHeaderView.frame.maxY),
size: CGSize(width: bounds.width, height: timelinePagerHeight))
}
}

public func transitionToHorizontalSizeClass(_ sizeClass: UIUserInterfaceSizeClass) {
dayHeaderView.transitionToHorizontalSizeClass(sizeClass)
updateStyle(style)
Expand Down
7 changes: 1 addition & 6 deletions Sources/Timeline/TimelineContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ public final class TimelineContainer: UIScrollView {

//adjust the scroll insets
let allDayViewHeight = timeline.allDayViewHeight
let bottomSafeInset: Double
if #available(iOS 11.0, *) {
bottomSafeInset = Double(window?.safeAreaInsets.bottom ?? 0.0)
} else {
bottomSafeInset = 0
}
let bottomSafeInset = Double(window?.safeAreaInsets.bottom ?? 0.0)
scrollIndicatorInsets = UIEdgeInsets(top: allDayViewHeight, left: 0, bottom: bottomSafeInset, right: 0)
contentInset = UIEdgeInsets(top: allDayViewHeight, left: 0, bottom: bottomSafeInset, right: 0)
}
Expand Down

0 comments on commit 9b6f7e4

Please sign in to comment.