Skip to content

Commit

Permalink
fix Android build paper
Browse files Browse the repository at this point in the history
  • Loading branch information
coado committed Nov 28, 2024
1 parent f07b8de commit d6e1597
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ abstract class FabricEnabledHeaderConfigViewGroup(
fun setStateWrapper(wrapper: StateWrapper?) {
mStateWrapper = wrapper
}

fun updatePaddings(
paddingStart: Int,
paddingEnd: Int
) {
// do nothing
}

fun updateHeaderConfigState(
width: Int,
Expand Down Expand Up @@ -49,7 +56,7 @@ abstract class FabricEnabledHeaderConfigViewGroup(
if (abs(lastWidth - realWidth) < DELTA &&
abs(lastHeight - realHeight) < DELTA &&
abs(lastOffsetX - offsetXDip) < DELTA &&
abs(lastOffsetY - offsetY) < DELTA
abs(lastOffsetY - offsetYDip) < DELTA
) {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract class FabricEnabledHeaderSubviewGroup(context: Context?): ViewGroup(con
mStateWrapper = wrapper
}

fun updateSubviewFrameState(
protected fun updateSubviewFrameState(
width: Int,
height: Int,
offsetX: Int,
Expand Down
14 changes: 9 additions & 5 deletions android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ open class CustomToolbar(
b: Int,
) {
super.onLayout(changed, l, t, r, b)
val width = r - l;
val height = b - t;

// our children are already laid out
val contentInsetStart = if (navigationIcon != null) contentInsetStartWithNavigation else contentInsetStart
config.updateHeaderConfigState(width, height, l, t)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
val width = r - l;
val height = b - t;
config.updateHeaderConfigState(width, height, l, t)
} else {
// our children are already laid out
val contentInsetStart = if (navigationIcon != null) contentInsetStartWithNavigation else contentInsetStart
config.updatePaddings(contentInsetStart, contentInsetEnd)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ abstract class FabricEnabledHeaderConfigViewGroup(

fun setStateWrapper(wrapper: StateWrapper?) = Unit

fun updatePaddingsFabric(
fun updateHeaderConfigState(
width: Int,
height: Int,
offsetX: Int,
offsetY: Int
) {
// do nothing
}

fun updatePaddings(
paddingStart: Int,
paddingEnd: Int,
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.swmansion.rnscreens

import android.content.Context
import android.view.ViewGroup
import com.facebook.react.uimanager.StateWrapper

abstract class FabricEnabledHeaderSubviewGroup(context: Context?): ViewGroup(context) {

fun setStateWrapper(wrapper: StateWrapper?) = Unit

protected fun updateSubviewFrameState(
width: Int,
height: Int,
offsetX: Int,
offsetY: Int
) {
// do nothing
}


}

0 comments on commit d6e1597

Please sign in to comment.