deep-linking-sample/Apps/Wikipedia/WMF Framework/UIStackView+SubviewVerification.swift
Javier Cicchelli 9bcdaa697b [Setup] Basic project structure (#1)
This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended.

To summarise this work:
- [x] created a new **Xcode** project;
- [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project;
- [x] created the `Locations` app and also, its `Libraries` package;
- [x] created the `Shared` package to share dependencies between the apps;
- [x] added a `Makefile` file and implemented some **environment** and **help** commands.

Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Reviewed-on: rock-n-code/deep-linking-assignment#1
2023-04-08 18:37:13 +00:00

28 lines
1.3 KiB
Swift

public extension UIView {
func wmf_hasRequiredNonZeroHeightConstraint() -> Bool {
let requiredHeightConstraint = constraints.first(where: {constraint in
guard
type(of: constraint) == NSLayoutConstraint.self,
constraint.firstAttribute == .height,
constraint.priority == UILayoutPriority.required,
constraint.constant != 0
else {
return false
}
return true
})
return (requiredHeightConstraint != nil)
}
}
public extension UIStackView {
func wmf_firstArrangedSubviewWithRequiredNonZeroHeightConstraint() -> UIView? {
return arrangedSubviews.first(where: { arrangedSubview in
return arrangedSubview.wmf_hasRequiredNonZeroHeightConstraint()
})
}
func wmf_anArrangedSubviewHasRequiredNonZeroHeightConstraintAssertString() -> String {
return "\n\nAll stackview arrangedSubview height constraints need to have a priority of < 1000 so the stackview can collapse the 'cell' if the arrangedSubview's isHidden property is set to true. This arrangedSubview was determined to have a required height: \(String(describing: wmf_firstArrangedSubviewWithRequiredNonZeroHeightConstraint())). To fix reduce the priority of its height constraint to < 1000.\n\n"
}
}