Skip to content

Commit 62f7b3d

Browse files
kkafarja1ns
authored andcommitted
chore(Android): update spotless & ktlint (software-mansion#2189)
## Description Encountered some errors (seems they were looking for old CMake version (3.10.2)) & decided to bump these deps as they are long overdue. ## Changes Ktlint: 0.43 -> 1.1.1 spotless 6.11 -> 6.22 ## Checklist - [ ] Ensured that CI passes
1 parent d38b747 commit 62f7b3d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1170
-563
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ buildscript {
1818
dependencies {
1919
classpath('com.android.tools.build:gradle:4.2.2')
2020
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', rnsDefaultKotlinVersion)}"
21-
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.11.0"
21+
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.25.0"
2222
}
2323
}
2424

android/spotless.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'com.diffplug.spotless'
44
spotless {
55
kotlin {
66
target 'src/**/*.kt'
7-
ktlint("0.43.0")
7+
ktlint("1.3.0")
88
trimTrailingWhitespace()
99
indentWithSpaces()
1010
endWithNewline()

android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,31 @@ import com.facebook.react.uimanager.FabricViewStateManager
99
import com.facebook.react.uimanager.PixelUtil
1010
import kotlin.math.abs
1111

12-
abstract class FabricEnabledViewGroup constructor(context: ReactContext?) : ViewGroup(context), FabricViewStateManager.HasFabricViewStateManager {
12+
abstract class FabricEnabledViewGroup constructor(
13+
context: ReactContext?,
14+
) : ViewGroup(context),
15+
FabricViewStateManager.HasFabricViewStateManager {
1316
private val mFabricViewStateManager: FabricViewStateManager = FabricViewStateManager()
1417

1518
private var lastSetWidth = 0f
1619
private var lastSetHeight = 0f
1720

18-
override fun getFabricViewStateManager(): FabricViewStateManager {
19-
return mFabricViewStateManager
20-
}
21+
override fun getFabricViewStateManager(): FabricViewStateManager = mFabricViewStateManager
2122

22-
protected fun updateScreenSizeFabric(width: Int, height: Int, headerHeight: Double) {
23+
protected fun updateScreenSizeFabric(
24+
width: Int,
25+
height: Int,
26+
headerHeight: Double,
27+
) {
2328
updateState(width, height, headerHeight)
2429
}
2530

2631
@UiThread
27-
fun updateState(width: Int, height: Int, headerHeight: Double) {
32+
fun updateState(
33+
width: Int,
34+
height: Int,
35+
headerHeight: Double,
36+
) {
2837
val realWidth: Float = PixelUtil.toDIPFromPixel(width.toFloat())
2938
val realHeight: Float = PixelUtil.toDIPFromPixel(height.toFloat())
3039

android/src/main/java/com/swmansion/rnscreens/CustomSearchView.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import androidx.appcompat.widget.SearchView
77
import androidx.fragment.app.Fragment
88

99
@SuppressLint("ViewConstructor") // Only we construct this view, it is never inflated.
10-
class CustomSearchView(context: Context, fragment: Fragment) : SearchView(context) {
10+
class CustomSearchView(
11+
context: Context,
12+
fragment: Fragment,
13+
) : SearchView(context) {
1114
/*
1215
CustomSearchView uses some variables from SearchView. They are listed below with links to documentation
1316
isIconified - https://developer.android.com/reference/android/widget/SearchView#setIconified(boolean)
1417
maxWidth - https://developer.android.com/reference/android/widget/SearchView#setMaxWidth(int)
1518
setOnSearchClickListener - https://developer.android.com/reference/android/widget/SearchView#setOnSearchClickListener(android.view.View.OnClickListener)
1619
setOnCloseListener - https://developer.android.com/reference/android/widget/SearchView#setOnCloseListener(android.widget.SearchView.OnCloseListener)
17-
*/
20+
*/
1821
private var onCloseListener: OnCloseListener? = null
1922
private var onSearchClickedListener: OnClickListener? = null
2023

android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ import androidx.appcompat.widget.Toolbar
66

77
// This class is used to store config closer to search bar
88
@SuppressLint("ViewConstructor") // Only we construct this view, it is never inflated.
9-
open class CustomToolbar(context: Context, val config: ScreenStackHeaderConfig) : Toolbar(context)
9+
open class CustomToolbar(
10+
context: Context,
11+
val config: ScreenStackHeaderConfig,
12+
) : Toolbar(context)

android/src/main/java/com/swmansion/rnscreens/FragmentBackPressOverrider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import androidx.fragment.app.Fragment
55

66
class FragmentBackPressOverrider(
77
private val fragment: Fragment,
8-
private val onBackPressedCallback: OnBackPressedCallback
8+
private val onBackPressedCallback: OnBackPressedCallback,
99
) {
1010
private var isCallbackAdded: Boolean = false
1111
var overrideBackAction: Boolean = true
@@ -14,7 +14,7 @@ class FragmentBackPressOverrider(
1414
if (!isCallbackAdded && overrideBackAction) {
1515
fragment.activity?.onBackPressedDispatcher?.addCallback(
1616
fragment,
17-
onBackPressedCallback
17+
onBackPressedCallback,
1818
)
1919
isCallbackAdded = true
2020
}

android/src/main/java/com/swmansion/rnscreens/LifecycleHelper.kt

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,23 @@ import androidx.lifecycle.LifecycleObserver
77

88
class LifecycleHelper {
99
private val mViewToLifecycleMap: MutableMap<View, Lifecycle> = HashMap()
10-
private val mRegisterOnLayoutChange: View.OnLayoutChangeListener = object : View.OnLayoutChangeListener {
11-
override fun onLayoutChange(
12-
view: View,
13-
i: Int,
14-
i1: Int,
15-
i2: Int,
16-
i3: Int,
17-
i4: Int,
18-
i5: Int,
19-
i6: Int,
20-
i7: Int
21-
) {
22-
registerViewWithLifecycleOwner(view)
23-
view.removeOnLayoutChangeListener(this)
10+
private val mRegisterOnLayoutChange: View.OnLayoutChangeListener =
11+
object : View.OnLayoutChangeListener {
12+
override fun onLayoutChange(
13+
view: View,
14+
i: Int,
15+
i1: Int,
16+
i2: Int,
17+
i3: Int,
18+
i4: Int,
19+
i5: Int,
20+
i6: Int,
21+
i7: Int,
22+
) {
23+
registerViewWithLifecycleOwner(view)
24+
view.removeOnLayoutChangeListener(this)
25+
}
2426
}
25-
}
2627

2728
private fun registerViewWithLifecycleOwner(view: View) {
2829
val parent = findNearestScreenFragmentAncestor(view)
@@ -54,7 +55,9 @@ class LifecycleHelper {
5455
}
5556
return if (parent != null) {
5657
(parent as Screen).fragment
57-
} else null
58+
} else {
59+
null
60+
}
5861
}
5962
}
6063
}

android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,16 @@ import com.facebook.react.module.model.ReactModuleInfoProvider
99
import com.facebook.react.uimanager.ViewManager
1010
import com.swmansion.rnscreens.utils.ScreenDummyLayoutHelper
1111

12-
1312
@ReactModuleList(
1413
nativeModules = [
15-
ScreensModule::class
16-
]
14+
ScreensModule::class,
15+
],
1716
)
1817
class RNScreensPackage : TurboReactPackage() {
1918
// We just retain it here. This object helps us tackle jumping content when using native header.
2019
// See: https://github.com/software-mansion/react-native-screens/pull/2169
2120
private var screenDummyLayoutHelper: ScreenDummyLayoutHelper? = null
2221

23-
2422
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
2523
// This is the earliest we lay our hands on react context.
2624
// Moreover this is called before FabricUIManger has finished initializing, not to mention
@@ -36,36 +34,36 @@ class RNScreensPackage : TurboReactPackage() {
3634
ScreenStackViewManager(),
3735
ScreenStackHeaderConfigViewManager(),
3836
ScreenStackHeaderSubviewManager(),
39-
SearchBarManager()
37+
SearchBarManager(),
4038
)
4139
}
4240

4341
override fun getModule(
4442
s: String,
45-
reactApplicationContext: ReactApplicationContext
43+
reactApplicationContext: ReactApplicationContext,
4644
): NativeModule? {
4745
when (s) {
4846
ScreensModule.NAME -> return ScreensModule(reactApplicationContext)
4947
}
5048
return null
5149
}
5250

53-
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
54-
return ReactModuleInfoProvider {
51+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider =
52+
ReactModuleInfoProvider {
5553
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
5654
val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
57-
moduleInfos[ScreensModule.NAME] = ReactModuleInfo(
58-
ScreensModule.NAME,
59-
ScreensModule.NAME,
60-
false, // canOverrideExistingModule
61-
false, // needsEagerInit
62-
true, // hasConstants
63-
false, // isCxxModule
64-
isTurboModule
65-
)
55+
moduleInfos[ScreensModule.NAME] =
56+
ReactModuleInfo(
57+
ScreensModule.NAME,
58+
ScreensModule.NAME,
59+
false, // canOverrideExistingModule
60+
false, // needsEagerInit
61+
true, // hasConstants
62+
false, // isCxxModule
63+
isTurboModule,
64+
)
6665
moduleInfos
6766
}
68-
}
6967

7068
companion object {
7169
const val TAG = "RNScreensPackage"

0 commit comments

Comments
 (0)