fluentui-apple
fluentui-apple copied to clipboard
UIScreen.main issue
I saw a lot of UIScreen.main in the codebase. As a UI framework, I don't think this is a good implementation.
iOS devices can use external screens, it means your view will not alway in the main screen, we should get screen form window:
extension UIView {
var screen: UIScreen { window?.screen ?? .main }
}
And screen should be accessed from methods like layoutSubviews, sizeThatFits. For example, Separator should access screen in sizeThatFits:
class Separator: UIView {
...
override func sizeThatFits(_ size: CGSize) -> CGSize {
switch orientation {
case .horizontal:
return CGSize(width: size.width, height: screen.devicePixel)
case .vertical:
return CGSize(width: screen.devicePixel, height: size.height)
}
}
Environment Information
-
Platform:
- [x] iOS
- [ ] macOS
Priorities and help requested:
Are you willing to submit a PR to fix? Neutral
Requested priority: Normal
@harrieshin can you take a look at this and help triage the issue?