Skip to content
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

Support React Native 0.73 #2671

Merged
merged 20 commits into from
Nov 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Format android
j-piasecki committed Nov 23, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2f178642832a5c47135162ab51db8300b2427372
Original file line number Diff line number Diff line change
@@ -5,26 +5,26 @@ import com.facebook.react.uimanager.PixelUtil
import com.swmansion.gesturehandler.core.FlingGestureHandler

class FlingGestureHandlerEventDataBuilder(handler: FlingGestureHandler) : GestureHandlerEventDataBuilder<FlingGestureHandler>(handler) {
private val x: Float
private val y: Float
private val absoluteX: Float
private val absoluteY: Float
private val x: Float
private val y: Float
private val absoluteX: Float
private val absoluteY: Float

init {
x = handler.lastRelativePositionX
y = handler.lastRelativePositionY
absoluteX = handler.lastPositionInWindowX
absoluteY = handler.lastPositionInWindowY
}
init {
x = handler.lastRelativePositionX
y = handler.lastRelativePositionY
absoluteX = handler.lastPositionInWindowX
absoluteY = handler.lastPositionInWindowY
}

override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)
override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)

with(eventData) {
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
}
with(eventData) {
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -5,26 +5,26 @@ import com.facebook.react.uimanager.PixelUtil
import com.swmansion.gesturehandler.core.HoverGestureHandler

class HoverGestureHandlerEventDataBuilder(handler: HoverGestureHandler) : GestureHandlerEventDataBuilder<HoverGestureHandler>(handler) {
private val x: Float
private val y: Float
private val absoluteX: Float
private val absoluteY: Float
private val x: Float
private val y: Float
private val absoluteX: Float
private val absoluteY: Float

init {
x = handler.lastRelativePositionX
y = handler.lastRelativePositionY
absoluteX = handler.lastPositionInWindowX
absoluteY = handler.lastPositionInWindowY
}
init {
x = handler.lastRelativePositionX
y = handler.lastRelativePositionY
absoluteX = handler.lastPositionInWindowX
absoluteY = handler.lastPositionInWindowY
}

override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)
override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)

with(eventData) {
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
}
with(eventData) {
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -5,29 +5,29 @@ import com.facebook.react.uimanager.PixelUtil
import com.swmansion.gesturehandler.core.LongPressGestureHandler

class LongPressGestureHandlerEventDataBuilder(handler: LongPressGestureHandler) : GestureHandlerEventDataBuilder<LongPressGestureHandler>(handler) {
private val x: Float
private val y: Float
private val absoluteX: Float
private val absoluteY: Float
private val duration: Int
private val x: Float
private val y: Float
private val absoluteX: Float
private val absoluteY: Float
private val duration: Int

init {
x = handler.lastRelativePositionX
y = handler.lastRelativePositionY
absoluteX = handler.lastPositionInWindowX
absoluteY = handler.lastPositionInWindowY
duration = handler.duration
}
init {
x = handler.lastRelativePositionX
y = handler.lastRelativePositionY
absoluteX = handler.lastPositionInWindowX
absoluteY = handler.lastPositionInWindowY
duration = handler.duration
}

override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)
override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)

with(eventData) {
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
putInt("duration", duration)
}
with(eventData) {
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
putInt("duration", duration)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -2,4 +2,4 @@ package com.swmansion.gesturehandler.react.eventbuilders

import com.swmansion.gesturehandler.core.ManualGestureHandler

class ManualGestureHandlerEventDataBuilder(handler: ManualGestureHandler) : GestureHandlerEventDataBuilder<ManualGestureHandler>(handler) {}
class ManualGestureHandlerEventDataBuilder(handler: ManualGestureHandler) : GestureHandlerEventDataBuilder<ManualGestureHandler>(handler)
Original file line number Diff line number Diff line change
@@ -4,15 +4,15 @@ import com.facebook.react.bridge.WritableMap
import com.swmansion.gesturehandler.core.NativeViewGestureHandler

class NativeGestureHandlerEventDataBuilder(handler: NativeViewGestureHandler) : GestureHandlerEventDataBuilder<NativeViewGestureHandler>(handler) {
private val pointerInside: Boolean
private val pointerInside: Boolean

init {
pointerInside = handler.isWithinBounds
}
init {
pointerInside = handler.isWithinBounds
}

override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)
override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)

eventData.putBoolean("pointerInside", pointerInside)
}
}
eventData.putBoolean("pointerInside", pointerInside)
}
}
Original file line number Diff line number Diff line change
@@ -5,38 +5,38 @@ import com.facebook.react.uimanager.PixelUtil
import com.swmansion.gesturehandler.core.PanGestureHandler

class PanGestureHandlerEventDataBuilder(handler: PanGestureHandler) : GestureHandlerEventDataBuilder<PanGestureHandler>(handler) {
private val x: Float
private val y: Float
private val absoluteX: Float
private val absoluteY: Float
private val translationX: Float
private val translationY: Float
private val velocityX: Float
private val velocityY: Float
private val x: Float
private val y: Float
private val absoluteX: Float
private val absoluteY: Float
private val translationX: Float
private val translationY: Float
private val velocityX: Float
private val velocityY: Float

init {
x = handler.lastRelativePositionX
y = handler.lastRelativePositionY
absoluteX = handler.lastPositionInWindowX
absoluteY = handler.lastPositionInWindowY
translationX = handler.translationX
translationY = handler.translationY
velocityX = handler.velocityX
velocityY = handler.velocityY
}
init {
x = handler.lastRelativePositionX
y = handler.lastRelativePositionY
absoluteX = handler.lastPositionInWindowX
absoluteY = handler.lastPositionInWindowY
translationX = handler.translationX
translationY = handler.translationY
velocityX = handler.velocityX
velocityY = handler.velocityY
}

override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)
override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)

with(eventData) {
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
putDouble("translationX", PixelUtil.toDIPFromPixel(translationX).toDouble())
putDouble("translationY", PixelUtil.toDIPFromPixel(translationY).toDouble())
putDouble("velocityX", PixelUtil.toDIPFromPixel(velocityX).toDouble())
putDouble("velocityY", PixelUtil.toDIPFromPixel(velocityY).toDouble())
}
with(eventData) {
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
putDouble("translationX", PixelUtil.toDIPFromPixel(translationX).toDouble())
putDouble("translationY", PixelUtil.toDIPFromPixel(translationY).toDouble())
putDouble("velocityX", PixelUtil.toDIPFromPixel(velocityX).toDouble())
putDouble("velocityY", PixelUtil.toDIPFromPixel(velocityY).toDouble())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -5,26 +5,26 @@ import com.facebook.react.uimanager.PixelUtil
import com.swmansion.gesturehandler.core.PinchGestureHandler

class PinchGestureHandlerEventDataBuilder(handler: PinchGestureHandler) : GestureHandlerEventDataBuilder<PinchGestureHandler>(handler) {
private val scale: Double
private val focalX: Float
private val focalY: Float
private val velocity: Double
private val scale: Double
private val focalX: Float
private val focalY: Float
private val velocity: Double

init {
scale = handler.scale
focalX = handler.focalPointX
focalY = handler.focalPointY
velocity = handler.velocity
}
init {
scale = handler.scale
focalX = handler.focalPointX
focalY = handler.focalPointY
velocity = handler.velocity
}

override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)
override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)

with(eventData) {
putDouble("scale", scale)
putDouble("focalX", PixelUtil.toDIPFromPixel(focalX).toDouble())
putDouble("focalY", PixelUtil.toDIPFromPixel(focalY).toDouble())
putDouble("velocity", velocity)
}
with(eventData) {
putDouble("scale", scale)
putDouble("focalX", PixelUtil.toDIPFromPixel(focalX).toDouble())
putDouble("focalY", PixelUtil.toDIPFromPixel(focalY).toDouble())
putDouble("velocity", velocity)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -5,26 +5,26 @@ import com.facebook.react.uimanager.PixelUtil
import com.swmansion.gesturehandler.core.RotationGestureHandler

class RotationGestureHandlerEventDataBuilder(handler: RotationGestureHandler) : GestureHandlerEventDataBuilder<RotationGestureHandler>(handler) {
private val rotation: Double
private val anchorX: Float
private val anchorY: Float
private val velocity: Double
private val rotation: Double
private val anchorX: Float
private val anchorY: Float
private val velocity: Double

init {
rotation = handler.rotation
anchorX = handler.anchorX
anchorY = handler.anchorY
velocity = handler.velocity
}
init {
rotation = handler.rotation
anchorX = handler.anchorX
anchorY = handler.anchorY
velocity = handler.velocity
}

override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)
override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)

with(eventData) {
putDouble("scale", rotation)
putDouble("focalX", PixelUtil.toDIPFromPixel(anchorX).toDouble())
putDouble("focalY", PixelUtil.toDIPFromPixel(anchorY).toDouble())
putDouble("velocity", velocity)
}
with(eventData) {
putDouble("scale", rotation)
putDouble("focalX", PixelUtil.toDIPFromPixel(anchorX).toDouble())
putDouble("focalY", PixelUtil.toDIPFromPixel(anchorY).toDouble())
putDouble("velocity", velocity)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -5,26 +5,26 @@ import com.facebook.react.uimanager.PixelUtil
import com.swmansion.gesturehandler.core.TapGestureHandler

class TapGestureHandlerEventDataBuilder(handler: TapGestureHandler) : GestureHandlerEventDataBuilder<TapGestureHandler>(handler) {
private val x: Float
private val y: Float
private val absoluteX: Float
private val absoluteY: Float
private val x: Float
private val y: Float
private val absoluteX: Float
private val absoluteY: Float

init {
x = handler.lastRelativePositionX
y = handler.lastRelativePositionY
absoluteX = handler.lastPositionInWindowX
absoluteY = handler.lastPositionInWindowY
}
init {
x = handler.lastRelativePositionX
y = handler.lastRelativePositionY
absoluteX = handler.lastPositionInWindowX
absoluteY = handler.lastPositionInWindowY
}

override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)
override fun buildEventData(eventData: WritableMap) {
super.buildEventData(eventData)

with(eventData) {
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
}
with(eventData) {
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
}
}
}
}

Unchanged files with check annotations Beta

renderSectionHeader={({ section: { sectionTitle } }) => (
<Text style={styles.sectionTitle}>{sectionTitle}</Text>
)}
ItemSeparatorComponent={() => <View style={styles.separator} />}

Check warning on line 200 in example/src/App.tsx

GitHub Actions / check (example)

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “MainScreen” and pass data as props. If you want to allow component creation in props, set allowAsProps option to true
/>
);
}
render() {
return (
<View style={styles.view}>
<Text style={{ textAlign: 'center', width: '80%' }}>

Check warning on line 34 in example/src/basic/forcetouch/index.tsx

GitHub Actions / check (example)

Inline style: { textAlign: 'center', width: '80%' }
{' '}
Force touch works only on some Apple devices (iPhones 6s+ excluding
XR) and should be used only as a supportive one{' '}
static platforms = ['android'];
render() {
const navigationView = (
<View style={{ flex: 1, backgroundColor: '#fff' }}>

Check warning on line 29 in example/src/basic/pagerAndDrawer/index.android.tsx

GitHub Actions / check (example)

Inline style: { flex: 1, backgroundColor: '#fff' }
<Text style={{ margin: 10, fontSize: 15, textAlign: 'left' }}>

Check warning on line 30 in example/src/basic/pagerAndDrawer/index.android.tsx

GitHub Actions / check (example)

Inline style: { margin: 10, fontSize: 15, textAlign: 'left' }
I&apos;m in the Drawer!
</Text>
</View>
return;
}
for (const snapPoint of SNAP_POINTS_FROM_TOP) {

Check warning on line 56 in example/src/new_api/bottom_sheet/index.tsx

GitHub Actions / check (example)

'snapPoint' is already declared in the upper scope
const distFromSnap = Math.abs(snapPoint - endOffsetY);
if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
destSnapPoint = snapPoint;
export default function CalculatorUI() {
const outputOffset = useSharedValue(0);
const [history, setHistory] = useState(Array<string>());

Check warning on line 30 in example/src/new_api/calculator/index.tsx

GitHub Actions / check (example)

The array literal notation [] is preferable
const [expression, setExpression] = useState('');
function measure({
scrollView.current = ref;
}}
enabled={opened}
contentContainerStyle={{ flexGrow: 1 }}>

Check warning on line 141 in example/src/new_api/calculator/index.tsx

GitHub Actions / check (example)

Inline style: { flexGrow: 1 }
<View style={{ flexGrow: 1 }} />

Check warning on line 142 in example/src/new_api/calculator/index.tsx

GitHub Actions / check (example)

Inline style: { flexGrow: 1 }
{history.map((exp: string) => {
return <Expression expression={exp} key={exp} />;
}
function updateSelectedFilter() {
const selectedFilter = Math.round(

Check warning on line 101 in example/src/new_api/camera/index.tsx

GitHub Actions / check (example)

'selectedFilter' is already declared in the upper scope
Math.min(filters.length - 1, Math.max(filter.value, 0))
);
setSelectedFilter(selectedFilter);
// hover4.simultaneousWithExternalGesture(hover5);
return (
<View style={{ flex: 1 }}>

Check warning on line 55 in example/src/new_api/hover/index.tsx

GitHub Actions / check (example)

Inline style: { flex: 1 }
<Text>Parent & child</Text>
<GestureDetector gesture={hover1}>
<Animated.View
export default function App() {
return (
<GestureHandlerRootView style={{ flex: 1 }}>

Check warning on line 52 in FabricExample/src/App.tsx

GitHub Actions / check (FabricExample)

Inline style: { flex: 1 }
<SafeAreaView style={{ flex: 1 }}>

Check warning on line 53 in FabricExample/src/App.tsx

GitHub Actions / check (FabricExample)

Inline style: { flex: 1 }
<Stack.Navigator initialRouteName="home" />
</SafeAreaView>
</GestureHandlerRootView>
if (
RNGestureHandlerModule &&
RNGestureHandlerModule.flushOperations === undefined

Check warning on line 21 in src/RNGestureHandlerModule.ts

GitHub Actions / check

Unsafe member access .flushOperations on an `any` value
) {
RNGestureHandlerModule.flushOperations = () => {

Check warning on line 23 in src/RNGestureHandlerModule.ts

GitHub Actions / check

Unsafe member access .flushOperations on an `any` value
// NO-OP if not defined
};
}
export const RNRenderer = {
findHostInstance_DEPRECATED: (_ref: any) => null,

Check warning on line 2 in src/RNRenderer.web.ts

GitHub Actions / check

Unexpected any. Specify a different type
};
);
const dragOffsetFromOnStartPosition = startPositionX.interpolate({
inputRange: [drawerWidth! - 1, drawerWidth!, drawerWidth! + 1],

Check warning on line 322 in src/components/DrawerLayout.tsx

GitHub Actions / check

Forbidden non-null assertion

Check warning on line 322 in src/components/DrawerLayout.tsx

GitHub Actions / check

Forbidden non-null assertion

Check warning on line 322 in src/components/DrawerLayout.tsx

GitHub Actions / check

Forbidden non-null assertion
outputRange: [0, 0, 1],
});
translationX = Animated.add(
}
this.openValue = Animated.add(translationX, drawerTranslation).interpolate({
inputRange: [0, drawerWidth!],

Check warning on line 332 in src/components/DrawerLayout.tsx

GitHub Actions / check

Forbidden non-null assertion
outputRange: [0, 1],
extrapolate: 'clamp',
});
ev: NativeSyntheticEvent<PanGestureHandlerEventPayload>
) => void;
} = {
useNativeDriver: props.useNativeAnimations!,

Check warning on line 344 in src/components/DrawerLayout.tsx

GitHub Actions / check

Forbidden non-null assertion
};
if (this.props.onDrawerSlide) {
if (drawerType === 'front') {
dragOffsetBasedOnStart =
gestureStartX > drawerWidth! ? gestureStartX - drawerWidth! : 0;

Check warning on line 422 in src/components/DrawerLayout.tsx

GitHub Actions / check

Forbidden non-null assertion

Check warning on line 422 in src/components/DrawerLayout.tsx

GitHub Actions / check

Forbidden non-null assertion
}
const startOffsetX =