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

Migration from hammer #2157

Merged
merged 43 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
fe6584c
Initial commit
m-bert Jul 21, 2022
68f5abc
test commit
m-bert Jul 21, 2022
f37b37a
access test
m-bert Jul 22, 2022
8b6eef6
test commit
m-bert Jul 22, 2022
6d04613
access test 2
m-bert Jul 22, 2022
9321d6d
Interface manager
m-bert Jul 22, 2022
aa66f83
Orchestrator logic
m-bert Jul 25, 2022
1117f68
Wotking DoubleTap
m-bert Jul 26, 2022
cc63c83
Long-double-single
m-bert Jul 27, 2022
870e8f5
Simultaneous bugfix
m-bert Jul 27, 2022
c03fab0
Pinch fix and rotation
m-bert Jul 29, 2022
a42ebf2
Rotation fix
m-bert Aug 1, 2022
570b1e9
Bouncing box fix
m-bert Aug 1, 2022
51c39fe
Pan velocity fix
m-bert Aug 2, 2022
012ad1b
Added native view
m-bert Aug 2, 2022
8be0e99
Bringing back hammer
m-bert Aug 3, 2022
d694091
organizing project structure
m-bert Aug 3, 2022
0845d3a
added switching to hammer
m-bert Aug 3, 2022
1a3b54e
First refactor
m-bert Aug 3, 2022
8950599
Second refactor
m-bert Aug 3, 2022
7388889
Double draggable fix
m-bert Aug 5, 2022
220cb88
Tap fix
m-bert Aug 5, 2022
6a3ae99
Removing pointer history
m-bert Aug 8, 2022
932a8fc
Added HitSlops
m-bert Aug 8, 2022
87133da
Types fix
m-bert Aug 8, 2022
6235998
Bringing back old examples
m-bert Aug 9, 2022
afe3c15
SVG fix in pinch and rotate
m-bert Aug 9, 2022
47d66c2
Velocity fix for pan
m-bert Aug 9, 2022
1a86d6e
Added missing import in GestureDetector
m-bert Aug 10, 2022
edb1692
Merge branch 'main' into migration-from-hammer
m-bert Aug 10, 2022
e22c207
Pan custom criteria fix
m-bert Aug 10, 2022
d1a3061
Type fixes in handlers
m-bert Aug 10, 2022
5e7a429
Camera example reset
m-bert Aug 10, 2022
1a425de
Changing Alert to window.alert
m-bert Aug 10, 2022
98a9b2b
Removing unnecessary methods and fields
m-bert Aug 11, 2022
15e1df7
Cosmetic changes (renaming methods, changing typos and removing unnec…
m-bert Aug 11, 2022
b62661d
Ignore Safari callbacks error
m-bert Aug 11, 2022
f0dda33
Fixed misssing event data
m-bert Aug 11, 2022
cbf433d
Adding braces to ifs and other minor cosmetic changes
m-bert Aug 12, 2022
12b5229
Changes in checking new implementation logic
m-bert Aug 16, 2022
48e8382
Import fixes
m-bert Aug 16, 2022
67e6576
Merge branch 'main' into migration-from-hammer
m-bert Aug 19, 2022
b48ae82
Type fix in interfaces
m-bert Aug 19, 2022
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
4 changes: 4 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ import DragNDrop from './new_api/drag_n_drop';
import BetterHorizontalDrawer from './new_api/betterHorizontalDrawer';
import ManualGestures from './new_api/manualGestures/index';

import { enableExperimentalWebImplementation } from 'react-native-gesture-handler';

enableExperimentalWebImplementation();

interface Example {
name: string;
component: React.ComponentType;
Expand Down
8 changes: 5 additions & 3 deletions example/src/basic/multitap/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { StyleSheet, View, Alert, Text } from 'react-native';
import { StyleSheet, View, Text } from 'react-native';

import {
LongPressGestureHandler,
Expand Down Expand Up @@ -28,12 +28,14 @@ export class PressBox extends Component<PressBoxProps> {
};
private onSingleTap = (event: TapGestureHandlerStateChangeEvent) => {
if (event.nativeEvent.state === State.ACTIVE) {
Alert.alert("I'm touched");
// eslint-disable-next-line no-alert
window.alert("I'm touched");
}
};
private onDoubleTap = (event: TapGestureHandlerStateChangeEvent) => {
if (event.nativeEvent.state === State.ACTIVE) {
Alert.alert('Double tap, good job!');
// eslint-disable-next-line no-alert
window.alert('Double tap, good job!');
}
};
render() {
Expand Down
4 changes: 2 additions & 2 deletions example/src/basic/panResponder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
I18nManager,
GestureResponderEvent,
PanResponderGestureState,
Alert,
GestureResponderHandlers,
} from 'react-native';

Expand Down Expand Up @@ -129,7 +128,8 @@ class PanResponderExample extends Component {

export default class Example extends Component {
onClick = () => {
Alert.alert("I'm so touched");
// eslint-disable-next-line no-alert
window.alert("I'm so touched");
};
render() {
return (
Expand Down
13 changes: 8 additions & 5 deletions example/src/new_api/camera/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Alert, StyleSheet, useWindowDimensions } from 'react-native';
import { StyleSheet, useWindowDimensions } from 'react-native';
import { GestureDetector, Gesture } from 'react-native-gesture-handler';
import Animated, {
useSharedValue,
Expand All @@ -21,7 +21,7 @@ export default function Home() {
const [isRecording, setIsRecording] = useState(false);
const [remainingTimeMs, setRemainingTimeMs] = useState(MAX_VIDEO_DURATION_MS);
const [recordingIntervalHandle, setRecordingIntervalHandle] =
useState<ReturnType<typeof setTimeout> | null>(null);
useState<ReturnType<typeof setInterval> | null>(null);

const filtersPanGesture = Gesture.Pan()
.onUpdate((e) => {
Expand Down Expand Up @@ -107,11 +107,13 @@ export default function Home() {
}

function takePhoto() {
Alert.alert('You took a photo');
// eslint-disable-next-line no-alert
window.alert('You took a photo');
}

function takeSeries() {
Alert.alert('You took a series of photos');
// eslint-disable-next-line no-alert
window.alert('You took a series of photos');
}

function startRecording() {
Expand All @@ -129,7 +131,8 @@ export default function Home() {
clearInterval(recordingIntervalHandle!);
setRemainingTimeMs(MAX_VIDEO_DURATION_MS);

Alert.alert(
// eslint-disable-next-line no-alert
window.alert(
`You took a video (${(MAX_VIDEO_DURATION_MS - remainingTimeMs) / 1000} s)`
);
}
Expand Down
8 changes: 6 additions & 2 deletions example/src/recipes/scaleAndRotate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Animated, StyleSheet } from 'react-native';
import { Animated, Platform, StyleSheet } from 'react-native';

import {
PanGestureHandler,
Expand Down Expand Up @@ -135,7 +135,11 @@ export class PinchableBox extends React.Component {
],
},
]}
source={require('./swmansion.png')}
source={
Platform.OS === 'web'
? require('./swm.svg')
: require('./swmansion.png')
}
/>
</Animated.View>
</PinchGestureHandler>
Expand Down
63 changes: 63 additions & 0 deletions example/src/recipes/scaleAndRotate/swm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 14 additions & 8 deletions example/src/release_tests/rows/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Text,
View,
LayoutChangeEvent,
Alert,
} from 'react-native';

import {
Expand Down Expand Up @@ -133,7 +132,8 @@ export const InfoButton = (props: BorderlessButtonProps & { name: string }) => (
<BorderlessButton
{...props}
style={styles.infoButton}
onPress={() => Alert.alert(`${props.name} info button clicked`)}>
// eslint-disable-next-line no-alert
onPress={() => window.alert(`${props.name} info button clicked`)}>
<View style={styles.infoButtonBorders}>
<Text style={styles.infoButtonText}>i</Text>
</View>
Expand All @@ -149,7 +149,8 @@ export default class Example extends Component {
<Swipeable enableTrackpadTwoFingerGesture>
<RectButton
style={styles.rectButton}
onPress={() => Alert.alert('First row clicked')}>
// eslint-disable-next-line no-alert
onPress={() => window.alert('First row clicked')}>
<Text style={styles.buttonText}>
Swipe this row & observe highlight delay
</Text>
Expand All @@ -164,7 +165,8 @@ export default class Example extends Component {
<View style={styles.buttonDelimiter} />
<RectButton
style={styles.rectButton}
onPress={() => Alert.alert('Second row clicked')}>
// eslint-disable-next-line no-alert
onPress={() => window.alert('Second row clicked')}>
<Text style={styles.buttonText}>
Second info icon will block scrolling
</Text>
Expand All @@ -177,7 +179,8 @@ export default class Example extends Component {
<RectButton
rippleColor="red"
style={styles.rectButton}
onPress={() => Alert.alert('Third row clicked')}>
// eslint-disable-next-line no-alert
onPress={() => window.alert('Third row clicked')}>
<Text style={styles.buttonText}>
This one will cancel when you drag outside
</Text>
Expand All @@ -192,7 +195,8 @@ export default class Example extends Component {
<RectButton
enabled={false}
style={styles.rectButton}
onPress={() => Alert.alert('Fourth row clicked')}>
// eslint-disable-next-line no-alert
onPress={() => window.alert('Fourth row clicked')}>
<Text style={styles.buttonText}>
This row is &quot;disabled&quot; but you can swipe it
</Text>
Expand All @@ -201,12 +205,14 @@ export default class Example extends Component {
</Swipeable>
<LongPressGestureHandler
onHandlerStateChange={({ nativeEvent }) =>
nativeEvent.state === State.ACTIVE && Alert.alert('Long')
// eslint-disable-next-line no-alert
nativeEvent.state === State.ACTIVE && window.alert('Long')
}>
<RectButton
rippleColor="red"
style={styles.rectButton}
onPress={() => Alert.alert('Fifth row clicked')}>
// eslint-disable-next-line no-alert
onPress={() => window.alert('Fifth row clicked')}>
<Text style={styles.buttonText}>
Clickable row with long press handler
</Text>
Expand Down
12 changes: 3 additions & 9 deletions example/src/showcase/swipeable/AppleStyleSwipeableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import React, { Component, PropsWithChildren } from 'react';
import {
Animated,
StyleSheet,
Text,
View,
I18nManager,
Alert,
} from 'react-native';
import { Animated, StyleSheet, Text, View, I18nManager } from 'react-native';

import { RectButton } from 'react-native-gesture-handler';

Expand Down Expand Up @@ -51,7 +44,8 @@ export default class AppleStyleSwipeableRow extends Component<
});
const pressHandler = () => {
this.close();
Alert.alert(text);
// eslint-disable-next-line no-alert
window.alert(text);
};

return (
Expand Down
5 changes: 3 additions & 2 deletions example/src/showcase/swipeable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { StyleSheet, Text, View, I18nManager, Alert } from 'react-native';
import { StyleSheet, Text, View, I18nManager } from 'react-native';

import { FlatList, RectButton } from 'react-native-gesture-handler';

Expand All @@ -16,7 +16,8 @@ type DataRow = {
};

const Row = ({ item }: { item: DataRow }) => (
<RectButton style={styles.rectButton} onPress={() => Alert.alert(item.from)}>
// eslint-disable-next-line no-alert
<RectButton style={styles.rectButton} onPress={() => window.alert(item.from)}>
<Text style={styles.fromText}>{item.from}</Text>
<Text numberOfLines={2} style={styles.messageText}>
{item.message}
Expand Down
18 changes: 18 additions & 0 deletions src/EnableExperimentalWebImplementation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
let EXPERIMENTAL_WEB_IMPLEMENTATION = false;
let getWasCalled = false;

export function enableExperimentalWebImplementation(shouldEnable = true): void {
if (getWasCalled) {
console.error(
'Some parts of this application have already started using old gesture handler implementation. No changes will be applied. You can try enabling new implementation earlier.'
);
return;
}

EXPERIMENTAL_WEB_IMPLEMENTATION = shouldEnable;
}

export function isExperimentalWebImplementationEnabled(): boolean {
getWasCalled = true;
return EXPERIMENTAL_WEB_IMPLEMENTATION;
}
Loading