Skip to content

Commit

Permalink
Bump Paralayout dependency in demo app to 1.0.0-rc.5
Browse files Browse the repository at this point in the history
  • Loading branch information
NickEntin committed Aug 8, 2023
1 parent b3e77c4 commit 4dd31c3
Show file tree
Hide file tree
Showing 25 changed files with 78 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private extension AccessibilityCustomActionsViewController {
// MARK: - UIView

override func layoutSubviews() {
views.forEach { $0.frame.size = .init(width: bounds.width / 2, height: 50) }
views.forEach { $0.bounds.size = .init(width: bounds.width / 2, height: 50) }

let statusBarHeight = window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0

Expand All @@ -71,7 +71,7 @@ private extension AccessibilityCustomActionsViewController {
distributionSpecifiers.append(subview)
distributionSpecifiers.append(1.flexible)
}
applySubviewDistribution(distributionSpecifiers)
applyVerticalSubviewDistribution(distributionSpecifiers)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private extension AccessibilityPathViewController {
distributionSpecifiers.append(subview)
distributionSpecifiers.append(1.flexible)
}
applySubviewDistribution(distributionSpecifiers)
applyVerticalSubviewDistribution(distributionSpecifiers)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ private extension ActivationPointViewController {
// MARK: - UIView

override func layoutSubviews() {
button.resize(toFit: bounds.size)
customActivationPointView.resize(toFit: bounds.size)
button.sizeToFit(bounds.size)
customActivationPointView.sizeToFit(bounds.size)

let statusBarHeight = window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0

applySubviewDistribution(
applyVerticalSubviewDistribution(
[
statusBarHeight.fixed,
1.flexible,
Expand Down Expand Up @@ -122,8 +122,8 @@ private extension ActivationPointViewController {
label.sizeToFit()
switchButton.sizeToFit()

label.alignToSuperview(.leftCenter, inset: 32)
switchButton.alignToSuperview(.rightCenter, inset: 32)
label.align(withSuperview: .leftCenter, inset: 32)
switchButton.align(withSuperview: .rightCenter, inset: 32)

label.isAccessibilityElement = false
}
Expand All @@ -150,7 +150,8 @@ private extension ActivationPointViewController {
get {
// Set the activation point to the center of switch so tapping the parent element toggles the switch.
return Position.center.point(
in: UIAccessibility.convertToScreenCoordinates(switchButton.frame, in: self)
in: UIAccessibility.convertToScreenCoordinates(switchButton.frame, in: self),
layoutDirection: effectiveUserInterfaceLayoutDirection
)
}
set {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,17 @@ extension ButtonAccessibilityTraitsViewController {
leftColSubviewDistribution.append(button)
leftColSubviewDistribution.append(1.flexible)
}
applySubviewDistribution(leftColSubviewDistribution, alignment: .leading(inset: outerMargin))
applyVerticalSubviewDistribution(
leftColSubviewDistribution,
orthogonalAlignment: .leading(inset: outerMargin)
)

var centerColSubviewDistribution: [ViewDistributionSpecifying] = [ statusBarHeight.fixed, 1.flexible ]
for button in buttons[buttonsPerColumn..<(2 * buttonsPerColumn)] {
centerColSubviewDistribution.append(button)
centerColSubviewDistribution.append(1.flexible)
}
applySubviewDistribution(centerColSubviewDistribution)
applyVerticalSubviewDistribution(centerColSubviewDistribution)

var rightColSubviewDistribution: [ViewDistributionSpecifying] = [ statusBarHeight.fixed, 1.flexible ]
for button in buttons[(2 * buttonsPerColumn)..<buttons.count] {
Expand All @@ -221,7 +224,10 @@ extension ButtonAccessibilityTraitsViewController {
rightColSubviewDistribution.append(buttons[0].frame.height.fixed)
rightColSubviewDistribution.append(1.flexible)
}
applySubviewDistribution(rightColSubviewDistribution, alignment: .trailing(inset: outerMargin))
applyVerticalSubviewDistribution(
rightColSubviewDistribution,
orthogonalAlignment: .trailing(inset: outerMargin)
)
}

}
Expand Down
4 changes: 2 additions & 2 deletions Example/AccessibilitySnapshot/DataTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private extension DataTableViewController {
width: CGFloat(accessibilityColumnCount()),
height: CGFloat(accessibilityRowCount())
).rect(
toFit: bounds.inset(left: 20, top: 20, right: 20, bottom: 20),
toFit: bounds.insetBy(left: 20, top: 20, right: 20, bottom: 20),
at: .center,
in: self
)
Expand All @@ -167,7 +167,7 @@ private extension DataTableViewController {
}

notACell.sizeToFit()
notACell.alignToSuperview(.topCenter, inset: 60)
notACell.capInsetsAlignmentProxy.align(withSuperview: .topCenter, inset: 60)
}

// MARK: - UIAccessibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private extension DefaultControlsViewController {
distributionSpecifiers.append(subview)
distributionSpecifiers.append(1.flexible)
}
applySubviewDistribution(distributionSpecifiers)
applyVerticalSubviewDistribution(distributionSpecifiers)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ extension DescriptionEdgeCasesViewController {
distributionSpecifiers.append(subview)
distributionSpecifiers.append(1.flexible)
}
applySubviewDistribution(distributionSpecifiers)
applyVerticalSubviewDistribution(distributionSpecifiers)
}

}
Expand Down
4 changes: 2 additions & 2 deletions Example/AccessibilitySnapshot/DynamicTypeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ final class DynamicTypeViewController: AccessibilityViewController {

views.forEach { $0.frame.size = $0.sizeThatFits(view.bounds.size) }

let statusBarHeight = UIApplication.shared.statusBarFrame.height
let statusBarHeight = view.window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0

var distributionSpecifiers: [ViewDistributionSpecifying] = [ statusBarHeight.fixed, 1.flexible ]
for subview in views {
distributionSpecifiers.append(subview)
distributionSpecifiers.append(1.flexible)
}
view.applySubviewDistribution(distributionSpecifiers)
view.applyVerticalSubviewDistribution(distributionSpecifiers)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private extension ElementOrderViewController {
)

case .container, .viewWithAccessibleSubviews:
view.alignToSuperview(.center)
view.align(withSuperview: .center)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private extension ElementSelectionViewController {
distributionSpecifiers.append(subview)
distributionSpecifiers.append(1.flexible)
}
applySubviewDistribution(distributionSpecifiers)
applyVerticalSubviewDistribution(distributionSpecifiers)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ private extension InvertColorsViewController {
override func layoutSubviews() {
let nestedViews: [UIView] = [self] + nestedSubviews
for (containingView, subview) in zip(nestedViews.dropLast(), nestedViews.dropFirst()) {
subview.frame = containingView.bounds.inset(left: 30, top: 60, right: 30, bottom: 60)
subview.frame = containingView.bounds.insetBy(left: 30, top: 60, right: 30, bottom: 60)
}

statusLabel.sizeToFit()
statusLabel.alignToSuperview(.topCenter, inset: 20)
statusLabel.capInsetsAlignmentProxy.align(withSuperview: .topCenter, inset: 20)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ extension LabelAccessibilityPropertiesViewController {

var distributionSpecifiers: [ViewDistributionSpecifying] = [ statusBarHeight.fixed, 1.flexible ]
for label in labels {
distributionSpecifiers.append(label)
distributionSpecifiers.append(label.distributionItemUsingCapInsets)
distributionSpecifiers.append(1.flexible)
}
applySubviewDistribution(distributionSpecifiers)
applyVerticalSubviewDistribution(distributionSpecifiers)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ private extension LandmarkContainerViewController {

// MARK: - Private Properties

private let views: [UIView]
private let views: [UILabel]

// MARK: - UIView

override func layoutSubviews() {
views.forEach { $0.sizeToFit() }

let statusBarHeight = UIApplication.shared.statusBarFrame.height
let statusBarHeight = window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0

var distributionSpecifiers: [ViewDistributionSpecifying] = [ statusBarHeight.fixed, 1.flexible ]
for subview in views {
distributionSpecifiers.append(subview)
distributionSpecifiers.append(subview.distributionItemUsingCapInsets)
distributionSpecifiers.append(1.flexible)
}
applySubviewDistribution(distributionSpecifiers)
applyVerticalSubviewDistribution(distributionSpecifiers)
}

// MARK: - UIAccessibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ private extension ListContainerViewController {

// MARK: - Private Properties

private let views: [UIView]
private let views: [UILabel]

// MARK: - UIView

override func layoutSubviews() {
views.forEach { $0.sizeToFit() }

let statusBarHeight = UIApplication.shared.statusBarFrame.height
let statusBarHeight = window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0

var distributionSpecifiers: [ViewDistributionSpecifying] = [ statusBarHeight.fixed, 1.flexible ]
for subview in views {
distributionSpecifiers.append(subview)
distributionSpecifiers.append(subview.distributionItemUsingCapInsets)
distributionSpecifiers.append(1.flexible)
}
applySubviewDistribution(distributionSpecifiers)
applyVerticalSubviewDistribution(distributionSpecifiers)
}

// MARK: - UIAccessibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ private extension ModalAccessibilityViewController {
// MARK: - UIView

override func layoutSubviews() {
views[0].alignToSuperview(.topLeft, inset: 20)
views[1].alignToSuperview(.topRight, inset: 20)
views[2].alignToSuperview(.bottomRight, inset: 20)
views[3].alignToSuperview(.bottomLeft, inset: 20)
views[0].align(withSuperview: .topLeft, inset: 20)
views[1].align(withSuperview: .topRight, inset: 20)
views[2].align(withSuperview: .bottomRight, inset: 20)
views[3].align(withSuperview: .bottomLeft, inset: 20)

var distributionItems: [ViewDistributionSpecifying] = [1.flexible]

Expand All @@ -125,7 +125,7 @@ private extension ModalAccessibilityViewController {

_ = distributionItems.dropLast()
distributionItems.append(1.flexible)
applySubviewDistribution(distributionItems)
applyVerticalSubviewDistribution(distributionItems)
}

}
Expand Down Expand Up @@ -178,7 +178,7 @@ private extension ModalAccessibilityViewController {

override func layoutSubviews() {
label.sizeToFit()
label.alignToSuperview(.center)
label.capInsetsAlignmentProxy.align(withSuperview: .center)

switch accessibilityMode {
case .viewContainsAccessibleElement,
Expand Down Expand Up @@ -227,13 +227,15 @@ private extension ModalAccessibilityViewController {

override func layoutSubviews() {
modalViews.forEach { $0.sizeToFit() }
applySubviewDistribution([
10.fixed,
modalViews[0],
10.fixed,
modalViews[1],
10.fixed,
])
applyVerticalSubviewDistribution(
[
10.fixed,
modalViews[0],
10.fixed,
modalViews[1],
10.fixed,
]
)
}

override func sizeThatFits(_ size: CGSize) -> CGSize {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private extension SwitchControlViewController {
1.flexible,
]
)
applySubviewDistribution(distributionSpecifiers)
applyVerticalSubviewDistribution(distributionSpecifiers)
}

}
Expand Down
12 changes: 6 additions & 6 deletions Example/AccessibilitySnapshot/TabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ extension TabBarViewController {
distributionSpecifiers.append(subview)
distributionSpecifiers.append(1.flexible)
}
applySubviewDistribution(distributionSpecifiers)
applyVerticalSubviewDistribution(distributionSpecifiers)
}

}
Expand Down Expand Up @@ -205,7 +205,7 @@ private final class TabBarTraitView: UIView {

override func layoutSubviews() {
tabs.forEach { $0.frame.size.height = bounds.height }
spreadOutSubviews(tabs, margin: 0)
horizontallySpreadSubviews(tabs, margin: 0)
}

override func sizeThatFits(_ size: CGSize) -> CGSize {
Expand Down Expand Up @@ -270,13 +270,13 @@ private final class TabBarTraitView: UIView {
outerLabelContainer.frame = bounds

leftLabel.sizeToFit()
leftLabel.alignToSuperview(.leftCenter, inset: 4)
leftLabel.capInsetsAlignmentProxy.align(withSuperview: .leftCenter, inset: 4)

rightLabel.sizeToFit()
rightLabel.alignToSuperview(.rightCenter, inset: 4)
rightLabel.capInsetsAlignmentProxy.align(withSuperview: .rightCenter, inset: 4)

middleLabel.sizeToFit()
middleLabel.alignToSuperview(.center)
middleLabel.capInsetsAlignmentProxy.align(withSuperview: .center)
}

}
Expand Down Expand Up @@ -352,7 +352,7 @@ private final class TabBarTraitContainerView: UIView {
override func layoutSubviews() {
itemLabels.forEach { $0.frame.size.height = bounds.height }

spreadOutSubviews(itemLabels, margin: 0)
horizontallySpreadSubviews(itemLabels, margin: 0)

for (label, element) in zip(itemLabels, accessibilityElements as! [UIAccessibilityElement]) {
element.accessibilityFrameInContainerSpace = label.frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ private extension UserIntefaceDirectionViewController {
// MARK: - UIView

override func layoutSubviews() {
let statusBarHeight = UIApplication.shared.statusBarFrame.height
let statusBarHeight = window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0

var distributionSpecifiers: [ViewDistributionSpecifying] = [ statusBarHeight.fixed, 1.flexible ]
for subview in [unspecifiedView, playbackView, spatialView, forceLeftToRightView, forceRightToLeftView] {
subview.frame.size = .init(width: 200, height: 32)
distributionSpecifiers.append(subview)
distributionSpecifiers.append(1.flexible)
}
applySubviewDistribution(distributionSpecifiers)
applyVerticalSubviewDistribution(distributionSpecifiers)
}

}
Expand Down Expand Up @@ -125,7 +125,7 @@ private extension UserIntefaceDirectionViewController {
// MARK: - UIView

override func layoutSubviews() {
applySubviewDistribution(subviews, axis: .horizontal)
applyHorizontalSubviewDistribution(subviews)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ extension ViewAccessibilityPropertiesViewController {
distributionSpecifiers.append(subview)
distributionSpecifiers.append(1.flexible)
}
applySubviewDistribution(distributionSpecifiers)
applyVerticalSubviewDistribution(distributionSpecifiers)
}

}
Expand Down
Loading

0 comments on commit 4dd31c3

Please sign in to comment.