Open nullatnothing opened 3 months ago
@nullatnothing are you referring to this bug, right?
Yes
@nullatnothing maybe you know ways how to fix that without using react-native-safe-area-context
? 😅
The reason why I'm asking is because I don't want to depend on another library and want to have as less as possible external dependencies. I've tried to use SafeAreaView
from react-native
but it doesn't give a satisfactory results 😔
@kirillzyusko I've tried all other available modules / views etc. but the only one, that works, is useSafeAreaInsets()
from react-native-safe-area-context
.
An approach could be following:
Here an example:
extension UIApplication { static var insets: UIEdgeInsets { let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene return scene?.windows.first?.safeAreaInsets ?? .zero } }
Here the docs for native safe area insets.
Here is the approach used by RNSafeAreaContext
I've found, that you already have a reference to UIApplication.shared.keyWindow
in the file UIApplication.swift at line 13.
The implementation could be:
static var insets: UIEdgeInsets { return UIApplication.shared.keyWindow?.safeAreaInsets ?? .zero }
Describe the bug On IOS devices in landscape orientation the "up arrow" button on the left and the "Close" button on the right are outside the safe area and covered by the "isle" (front camera on iPhone 15).
Code snippet The error occurs in the file: src/components/KeyboardToolbar/index.tsx at line: 216
Here the code:
The
paddingHorizontal
is declared as constant with a value of 8. On IOS it's required to be dynamic to adapt to safe area padding.Repo for reproducing Create a component with following code:
To Reproduce Steps to reproduce the behavior:
Expected behavior The "up arrow" button on the left and the "Close" button on the right to be within the safe area and not covered by the "isle" (front camera on iPhone 15).
Smartphone (please complete the following information):
Additional context I patched the file: src/components/KeyboardToolbar/index.tsx
with following code: