Fix missing InterfaceOrientation rawValue, remove redundant logic - #583
Conversation
| ) | ||
|
|
||
| /* | ||
| * On newest iOS interfaceOrientation will be deduced from [UIWindowScene] of [UIWindow] |
There was a problem hiding this comment.
newest
Please specify versions. This comment will be there in a few years with new iOS and possible new API
| /* | ||
| * On newest iOS interfaceOrientation will be deduced from [UIWindowScene] of [UIWindow] | ||
| * to which our [ComposeWindow] is attached. | ||
| * It's never UIInterfaceOrientationUnknown, if accessed after owning [UIWindow] was made key and visible: |
There was a problem hiding this comment.
It's never UIInterfaceOrientationUnknown
Why it's nullable then? Isn't it adding extra boxing?
There was a problem hiding this comment.
You can write a code, that will end up with accessing this property and getting null. And we don't need to do anything about it.
| // This fixes an interop use case when Compose is embedded in SwiftUi. | ||
| layer.layer.needRedraw() | ||
| } | ||
| super.viewWillTransitionToSize(size, withTransitionCoordinator) |
There was a problem hiding this comment.
Can we just remove this now? I mean after deleting everything aside super call in the last commit
There was a problem hiding this comment.
Actually yes. I'll need it in a branch where I want to make rotation animation not so clunky though. Could remove it altogether until then.
Test: ./gradlew test connectedCheck Bug: 270612487 This is an imported pull request from androidx#583. Resolves #583 Github-Pr-Head-Sha: bdbe4b4 GitOrigin-RevId: c027806 Change-Id: Id251580331a2ddd3999abed175e954372c2be416
Test: ./gradlew test connectedCheck Bug: 270612487 This is an imported pull request from androidx#583. Resolves JetBrains#583 Github-Pr-Head-Sha: bdbe4b4 GitOrigin-RevId: c027806 Change-Id: Id251580331a2ddd3999abed175e954372c2be416
Proposed Changes
Remove UIDeviceOrientation change notifications listening, since it's orthogonal to UIInterfaceOrientation
Differentiate between new and deprecated API for orientation retrieval based on iOS version.
Update orientation composition local inside
viewWillLayout.Orientation update will call
viewWillTransitionToSizefollowed byviewSafeAreaInsetsDidChangeandviewWillLayout. If orientation change happens when app is in background,viewSafeAreaInsetsDidChangeandwillViewLayoutwill still be called after it becomes active, so it's the best place for it.Testing
Test: run regenerate_xcodeproject.sh, launch the app.
Issues Fixed
Fixes: startup crash on xcodegen generated project. Crashes when creating ComposeWindow on iOS in case statusBarOrientation of UIApplication is invalid (usually before UIWindow becomes key and visible). Trying to proactively obtain current interface orientation before view is ready for layout is a bad idea.