-
-
Notifications
You must be signed in to change notification settings - Fork 610
fix(Android, Fabric): jumping content with native header #2169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 21 commits
6b2e6da
2a2e1bc
5c8fd35
581cd7e
fd86a96
fd9b32f
bdfc038
1ff7f95
29a92f3
8b445d8
ed0b6ca
342c27e
7d2c5d8
5ed1933
aadfe60
ecd33f6
14b0724
9df3744
b74618b
1c1f8a0
81805f0
f8a251b
29f6b16
6997c26
f67ba5e
27c6ec9
35f41b7
5d9210a
5221637
73e533f
55418d9
eb36e66
61c42d1
f76a0d9
fcc5415
8ea06ac
8e3362f
608a11c
9884e83
699015e
f465673
51ebbb7
e90f57d
d3da357
c3aab0e
175f49c
02a58c6
2c42d65
8a638c4
dc73577
fc701ef
cc110c5
3746958
e3c2fd8
8fb2709
5938d56
359bc49
54463b4
d31dd00
c5e3c6e
184a527
fbda22e
cb6fe2b
db138f9
a0d15bb
4f34895
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
kkafar marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,7 +66,8 @@ class Screen(context: ReactContext?) : FabricEnabledViewGroup(context) { | |
| val height = b - t | ||
|
|
||
| val headerHeight = calculateHeaderHeight() | ||
| val totalHeight = headerHeight.first + headerHeight.second // action bar height + status bar height | ||
| val totalHeight = | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there any changes in this file? Please remove the formatting from the PR.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a comment there and I wouldn't mind if it has stayed. If you are strongly opinionated here I'm willing to open separate PR with that single line comment 😄 |
||
| headerHeight.first + headerHeight.second // action bar height + status bar height | ||
| if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { | ||
| updateScreenSizeFabric(width, height, totalHeight) | ||
| } else { | ||
|
|
@@ -171,7 +172,13 @@ class Screen(context: ReactContext?) : FabricEnabledViewGroup(context) { | |
| ScreenWindowTraits.applyDidSetStatusBarAppearance() | ||
| } | ||
| field = statusBarStyle | ||
| fragmentWrapper?.let { ScreenWindowTraits.setStyle(this, it.tryGetActivity(), it.tryGetContext()) } | ||
| fragmentWrapper?.let { | ||
| ScreenWindowTraits.setStyle( | ||
| this, | ||
| it.tryGetActivity(), | ||
| it.tryGetContext() | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| var isStatusBarHidden: Boolean? = null | ||
|
|
@@ -204,7 +211,13 @@ class Screen(context: ReactContext?) : FabricEnabledViewGroup(context) { | |
| ScreenWindowTraits.applyDidSetStatusBarAppearance() | ||
| } | ||
| field = statusBarColor | ||
| fragmentWrapper?.let { ScreenWindowTraits.setColor(this, it.tryGetActivity(), it.tryGetContext()) } | ||
| fragmentWrapper?.let { | ||
| ScreenWindowTraits.setColor( | ||
| this, | ||
| it.tryGetActivity(), | ||
| it.tryGetContext() | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| var navigationBarColor: Int? = null | ||
|
|
@@ -213,7 +226,12 @@ class Screen(context: ReactContext?) : FabricEnabledViewGroup(context) { | |
| ScreenWindowTraits.applyDidSetNavigationBarAppearance() | ||
| } | ||
| field = navigationBarColor | ||
| fragmentWrapper?.let { ScreenWindowTraits.setNavigationBarColor(this, it.tryGetActivity()) } | ||
| fragmentWrapper?.let { | ||
| ScreenWindowTraits.setNavigationBarColor( | ||
| this, | ||
| it.tryGetActivity() | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| var isNavigationBarHidden: Boolean? = null | ||
|
|
@@ -234,20 +252,23 @@ class Screen(context: ReactContext?) : FabricEnabledViewGroup(context) { | |
|
|
||
| private fun calculateHeaderHeight(): Pair<Double, Double> { | ||
| val actionBarTv = TypedValue() | ||
| val resolvedActionBarSize = context.theme.resolveAttribute(android.R.attr.actionBarSize, actionBarTv, true) | ||
| val resolvedActionBarSize = | ||
| context.theme.resolveAttribute(android.R.attr.actionBarSize, actionBarTv, true) | ||
|
|
||
| // Check if it's possible to get an attribute from theme context and assign a value from it. | ||
| // Otherwise, the default value will be returned. | ||
| val actionBarHeight = TypedValue.complexToDimensionPixelSize(actionBarTv.data, resources.displayMetrics) | ||
| .takeIf { resolvedActionBarSize && headerConfig?.isHeaderHidden != true && headerConfig?.isHeaderTranslucent != true } | ||
| ?.let { PixelUtil.toDIPFromPixel(it.toFloat()).toDouble() } ?: 0.0 | ||
|
|
||
| val statusBarHeight = context.resources.getIdentifier("status_bar_height", "dimen", "android") | ||
| // Count only status bar when action bar is visible and status bar is not hidden | ||
| .takeIf { it > 0 && isStatusBarHidden != true && actionBarHeight > 0 } | ||
| ?.let { (context.resources::getDimensionPixelSize)(it) } | ||
| ?.let { PixelUtil.toDIPFromPixel(it.toFloat()).toDouble() } | ||
| ?: 0.0 | ||
| val actionBarHeight = | ||
| TypedValue.complexToDimensionPixelSize(actionBarTv.data, resources.displayMetrics) | ||
| .takeIf { resolvedActionBarSize && headerConfig?.isHeaderHidden != true && headerConfig?.isHeaderTranslucent != true } | ||
| ?.let { PixelUtil.toDIPFromPixel(it.toFloat()).toDouble() } ?: 0.0 | ||
|
|
||
| val statusBarHeight = | ||
| context.resources.getIdentifier("status_bar_height", "dimen", "android") | ||
| // Count only status bar when action bar is visible and status bar is not hidden | ||
| .takeIf { it > 0 && isStatusBarHidden != true && actionBarHeight > 0 } | ||
| ?.let { (context.resources::getDimensionPixelSize)(it) } | ||
| ?.let { PixelUtil.toDIPFromPixel(it.toFloat()).toDouble() } | ||
| ?: 0.0 | ||
|
|
||
| return actionBarHeight to statusBarHeight | ||
| } | ||
|
|
||
kkafar marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.