Android targetSdk 35 update - remove SafeAreaView and use padding#95
Conversation
Remove use of SafeAreaView and ScrollView.contentInsetAdjustmentBehavior prop.
| const hackyPadding = '5%'; | ||
|
|
||
| return ( | ||
| <SafeAreaView style={backgroundStyle}> |
There was a problem hiding this comment.
SafeAreaView is removed
template/App.tsx
Outdated
| }; | ||
|
|
||
| // Note: adding hacky padding to avoid importing rn-safe-area-context library but should not be done in production | ||
| const hackyPadding = '5%'; |
There was a problem hiding this comment.
magic padding is used for both iOS and Android
There was a problem hiding this comment.
See my other comment. Can we not call this 'hackyPadding' but more like 'safePadding' or 'areaPadding' etc.
| backgroundColor={backgroundStyle.backgroundColor} | ||
| /> | ||
| <ScrollView | ||
| contentInsetAdjustmentBehavior="automatic" |
There was a problem hiding this comment.
removed iOS only prop: contentInsetAdjustmentBehavior
template/App.tsx
Outdated
| contentInsetAdjustmentBehavior="automatic" | ||
| style={backgroundStyle}> | ||
| <Header /> | ||
| <View style={{paddingRight: hackyPadding}}> |
There was a problem hiding this comment.
right padding for RN version indicator
template/App.tsx
Outdated
| <View | ||
| style={{ | ||
| backgroundColor: isDarkMode ? Colors.black : Colors.white, | ||
| paddingHorizontal: hackyPadding, |
There was a problem hiding this comment.
left, right padding for content within ScrollView
template/App.tsx
Outdated
| style={{ | ||
| backgroundColor: isDarkMode ? Colors.black : Colors.white, | ||
| paddingHorizontal: hackyPadding, | ||
| paddingBottom: hackyPadding, |
There was a problem hiding this comment.
bottom padding to prevent content overlap with button nav bar
cipolleschi
left a comment
There was a problem hiding this comment.
I personally prefer this alternative because:
- It provides a clear message that SafeAreaView should not be used.
- reduces differences between iOS and Android.
How does this behave in landscape mode?
template/App.tsx
Outdated
| }; | ||
|
|
||
| // Note: adding hacky padding to avoid importing rn-safe-area-context library but should not be done in production | ||
| const hackyPadding = '5%'; |
There was a problem hiding this comment.
See my other comment. Can we not call this 'hackyPadding' but more like 'safePadding' or 'areaPadding' etc.
rename padding variable and add additional context on its use Co-authored-by: Nicola Corti <corti.nico@gmail.com>
|
@cipolleschi ios_hacky_padding_only_land.mp4
|
Summary:
This is an alternative implementation for PR #94 which removes SafeAreaView entirely and uses magic padding for both iOS and Android.
Updating to targetSdk 35 on Android enforces edge-to-edge on Android 15+.
We decided not to use react-native-safe-area-context in the template (PR #84 ) to reduce external dependency although it is the recommendation.
To account for UI overlap, we are using a magic padding value for both iOS and Android in the template.
Also SafeAreaView (iOS only) was removed so same code is used on both platforms.
Changelog:
[ANDROID][CHANGED] - update targetSdk to 35 which will enforce edge-to-edge on Android 15+
[GENERAL][REMOVED] - Removed use of SafeAreaView
Test Plan:
ios_hacky_padding_only.mp4
ios_hacky_padding_only_land.mp4
android_hacky_padding.mp4
android_hacky_padding_land.mp4