Skip to content

Commit 29ef89b

Browse files
committed
Update spotless to 7.0.3
1 parent 18ce1a6 commit 29ef89b

28 files changed

Lines changed: 276 additions & 334 deletions

File tree

packages/react-native-gesture-handler/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ buildscript {
1212
dependencies {
1313
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
1414
classpath("com.android.tools.build:gradle:7.2.1")
15-
classpath("com.diffplug.spotless:spotless-plugin-gradle:6.7.2")
15+
classpath("com.diffplug.spotless:spotless-plugin-gradle:7.0.3")
1616
}
1717
}
1818

packages/react-native-gesture-handler/android/noreanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import com.facebook.react.bridge.ReactContext
44
import com.facebook.react.uimanager.events.Event
55

66
class ReanimatedEventDispatcher {
7-
@Suppress("UNUSED_PARAMETER", "COMMENT_IN_SUPPRESSION")
87
// This is necessary on new architecture
9-
fun <T : Event<T>>sendEvent(event: T, reactApplicationContext: ReactContext) {
8+
@Suppress("UNUSED_PARAMETER", "COMMENT_IN_SUPPRESSION")
9+
fun <T : Event<T>> sendEvent(event: T, reactApplicationContext: ReactContext) {
1010
// no-op
1111
}
1212
}

packages/react-native-gesture-handler/android/package77/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,41 @@ import com.swmansion.gesturehandler.react.RNGestureHandlerRootViewManager
1616

1717
@ReactModuleList(
1818
nativeModules = [
19-
RNGestureHandlerModule::class
20-
]
19+
RNGestureHandlerModule::class,
20+
],
2121
)
22-
class RNGestureHandlerPackage : BaseReactPackage(), ViewManagerOnDemandReactPackage {
22+
class RNGestureHandlerPackage :
23+
BaseReactPackage(),
24+
ViewManagerOnDemandReactPackage {
2325
private val viewManagers: Map<String, ModuleSpec> by lazy {
2426
mapOf(
2527
RNGestureHandlerRootViewManager.REACT_CLASS to ModuleSpec.viewManagerSpec {
2628
RNGestureHandlerRootViewManager()
2729
},
2830
RNGestureHandlerButtonViewManager.REACT_CLASS to ModuleSpec.viewManagerSpec {
2931
RNGestureHandlerButtonViewManager()
30-
}
32+
},
3133
)
3234
}
3335

34-
override fun createViewManagers(reactContext: ReactApplicationContext) =
35-
listOf<ViewManager<*, *>>(
36-
RNGestureHandlerRootViewManager(),
37-
RNGestureHandlerButtonViewManager()
38-
)
36+
override fun createViewManagers(reactContext: ReactApplicationContext) = listOf<ViewManager<*, *>>(
37+
RNGestureHandlerRootViewManager(),
38+
RNGestureHandlerButtonViewManager(),
39+
)
3940

40-
override fun getViewManagerNames(reactContext: ReactApplicationContext) =
41-
viewManagers.keys.toList()
41+
override fun getViewManagerNames(reactContext: ReactApplicationContext) = viewManagers.keys.toList()
4242

43-
override fun getViewManagers(reactContext: ReactApplicationContext): MutableList<ModuleSpec> =
44-
viewManagers.values.toMutableList()
43+
override fun getViewManagers(reactContext: ReactApplicationContext): MutableList<ModuleSpec> = viewManagers.values.toMutableList()
4544

4645
override fun createViewManager(
4746
reactContext: ReactApplicationContext,
48-
viewManagerName: String
47+
viewManagerName: String,
4948
) = viewManagers[viewManagerName]?.provider?.get() as? ViewManager<*, *>
5049

51-
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
52-
return if (name == RNGestureHandlerModule.NAME) {
53-
RNGestureHandlerModule(reactContext)
54-
} else {
55-
null
56-
}
50+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = if (name == RNGestureHandlerModule.NAME) {
51+
RNGestureHandlerModule(reactContext)
52+
} else {
53+
null
5754
}
5855

5956
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
@@ -72,8 +69,8 @@ class RNGestureHandlerPackage : BaseReactPackage(), ViewManagerOnDemandReactPack
7269
reactModule.canOverrideExistingModule,
7370
reactModule.needsEagerInit,
7471
reactModule.isCxxModule,
75-
true
76-
)
72+
true,
73+
),
7774
)
7875
}
7976
} catch (e: InstantiationException) {

packages/react-native-gesture-handler/android/packageDeprecated/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,41 @@ import com.swmansion.gesturehandler.react.RNGestureHandlerRootViewManager
1616

1717
@ReactModuleList(
1818
nativeModules = [
19-
RNGestureHandlerModule::class
20-
]
19+
RNGestureHandlerModule::class,
20+
],
2121
)
22-
class RNGestureHandlerPackage : BaseReactPackage(), ViewManagerOnDemandReactPackage {
22+
class RNGestureHandlerPackage :
23+
BaseReactPackage(),
24+
ViewManagerOnDemandReactPackage {
2325
private val viewManagers: Map<String, ModuleSpec> by lazy {
2426
mapOf(
2527
RNGestureHandlerRootViewManager.REACT_CLASS to ModuleSpec.viewManagerSpec {
2628
RNGestureHandlerRootViewManager()
2729
},
2830
RNGestureHandlerButtonViewManager.REACT_CLASS to ModuleSpec.viewManagerSpec {
2931
RNGestureHandlerButtonViewManager()
30-
}
32+
},
3133
)
3234
}
3335

34-
override fun createViewManagers(reactContext: ReactApplicationContext) =
35-
listOf<ViewManager<*, *>>(
36-
RNGestureHandlerRootViewManager(),
37-
RNGestureHandlerButtonViewManager()
38-
)
36+
override fun createViewManagers(reactContext: ReactApplicationContext) = listOf<ViewManager<*, *>>(
37+
RNGestureHandlerRootViewManager(),
38+
RNGestureHandlerButtonViewManager(),
39+
)
3940

40-
override fun getViewManagerNames(reactContext: ReactApplicationContext?) =
41-
viewManagers.keys.toList()
41+
override fun getViewManagerNames(reactContext: ReactApplicationContext?) = viewManagers.keys.toList()
4242

43-
override fun getViewManagers(reactContext: ReactApplicationContext?): MutableList<ModuleSpec> =
44-
viewManagers.values.toMutableList()
43+
override fun getViewManagers(reactContext: ReactApplicationContext?): MutableList<ModuleSpec> = viewManagers.values.toMutableList()
4544

4645
override fun createViewManager(
4746
reactContext: ReactApplicationContext?,
48-
viewManagerName: String?
47+
viewManagerName: String?,
4948
) = viewManagers[viewManagerName]?.provider?.get() as? ViewManager<*, *>
5049

51-
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
52-
return if (name == RNGestureHandlerModule.NAME) {
53-
RNGestureHandlerModule(reactContext)
54-
} else {
55-
null
56-
}
50+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = if (name == RNGestureHandlerModule.NAME) {
51+
RNGestureHandlerModule(reactContext)
52+
} else {
53+
null
5754
}
5855

5956
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
@@ -72,8 +69,8 @@ class RNGestureHandlerPackage : BaseReactPackage(), ViewManagerOnDemandReactPack
7269
reactModule.canOverrideExistingModule,
7370
reactModule.needsEagerInit,
7471
reactModule.isCxxModule,
75-
true
76-
)
72+
true,
73+
),
7774
)
7875
}
7976
} catch (e: InstantiationException) {

packages/react-native-gesture-handler/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import com.swmansion.reanimated.ReanimatedModule
77
class ReanimatedEventDispatcher {
88
private var reanimatedModule: ReanimatedModule? = null
99

10-
fun <T : Event<T>>sendEvent(event: T, reactApplicationContext: ReactContext) {
10+
fun <T : Event<T>> sendEvent(event: T, reactApplicationContext: ReactContext) {
1111
if (reanimatedModule == null) {
1212
reanimatedModule = reactApplicationContext.getNativeModule(ReanimatedModule::class.java)
1313
}

packages/react-native-gesture-handler/android/spotless.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ spotless {
55
target "**/*.kt"
66
ktlint().editorConfigOverride([indent_size: 2])
77
trimTrailingWhitespace()
8-
indentWithSpaces()
8+
leadingTabsToSpaces()
99
endWithNewline()
1010
}
1111
}

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
7676
@Suppress("UNCHECKED_CAST")
7777
protected fun self(): ConcreteGestureHandlerT = this as ConcreteGestureHandlerT
7878

79-
protected inline fun applySelf(block: ConcreteGestureHandlerT.() -> Unit): ConcreteGestureHandlerT =
80-
self().apply { block() }
79+
protected inline fun applySelf(block: ConcreteGestureHandlerT.() -> Unit): ConcreteGestureHandlerT = self().apply { block() }
8180

8281
// properties set and accessed only by the orchestrator
8382
var activationIndex = 0
@@ -116,8 +115,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
116115
return false
117116
}
118117

119-
fun setShouldCancelWhenOutside(shouldCancelWhenOutside: Boolean): ConcreteGestureHandlerT =
120-
applySelf { this.shouldCancelWhenOutside = shouldCancelWhenOutside }
118+
fun setShouldCancelWhenOutside(shouldCancelWhenOutside: Boolean): ConcreteGestureHandlerT = applySelf { this.shouldCancelWhenOutside = shouldCancelWhenOutside }
121119

122120
fun setEnabled(enabled: Boolean): ConcreteGestureHandlerT = applySelf {
123121
// Don't cancel handler when not changing the value of the isEnabled, executing it always caused
@@ -131,8 +129,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
131129
isEnabled = enabled
132130
}
133131

134-
fun setManualActivation(manualActivation: Boolean): ConcreteGestureHandlerT =
135-
applySelf { this.manualActivation = manualActivation }
132+
fun setManualActivation(manualActivation: Boolean): ConcreteGestureHandlerT = applySelf { this.manualActivation = manualActivation }
136133

137134
fun setHitSlop(
138135
leftPad: Float,
@@ -157,12 +154,9 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
157154
require(!(hitSlopSet(height) && !hitSlopSet(bottomPad) && !hitSlopSet(topPad))) { "When height is set one of top or bottom pads need to be defined" }
158155
}
159156

160-
fun setHitSlop(padding: Float): ConcreteGestureHandlerT {
161-
return setHitSlop(padding, padding, padding, padding, HIT_SLOP_NONE, HIT_SLOP_NONE)
162-
}
157+
fun setHitSlop(padding: Float): ConcreteGestureHandlerT = setHitSlop(padding, padding, padding, padding, HIT_SLOP_NONE, HIT_SLOP_NONE)
163158

164-
fun setInteractionController(controller: GestureHandlerInteractionController?): ConcreteGestureHandlerT =
165-
applySelf { interactionController = controller }
159+
fun setInteractionController(controller: GestureHandlerInteractionController?): ConcreteGestureHandlerT = applySelf { interactionController = controller }
166160

167161
fun setMouseButton(mouseButton: Int) = apply {
168162
this.mouseButton = mouseButton
@@ -189,13 +183,12 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
189183

190184
protected open fun onPrepare() {}
191185

192-
private fun getActivity(context: Context?): Activity? =
193-
when (context) {
194-
is ReactContext -> context.currentActivity
195-
is Activity -> context
196-
is ContextWrapper -> getActivity(context.baseContext)
197-
else -> null
198-
}
186+
private fun getActivity(context: Context?): Activity? = when (context) {
187+
is ReactContext -> context.currentActivity
188+
is Activity -> context
189+
is ContextWrapper -> getActivity(context.baseContext)
190+
else -> null
191+
}
199192

200193
private fun findNextLocalPointerId(): Int {
201194
var localPointerId = 0
@@ -308,7 +301,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
308301
event.deviceId,
309302
event.edgeFlags,
310303
event.source,
311-
event.flags
304+
event.flags,
312305
)
313306
} catch (e: IllegalArgumentException) {
314307
throw AdaptEventException(this, event, e)
@@ -322,7 +315,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
322315
class AdaptEventException(
323316
handler: GestureHandler<*>,
324317
event: MotionEvent,
325-
e: IllegalArgumentException
318+
e: IllegalArgumentException,
326319
) : Exception(
327320
"""
328321
handler: ${handler::class.simpleName}
@@ -336,7 +329,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
336329
trackedPointers: ${handler.trackedPointerIDs.joinToString(separator = ", ")}
337330
while handling event: $event
338331
""".trimIndent(),
339-
e
332+
e,
340333
)
341334

342335
fun handle(transformedEvent: MotionEvent, sourceEvent: MotionEvent) {
@@ -570,13 +563,11 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
570563
onStateChange(newState, oldState)
571564
}
572565

573-
fun wantEvents(): Boolean {
574-
return isEnabled &&
575-
state != STATE_FAILED &&
576-
state != STATE_CANCELLED &&
577-
state != STATE_END &&
578-
trackedPointersIDsCount > 0
579-
}
566+
fun wantEvents(): Boolean = isEnabled &&
567+
state != STATE_FAILED &&
568+
state != STATE_CANCELLED &&
569+
state != STATE_END &&
570+
trackedPointersIDsCount > 0
580571

581572
open fun shouldRequireToWaitForFailure(handler: GestureHandler<*>): Boolean {
582573
if (handler === this) {
@@ -690,9 +681,9 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
690681
}
691682

692683
/*
693-
* Returns true if the view this handler is attached to is a descendant of the view the other handler
694-
* is attached to and false otherwise.
695-
*/
684+
* Returns true if the view this handler is attached to is a descendant of the view the other handler
685+
* is attached to and false otherwise.
686+
*/
696687
fun isDescendantOf(of: GestureHandler<*>): Boolean {
697688
var view = this.view?.parent as? View
698689
while (view != null) {
@@ -767,12 +758,10 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
767758
*
768759
* This method modifies and transforms the received point.
769760
*/
770-
protected fun transformPoint(point: PointF): PointF {
771-
return orchestrator?.transformPointToViewCoords(this.view, point) ?: run {
772-
point.x = Float.NaN
773-
point.y = Float.NaN
774-
point
775-
}
761+
protected fun transformPoint(point: PointF): PointF = orchestrator?.transformPointToViewCoords(this.view, point) ?: run {
762+
point.x = Float.NaN
763+
point.y = Float.NaN
764+
point
776765
}
777766
fun reset() {
778767
view = null
@@ -865,9 +854,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
865854
}
866855

867856
private var nextEventCoalescingKey: Short = 0
868-
private fun hitSlopSet(value: Float): Boolean {
869-
return !java.lang.Float.isNaN(value)
870-
}
857+
private fun hitSlopSet(value: Float): Boolean = !java.lang.Float.isNaN(value)
871858

872859
fun stateToString(state: Int): String? {
873860
when (state) {
@@ -887,6 +874,6 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
887874
var x: Float,
888875
var y: Float,
889876
var absoluteX: Float,
890-
var absoluteY: Float
877+
var absoluteY: Float,
891878
)
892879
}

0 commit comments

Comments
 (0)