Skip to content

Rewrite to TS #1327

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

Merged
merged 20 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
54 changes: 54 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"satya164"
],
"settings": {
"react": { "version": "16" },
"import/resolver": {
"babel-module": {}
}
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"env": { "browser": true, "node": true, "jest/globals": true },
"plugins": ["jest"],
"ignorePatterns": ["dist/**/*"],
"rules": {
// temporary, remove after we type internals better
"@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-return": "warn",

// common
"@typescript-eslint/explicit-module-boundary-types": "off",
"import/named": "off",
"react/sort-comp": "off",
"prefer-const": [
"error",
{
"destructuring": "all"
}
],
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
],
"no-redeclare": "off",
"@typescript-eslint/no-redeclare": "error",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-ignore": "allow-with-description",
"ts-expect-error": "allow-with-description"
}
]
}
}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ buck-out/
!debug.keystore

# Expo
/.expo
.expo/
web-build/

# vscode
jsconfig.json
.classpath
.project
.settings/
.vscode

# TS
dist/
97 changes: 57 additions & 40 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
matrix:
include:
- language: objective-c
os: osx
osx_image: xcode12.2
xcode_workspace: './e2e/ios/ExampleE2E.xcworkspace'
xcode_scheme: ExampleE2E
podfile: './e2e/ios/Podfile'
xcode_sdk: iphonesimulator12.4
xcode_destination: platform=iOS Simulator,OS=12.4,name=iPhone X
env: NODE_VERSION=10.19.0
# Fix this config
# - language: objective-c
# os: osx
# osx_image: xcode12.2
# xcode_workspace: './e2e/ios/ExampleE2E.xcworkspace'
# xcode_scheme: ExampleE2E
# podfile: './e2e/ios/Podfile'
# xcode_sdk: iphonesimulator12.4
# xcode_destination: platform=iOS Simulator,OS=12.4,name=iPhone X
# env: NODE_VERSION=10.19.0

branches:
only:
- master
# branches:
# only:
# - master

cache: yarn
# cache: yarn

install:
- nvm --version
- echo $NODE_VERSION
- sudo launchctl limit maxfiles 2048 unlimited
- sudo ulimit -n 10000
- brew tap wix/brew
- brew install applesimutils
- nvm install $NODE_VERSION
- nvm use $NODE_VERSION
- nvm alias default $NODE_VERSION
- brew install yarn --ignore-dependencies
- npm install -g react-native-cli
- npm install -g detox-cli
- yarn
- cd ci/e2e
- yarn
- cd ios
- pod install
- cd ..
- export PRODUCT_BUNDLE_IDENTIFIER="com.swmansion.rn_gesture_handler_example"
- detox build -c ios.sim.release | xcpretty
script:
- detox test -c ios.sim.release --no-color --headless --cleanup
# install:
# - nvm --version
# - echo $NODE_VERSION
# - sudo launchctl limit maxfiles 2048 unlimited
# - sudo ulimit -n 10000
# - brew tap wix/brew
# - brew install applesimutils
# - nvm install $NODE_VERSION
# - nvm use $NODE_VERSION
# - nvm alias default $NODE_VERSION
# - brew install yarn --ignore-dependencies
# - npm install -g react-native-cli
# - npm install -g detox-cli
# - yarn
# - cd ci/e2e
# - yarn
# - cd ios
# - pod install
# - cd ..
# - export PRODUCT_BUNDLE_IDENTIFIER="com.swmansion.rn_gesture_handler_example"
# - detox build -c ios.sim.release | xcpretty
# script:
# - detox test -c ios.sim.release --no-color --headless --cleanup

- language: android
dist: trusty
Expand All @@ -57,8 +58,9 @@ matrix:
components:
- tools
- platform-tools
- build-tools-29.0.2
- build-tools-28.0.3
- android-28
- android-29
install:
- nvm install $NODE_VERSION
- nvm use $NODE_VERSION
Expand All @@ -76,8 +78,8 @@ matrix:
- language: objective-c
os: osx
osx_image: xcode12.2
xcode_workspace: './Example/ios/GestureHandler.xcworkspace'
xcode_scheme: GestureHandler
xcode_workspace: './Example/ios/Example.xcworkspace'
xcode_scheme: Example
podfile: './Example/ios/Podfile'
xcode_sdk: iphonesimulator12.2
xcode_destination: platform=iOS Simulator,OS=12.2,name=iPhone X
Expand Down Expand Up @@ -107,4 +109,19 @@ matrix:
- export PRODUCT_BUNDLE_IDENTIFIER="com.swmansion.rn_gesture_handler_example"

script:
- xcodebuild -workspace ios/GestureHandler.xcworkspace -destination 'platform=iOS Simulator,OS=12.2,name=iPhone X' -scheme GestureHandler -parallelizeTargets -configuration Debug -derivedDataPath ios/build -UseModernBuildSystem=YES
- xcodebuild -workspace ios/Example.xcworkspace -destination 'platform=iOS Simulator,OS=12.2,name=iPhone X' -scheme Example -parallelizeTargets -configuration Debug -derivedDataPath ios/build -UseModernBuildSystem=YES | xcpretty

- language: node_js
node_js:
- 12
cache:
directories:
- node_modules
script:
- yarn
- yarn tsc --noEmit
- yarn lint-check
- cd examples/Example
- yarn
- yarn tsc --noEmit
- yarn lint-check
51 changes: 0 additions & 51 deletions DrawerLayout.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions DrawerLayout.js

This file was deleted.

6 changes: 6 additions & 0 deletions DrawerLayout/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"main": "../dist/src/components/DrawerLayout",
"react-native": "../src/components/DrawerLayout",
"browser": "../src/components/DrawerLayout",
"types": "../dist/src/components/DrawerLayout.d.ts"
}
61 changes: 0 additions & 61 deletions Swipeable.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions Swipeable.js

This file was deleted.

6 changes: 6 additions & 0 deletions Swipeable/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"main": "../dist/src/components/Swipeable",
"react-native": "../src/components/Swipeable",
"browser": "../src/components/Swipeable",
"types": "../dist/src/components/Swipeable.d.ts"
}
6 changes: 0 additions & 6 deletions babel.config.js

This file was deleted.

11 changes: 7 additions & 4 deletions docs/docs/api/components/drawer-layout.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,19 @@ color (default to `"black"`) of a semi-transparent overlay to be displayed on to
function. This attribute is present in the standard implementation already and is one of the required params. Gesture handler version of DrawerLayout make it possible for the function passed as `renderNavigationView` to take an Animated value as a parameter that indicates the progress of drawer opening/closing animation (progress value is 0 when closed and 1 when opened). This can be used by the drawer component to animated its children while the drawer is opening or closing.

### `onDrawerClose`

function. This function is called when the drawer is closed.

### `onDrawerOpen`

function. This function is called when the drawer is opened.

### `onDrawerSlide`

function. This function is called as a drawer sliding open from touch events. The progress of the drawer opening/closing is passed back as 0 when closed and 1 when opened.

### `onDrawerStateChanged`

function. This function is called when the status of the drawer changes. Possible values that can be passed back are: 'Idle', 'Dragging', and 'Settling'.

### `enableTrackpadTwoFingerGesture` (iOS only)
Expand All @@ -85,7 +89,6 @@ component or function. Children is a component which is rendered by default and

## Methods


### `openDrawer(options)`

`openDrawer` can take an optional `options` parameter which is an object, enabling further customization of the open animation.
Expand All @@ -106,14 +109,14 @@ component or function. Children is a component which is rendered by default and

## Example:

See the [drawer example](https://github.com/software-mansion/react-native-gesture-handler/blob/master/examples/Example/horizontalDrawer/index.js) from [GestureHandler Example App](example.md) or view it directly on your phone by visiting [our expo demo](https://snack.expo.io/@adamgrzybowski/react-native-gesture-handler-demo).
See the [drawer example](https://github.com/software-mansion/react-native-gesture-handler/blob/master/examples/Example/horizontalDrawer/index.tsx) from [GestureHandler Example App](example.md) or view it directly on your phone by visiting [our expo demo](https://snack.expo.io/@adamgrzybowski/react-native-gesture-handler-demo).

```js
class Drawerable extends Component {
handleDrawerSlide = status => {
handleDrawerSlide = (status) => {
// outputs a value between 0 and 1
console.log(status);
}
};

renderDrawer = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/components/swipeable.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ method that opens component on right side.

### Example:

See the [swipeable example](https://github.com/software-mansion/react-native-gesture-handler/blob/master/examples/Example/swipeable/index.js) from [GestureHandler Example App](example.md) or view it directly on your phone by visiting [our expo demo](https://snack.expo.io/@adamgrzybowski/react-native-gesture-handler-demo).
See the [swipeable example](https://github.com/software-mansion/react-native-gesture-handler/blob/master/examples/Example/swipeable/index.tsx) from [GestureHandler Example App](example.md) or view it directly on your phone by visiting [our expo demo](https://snack.expo.io/@adamgrzybowski/react-native-gesture-handler-demo).

```js
import React, { Component } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/components/touchables.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ import {
} from 'react-native-gesture-handler';
```

For a comparison of both touchable implementations see our [touchables example](https://github.com/software-mansion/react-native-gesture-handler/blob/master/examples/Example/touchables/index.js)
For a comparison of both touchable implementations see our [touchables example](https://github.com/software-mansion/react-native-gesture-handler/blob/master/examples/Example/touchables/index.tsx)
Loading