Skip to content

Commit

Permalink
Merge branch 'main' into @kkafar/android-linter-2
Browse files Browse the repository at this point in the history
  • Loading branch information
kkafar committed Jun 19, 2024
2 parents 2da47f6 + 81cd573 commit da33b62
Show file tree
Hide file tree
Showing 21 changed files with 702 additions and 45 deletions.
4 changes: 2 additions & 2 deletions Example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNScreens (3.31.1):
- RNScreens (3.32.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1486,7 +1486,7 @@ SPEC CHECKSUMS:
ReactCommon: f42444e384d82ab89184aed5d6f3142748b54768
RNGestureHandler: 2282cfbcf86c360d29f44ace393203afd5c6cff7
RNReanimated: 7ad0f08a845cb60955ee5d461d2156d7b9707118
RNScreens: 83bd0cc27e5d22a58e1bdd560d0e1318e1583b41
RNScreens: 5aeecbb09aa7285379b6e9f3c8a3c859bb16401c
RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372
Expand Down
10 changes: 5 additions & 5 deletions FabricExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNScreens (3.31.1):
- RNScreens (3.32.0):
- DoubleConversion
- glog
- hermes-engine
Expand All @@ -1295,9 +1295,9 @@ PODS:
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- RNScreens/common (= 3.31.1)
- RNScreens/common (= 3.32.0)
- Yoga
- RNScreens/common (3.31.1):
- RNScreens/common (3.32.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1522,7 +1522,7 @@ SPEC CHECKSUMS:
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
hermes-engine: 16b8530de1b383cdada1476cf52d1b52f0692cbc
RCT-Folly: 045d6ecaa59d826c5736dfba0b2f4083ff8d79df
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
RCTDeprecation: efb313d8126259e9294dc4ee0002f44a6f676aba
RCTRequired: f49ea29cece52aee20db633ae7edc4b271435562
RCTTypeSafety: a11979ff0570d230d74de9f604f7d19692157bc4
Expand Down Expand Up @@ -1573,7 +1573,7 @@ SPEC CHECKSUMS:
ReactCommon: f42444e384d82ab89184aed5d6f3142748b54768
RNGestureHandler: 156548e18203327173a764c6932a3f52e90cb9cd
RNReanimated: 2f33b2f8c79c456ce3858a7cd2e07460eb5f61e0
RNScreens: 677b8292cba019c77fa6740dfe248c232d819e91
RNScreens: d3d50aa84db4541eee00fbb1f32151030f56c510
RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372
Expand Down
8 changes: 4 additions & 4 deletions FabricTestExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNScreens (3.31.1):
- RNScreens (3.32.0):
- DoubleConversion
- glog
- hermes-engine
Expand All @@ -1293,9 +1293,9 @@ PODS:
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- RNScreens/common (= 3.31.1)
- RNScreens/common (= 3.32.0)
- Yoga
- RNScreens/common (3.31.1):
- RNScreens/common (3.32.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1562,7 +1562,7 @@ SPEC CHECKSUMS:
ReactCommon: f42444e384d82ab89184aed5d6f3142748b54768
RNGestureHandler: 156548e18203327173a764c6932a3f52e90cb9cd
RNReanimated: 2f33b2f8c79c456ce3858a7cd2e07460eb5f61e0
RNScreens: 677b8292cba019c77fa6740dfe248c232d819e91
RNScreens: d3d50aa84db4541eee00fbb1f32151030f56c510
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Screens are already integrated with the React Native's most popular navigation l

| library version | react-native version |
| ------- | -------------------- |
| 3.32.0+ | 0.71.0+ |
| 3.30.0+ | 0.68.0+ |
| 3.14.0+ | 0.64.0+ |
| 3.0.0+ | 0.62.0+ |
Expand All @@ -119,6 +120,7 @@ Here's a table with summary of supported `react-native` versions when Fabric is

| library version | react-native version |
| ------- | -------------------- |
| 3.32.0+ | 0.74.0+ |
| 3.28.0+ | 0.73.0+ |
| 3.21.0+ | 0.72.0+ |
| 3.19.0+ | 0.71.0+ |
Expand Down
8 changes: 4 additions & 4 deletions TVOSExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNScreens (3.31.1):
- RNScreens (3.32.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1402,10 +1402,10 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: 88202336c3ba1e7a264a83c0c888784b0f360c28
DoubleConversion: 00143ab27d470b28035933623e1a3ea37e68889c
DoubleConversion: cde416483dac037923206447da6e1454df403714
FBLazyVector: f13c7f203117288def36bfc9a195216ff4fea859
fmt: 1568fa7b2f242362c45c42d4a15e9dd4b2e621b3
glog: f0ddebfc00a905e9213e37801095a0a705d2e5f6
glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3
hermes-engine: 075dd41a8f260f99d7c5c77ad79b0b9632ee920d
RCT-Folly: b54b39c7532acfa0216d988bdeb706883e71416e
RCTDeprecation: a6e6151fa6cb426065ec2997b746fe76e079db8d
Expand Down Expand Up @@ -1457,7 +1457,7 @@ SPEC CHECKSUMS:
ReactCommon: 678c6fdb479e7533859f29000d899af37d3a6c7a
RNGestureHandler: 2282cfbcf86c360d29f44ace393203afd5c6cff7
RNReanimated: 7ad0f08a845cb60955ee5d461d2156d7b9707118
RNScreens: 83bd0cc27e5d22a58e1bdd560d0e1318e1583b41
RNScreens: 5aeecbb09aa7285379b6e9f3c8a3c859bb16401c
RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: d84d1e521e3f8fa3cdd139d617ddf6514d061c78
Expand Down
4 changes: 2 additions & 2 deletions TestsExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNScreens (3.31.1):
- RNScreens (3.32.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1475,7 +1475,7 @@ SPEC CHECKSUMS:
ReactCommon: f42444e384d82ab89184aed5d6f3142748b54768
RNGestureHandler: 2282cfbcf86c360d29f44ace393203afd5c6cff7
RNReanimated: 7ad0f08a845cb60955ee5d461d2156d7b9707118
RNScreens: 83bd0cc27e5d22a58e1bdd560d0e1318e1583b41
RNScreens: 5aeecbb09aa7285379b6e9f3c8a3c859bb16401c
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372

Expand Down
21 changes: 19 additions & 2 deletions android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,27 @@ import com.facebook.react.module.annotations.ReactModuleList
import com.facebook.react.module.model.ReactModuleInfo
import com.facebook.react.module.model.ReactModuleInfoProvider
import com.facebook.react.uimanager.ViewManager
import com.swmansion.rnscreens.utils.ScreenDummyLayoutHelper

@ReactModuleList(
nativeModules = [
ScreensModule::class,
],
)
class RNScreensPackage : TurboReactPackage() {
override fun createViewManagers(reactContext: ReactApplicationContext) =
listOf<ViewManager<*, *>>(
// We just retain it here. This object helps us tackle jumping content when using native header.
// See: https://github.com/software-mansion/react-native-screens/pull/2169
private var screenDummyLayoutHelper: ScreenDummyLayoutHelper? = null

override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
// This is the earliest we lay our hands on react context.
// Moreover this is called before FabricUIManger has finished initializing, not to mention
// installing its C++ bindings - so we are safe in terms of creating this helper
// before RN starts creating shadow nodes.
// See https://github.com/software-mansion/react-native-screens/pull/2169
screenDummyLayoutHelper = ScreenDummyLayoutHelper(reactContext)

return listOf<ViewManager<*, *>>(
ScreenContainerViewManager(),
ScreenViewManager(),
ModalScreenViewManager(),
Expand All @@ -24,6 +36,7 @@ class RNScreensPackage : TurboReactPackage() {
ScreenStackHeaderSubviewManager(),
SearchBarManager(),
)
}

override fun getModule(
s: String,
Expand Down Expand Up @@ -51,4 +64,8 @@ class RNScreensPackage : TurboReactPackage() {
)
moduleInfos
}

companion object {
const val TAG = "RNScreensPackage"
}
}
29 changes: 24 additions & 5 deletions android/src/main/java/com/swmansion/rnscreens/Screen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class Screen(
val height = b - t

val headerHeight = calculateHeaderHeight()
val totalHeight = headerHeight.first + headerHeight.second // action bar height + status bar height
val totalHeight =
headerHeight.first + headerHeight.second // action bar height + status bar height
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
updateScreenSizeFabric(width, height, totalHeight)
} else {
Expand Down Expand Up @@ -187,7 +188,13 @@ class Screen(
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
Expand Down Expand Up @@ -220,7 +227,13 @@ class Screen(
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
Expand All @@ -229,7 +242,12 @@ class Screen(
ScreenWindowTraits.applyDidSetNavigationBarAppearance()
}
field = navigationBarColor
fragmentWrapper?.let { ScreenWindowTraits.setNavigationBarColor(this, it.tryGetActivity()) }
fragmentWrapper?.let {
ScreenWindowTraits.setNavigationBarColor(
this,
it.tryGetActivity()
)
}
}

var isNavigationBarTranslucent: Boolean? = null
Expand Down Expand Up @@ -264,7 +282,8 @@ class Screen(

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class ScreenStackHeaderConfig(
toolbar.contentInsetStartWithNavigation = 0
}

val titleTextView = titleTextView
val titleTextView = findTitleTextViewInToolbar(toolbar)
if (titleColor != 0) {
toolbar.setTitleTextColor(titleColor)
}
Expand Down Expand Up @@ -332,19 +332,6 @@ class ScreenStackHeaderConfig(
maybeUpdate()
}

private val titleTextView: TextView?
get() {
for (i in 0 until toolbar.childCount) {
val view = toolbar.getChildAt(i)
if (view is TextView) {
if (view.text == toolbar.title) {
return view
}
}
}
return null
}

fun setTitle(title: String?) {
this.title = title
}
Expand Down Expand Up @@ -427,4 +414,18 @@ class ScreenStackHeaderConfig(
}
toolbar.clipChildren = false
}

companion object {
fun findTitleTextViewInToolbar(toolbar: Toolbar): TextView? {
for (i in 0 until toolbar.childCount) {
val view = toolbar.getChildAt(i)
if (view is TextView) {
if (view.text == toolbar.title) {
return view
}
}
}
return null
}
}
}
Loading

0 comments on commit da33b62

Please sign in to comment.