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

up to date #2

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
91fed79
resolve #2, introduce the disable swipe feature
ambisign-gavin Apr 25, 2020
4666584
Bump lodash from 3.10.1 to 4.17.15
dependabot[bot] Apr 25, 2020
16870fb
Merge pull request #5 from ambisign-gavin/dependabot/npm_and_yarn/lod…
ambisign-gavin Apr 25, 2020
176752c
Bump mixin-deep from 1.3.1 to 1.3.2
dependabot[bot] Apr 25, 2020
8d54703
Merge pull request #3 from ambisign-gavin/dependabot/npm_and_yarn/mix…
ambisign-gavin Apr 25, 2020
d8eb127
Merge pull request #6 from ambisign-gavin/feature/disable-swipe
ambisign-gavin Apr 27, 2020
61ea2bf
change to v0.4.0
ambisign-gavin Apr 27, 2020
05f767c
support react-native 0.62.0 and newer version
ambisign-gavin Feb 19, 2022
587b7d0
Merge pull request #17 from ambisign-gavin/develop-0.5.0
ambisign-gavin Feb 19, 2022
2aff8fb
Bump y18n from 3.2.1 to 4.0.3
dependabot[bot] Feb 19, 2022
e4744f8
Bump ini from 1.3.5 to 1.3.8
dependabot[bot] Feb 19, 2022
398a9e9
Bump tar from 4.4.1 to 4.4.19
dependabot[bot] Feb 19, 2022
4c7b662
Bump lodash from 4.17.15 to 4.17.21
dependabot[bot] Feb 19, 2022
8bedc3d
Bump hosted-git-info from 2.7.1 to 2.8.9
dependabot[bot] Feb 19, 2022
879b49c
fix README
ambisign-gavin Feb 19, 2022
ef43515
0.5.1
ambisign-gavin Feb 19, 2022
9f32417
Merge pull request #19 from ambisign-gavin/dependabot/npm_and_yarn/in…
ambisign-gavin Feb 20, 2022
4eca11c
Merge pull request #18 from ambisign-gavin/dependabot/npm_and_yarn/y1…
ambisign-gavin Feb 20, 2022
922b550
Merge pull request #16 from ambisign-gavin/dependabot/npm_and_yarn/ta…
ambisign-gavin Feb 20, 2022
7c59f8f
Merge pull request #14 from ambisign-gavin/dependabot/npm_and_yarn/ho…
ambisign-gavin Feb 20, 2022
3278689
Merge pull request #13 from ambisign-gavin/dependabot/npm_and_yarn/lo…
ambisign-gavin Feb 20, 2022
72449e0
added the SwipeProvider component
ambisign-gavin Feb 21, 2022
baad83b
fix package-lock.json
ambisign-gavin Feb 21, 2022
249d98e
edit README
ambisign-gavin Feb 25, 2022
082c4ab
Merge pull request #20 from ambisign-gavin/develop/swipeProvider
ambisign-gavin Feb 25, 2022
2f43915
Update README.md
ambisign-gavin Feb 25, 2022
da9cd57
0.6.0
ambisign-gavin Feb 25, 2022
f2d3565
Bump minimist from 1.2.0 to 1.2.6
dependabot[bot] Mar 24, 2022
92c5d07
Merge pull request #21 from ambisign-gavin/dependabot/npm_and_yarn/mi…
ambisign-gavin Mar 28, 2022
24f415c
feat: RTL support (#24)
ambisign-gavin May 1, 2022
d1a3d76
Merge pull request #25 from ambisign-gavin/develop/rtl
ambisign-gavin May 1, 2022
6f1f388
0.6.1
ambisign-gavin May 1, 2022
88e3940
fix the require cycle warning
ambisign-gavin May 8, 2022
95fcae9
feat: support swipeThreshold and disableButtonScale (#28)
ambisign-gavin May 19, 2022
bc4bf85
Merge pull request #29 from ambisign-gavin/fix-28
ambisign-gavin May 19, 2022
f8cf953
0.7.0
ambisign-gavin May 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
5 changes: 1 addition & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"presets": ["react-native"],
"plugins": [
"transform-flow-strip-types",
]
"presets": ["module:metro-react-native-babel-preset", "@babel/preset-flow"]
}
61 changes: 42 additions & 19 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,70 @@
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*
; Ignore polyfills
node_modules/react-native/Libraries/polyfills/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
; These should not be required directly
; require from fbjs/lib instead: require('fbjs/lib/warning')
node_modules/warning/.*

; Ignore polyfills
.*/Libraries/polyfills/.*
; Flow doesn't support platforms
.*/Libraries/Utilities/LoadingView.js

; Ignore dist
.*/dist/*
[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/interface.js
node_modules/react-native/flow/

[options]
emoji=true

module.system=haste
esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

unsafe.enable_getters_and_setters=true
[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
sketchy-number=warn
untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
inexact-spread=warn
unnecessary-invariant=warn
signature-verification-failure=warn
deprecated-utility=error

[strict]
deprecated-type
nonstrict-import
sketchy-null
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import

[version]
^0.56.0
^0.113.0
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tabWidth": 4,
"semi": true,
"printWidth": 120,
"singleQuote": true,
"trailingComma": "es5"
}
146 changes: 134 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ npm i --save react-native-swipe-item

```

- **if you use react-native 0.62.0 or newer version, please install `0.5.0`.**

## Usage

You can use the `SwipeButtonsContainer` to wrap buttons that you want to show when users swipe the item, and pass it to props.

```javascript
import { SwipeItem, SwipeButtonsContainer } from 'react-native-swipe-item';
import { SwipeItem, SwipeButtonsContainer, SwipeProvider } from 'react-native-swipe-item';

export default function SwipeButtonCustom() {

Expand All @@ -46,15 +48,20 @@ export default function SwipeButtonCustom() {
);

return (
<SwipeItem
style={styles.button}
swipeContainerStyle={styles.swipeContentContainerStyle}
leftButtons={leftButton}
>
<Text>
Swipe me!
</Text>
</SwipeItem>
<SwipeProvider>
<SwipeItem
style={styles.button}
swipeContainerStyle={styles.swipeContentContainerStyle}
leftButtons={leftButton}
>
<Text>
Swipe me!
</Text>
</SwipeItem>
<SwipeItem>
...
</SwipeItem>
</SwipeProvider>
);
}

Expand All @@ -77,7 +84,60 @@ const styles = StyleSheet.create({

```

### `SwipeItem` Props
## Components

* **SwipeProvider** `since v0.6.0`

- [props](#SwipeProvider)

* **SwipeItem**

- [props](#SwipeItem)

- [ref methods](#SwipeItemRefMethods)

* **SwipeButtonsContainer**

- [props](#SwipeButtonsContainer)

------

### `SwipeProvider` Props<a id='SwipeProvider'></a>

* [mode](#SwipeProvider_mode)

* [closeTrigger](#SwipeProvider_closeTrigger)

<a id="SwipeProvider_mode">**`mode`**</a>

Swipe items mode, default is `single`.

| TYPE | REQUIRED |
| --- | --- |
| `single` \| `multiple` | No |

* `single`: only allow one swipe item to be opened. The opened swipe item would be automatically closed when the new swipe item triggers the close event. (see the [closeTrigger](#SwipeProvider_closeTrigger) prop for more detail.)

* `multiple`: allow multiple swipe items to be opened.

---

<a id="SwipeProvider_closeTrigger">**`closeTrigger`**</a>

The trigger for automatically closed swipe item , only works when the mode prop is single, default is `onItemMoved`.

| TYPE | REQUIRED |
| --- | --- |
| `onItemMoved` \| `onButtonShowed` | No |

* `onItemMoved`: when the swipe item is moved, the opened one will be closed.

* `onButtonShowed`: when the swipe item button is showing, the opened one will be closed.

---


### `SwipeItem` Props<a id='SwipeItem'></a>

* [style](#style)

Expand All @@ -89,6 +149,12 @@ const styles = StyleSheet.create({

* [containerView](#containerView)

* [disableSwipeIfNoButton](#disableSwipeIfNoButton)

* [swipeThreshold](#swipeThreshold)

* [disableButtonScale](#disableButtonScale)

* [onSwipeInitial](#onSwipeInitial)

* [onLeftButtonsShowed](#onLeftButtonsShowed)
Expand Down Expand Up @@ -216,16 +282,72 @@ This prop will be called when the item moved to the origin, and the `SwipeItem`

---

### `SwipeItem` Methods
<a id="disableSwipeIfNoButton">**`disableSwipeIfNoButton`**</a>

`since v0.4`

Disable the swipe feature when there are no buttons.

| TYPE | REQUIRED |
| --- | --- |
| `boolean` | No |

---

<a id="swipeThreshold">**`swipeThreshold`**</a>

`since v0.7`

The swipe item will be opened automatically when the position pass the threshold, and you can set the left and right buttons separately.

| TYPE | REQUIRED |
| --- | --- |
| `{ left?: number, right?: number }` | No |

---

<a id="disableButtonScale">**`disableButtonScale`**</a>

`since v0.7`

You can disabled left or right or both button scale when swiping.

| TYPE | REQUIRED |
| --- | --- |
| `{ left?: boolean, right?: boolean }` | No |


---

### `SwipeItem` Ref Methods<a id="SwipeItemRefMethods"></a>

* [close](#close)

<a id="close">**`close`**</a>

Close the swipe item.

Example:

```

const itemRef = useRef(null);
...
itemRef.current.close();
...
<SwipeItem ref={itemRef} >
...
</SwipeItem>

```

---

### `SwipeButtonsContainer` Props<a id='SwipeButtonsContainer'></a>

**This component extends react-native View props.**


## License

MIT
Loading