Compare commits

...
75 Commits
Author SHA1 Message Date
semantic-release-bot fc9cefa2c1 chore(release): 4.0.0 [skip ci]
# [4.0.0](https://github.com/expo/react-native-action-sheet/compare/v3.14.0...v4.0.0) (2022-10-26)

### Features

* iOS use custom action sheet ([#281](https://github.com/expo/react-native-action-sheet/issues/281)) ([372dc80](https://github.com/expo/react-native-action-sheet/commit/372dc8065006a4da510ef5f31c27225d14a71ff3))

### BREAKING CHANGES

* This implementation is backwards compatible, but just to be safe I'm marking this as breaking so that it bumps the major version.
2022-10-26 17:39:06 +00:00
BradByte 372dc80650 feat: iOS use custom action sheet (#281)
BREAKING CHANGE: This implementation is backwards compatible, but just to be safe I'm marking this as breaking so that it bumps the major version.
2022-10-26 12:38:17 -05:00
BradByte 86fabab32b docs: add link to expo snack (#280) 2022-10-05 10:10:07 -05:00
BradByte b75a00a233 docs: update the docs, add better example, iOS props (#279) 2022-10-04 10:53:01 -05:00
semantic-release-bot 1df8d22613 chore(release): 3.14.0 [skip ci]
# [3.14.0](https://github.com/expo/react-native-action-sheet/compare/v3.13.1...v3.14.0) (2022-10-03)

### Features

* support cancelButtonTintColor ([#278](https://github.com/expo/react-native-action-sheet/issues/278)) ([2dcd54c](https://github.com/expo/react-native-action-sheet/commit/2dcd54c56f35a64c66f8d9a7d09a9475801cf037))
2022-10-03 19:40:24 +00:00
BradByte 2dcd54c56f feat: support cancelButtonTintColor (#278)
* feat: bump expo to sdk 46
* feat: add support for cancelButtonTintColor
2022-10-03 14:39:47 -05:00
semantic-release-bot 6244df4549 chore(release): 3.13.1 [skip ci]
## [3.13.1](https://github.com/expo/react-native-action-sheet/compare/v3.13.0...v3.13.1) (2022-10-03)

### Bug Fixes

* add return type to connectActionSheet ([#273](https://github.com/expo/react-native-action-sheet/issues/273)) ([f46a5cf](https://github.com/expo/react-native-action-sheet/commit/f46a5cfc473807478c558a733c8adb1440941017))
2022-10-03 18:36:09 +00:00
Danilo Bürger f46a5cfc47 fix: add return type to connectActionSheet (#273)
This avoids importing hoist-non-react-statics in the built d.ts file causing errors when using typescript with esModuleInterop = false
2022-10-03 13:35:33 -05:00
dependabot[bot] 9c6f5be31d chore(deps): bump simple-plist from 1.1.1 to 1.3.1 (#268)
Bumps [simple-plist](https://github.com/wollardj/simple-plist) from 1.1.1 to 1.3.1.
- [Release notes](https://github.com/wollardj/simple-plist/releases)
- [Commits](https://github.com/wollardj/simple-plist/compare/v1.1.1...v1.3.1)

---
updated-dependencies:
- dependency-name: simple-plist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 13:15:43 -05:00
dependabot[bot] 0147d326f9 chore(deps): bump simple-plist from 1.0.0 to 1.3.1 in /example (#269)
Bumps [simple-plist](https://github.com/wollardj/simple-plist) from 1.0.0 to 1.3.1.
- [Release notes](https://github.com/wollardj/simple-plist/releases)
- [Commits](https://github.com/wollardj/simple-plist/compare/v1.0.0...v1.3.1)

---
updated-dependencies:
- dependency-name: simple-plist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 13:15:31 -05:00
dependabot[bot] 47a1711c3c chore(deps-dev): bump semantic-release from 17.4.4 to 19.0.3 (#271)
Bumps [semantic-release](https://github.com/semantic-release/semantic-release) from 17.4.4 to 19.0.3.
- [Release notes](https://github.com/semantic-release/semantic-release/releases)
- [Commits](https://github.com/semantic-release/semantic-release/compare/v17.4.4...v19.0.3)

---
updated-dependencies:
- dependency-name: semantic-release
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 13:14:41 -05:00
dependabot[bot] 758050480d chore(deps): bump semver-regex from 3.1.3 to 3.1.4 (#270)
Bumps [semver-regex](https://github.com/sindresorhus/semver-regex) from 3.1.3 to 3.1.4.
- [Release notes](https://github.com/sindresorhus/semver-regex/releases)
- [Commits](https://github.com/sindresorhus/semver-regex/commits/v3.1.4)

---
updated-dependencies:
- dependency-name: semver-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 13:14:26 -05:00
dependabot[bot] e4f4246880 chore(deps): bump plist from 3.0.1 to 3.0.5 in /example (#266)
Bumps [plist](https://github.com/TooTallNate/node-plist) from 3.0.1 to 3.0.5.
- [Release notes](https://github.com/TooTallNate/node-plist/releases)
- [Changelog](https://github.com/TooTallNate/plist.js/blob/master/History.md)
- [Commits](https://github.com/TooTallNate/node-plist/commits)

---
updated-dependencies:
- dependency-name: plist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 13:13:58 -05:00
dependabot[bot] da6105e8a0 chore(deps): bump ansi-regex from 4.1.0 to 4.1.1 in /example (#265)
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 13:13:48 -05:00
dependabot[bot] 3822febbf8 chore(deps): bump plist from 3.0.1 to 3.0.5 (#264)
Bumps [plist](https://github.com/TooTallNate/node-plist) from 3.0.1 to 3.0.5.
- [Release notes](https://github.com/TooTallNate/node-plist/releases)
- [Changelog](https://github.com/TooTallNate/plist.js/blob/master/History.md)
- [Commits](https://github.com/TooTallNate/node-plist/commits)

---
updated-dependencies:
- dependency-name: plist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 13:13:37 -05:00
dependabot[bot] 8999650323 chore(deps): bump cross-fetch from 3.1.4 to 3.1.5 in /example (#262)
Bumps [cross-fetch](https://github.com/lquixada/cross-fetch) from 3.1.4 to 3.1.5.
- [Release notes](https://github.com/lquixada/cross-fetch/releases)
- [Commits](https://github.com/lquixada/cross-fetch/compare/v3.1.4...v3.1.5)

---
updated-dependencies:
- dependency-name: cross-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 13:13:26 -05:00
dependabot[bot] 6e22c372d3 chore(deps): bump async from 2.6.3 to 2.6.4 (#261)
Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 13:13:09 -05:00
dependabot[bot] 02b2db8947 chore(deps): bump async from 2.6.2 to 2.6.4 in /example (#260)
Bumps [async](https://github.com/caolan/async) from 2.6.2 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.2...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 13:13:00 -05:00
dependabot[bot] 880fe21224 chore(deps): bump url-parse from 1.5.3 to 1.5.10 in /example (#257)
Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.3 to 1.5.10.
- [Release notes](https://github.com/unshiftio/url-parse/releases)
- [Commits](https://github.com/unshiftio/url-parse/compare/1.5.3...1.5.10)

---
updated-dependencies:
- dependency-name: url-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 13:12:49 -05:00
dependabot[bot] df363ead72 chore(deps): bump shelljs from 0.8.4 to 0.8.5 in /example (#255)
Bumps [shelljs](https://github.com/shelljs/shelljs) from 0.8.4 to 0.8.5.
- [Release notes](https://github.com/shelljs/shelljs/releases)
- [Changelog](https://github.com/shelljs/shelljs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/shelljs/shelljs/compare/v0.8.4...v0.8.5)

---
updated-dependencies:
- dependency-name: shelljs
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 13:12:38 -05:00
semantic-release-bot 9ea2d088e6 chore(release): 3.13.0 [skip ci]
# [3.13.0](https://github.com/expo/react-native-action-sheet/compare/v3.12.0...v3.13.0) (2022-01-10)

### Bug Fixes

* defer calling onSelect until after animation ([#248](https://github.com/expo/react-native-action-sheet/issues/248)) ([1fb3411](https://github.com/expo/react-native-action-sheet/commit/1fb3411f575b4fa1cb762a804fc38cf3e2a5c73b)), closes [#203](https://github.com/expo/react-native-action-sheet/issues/203)
* stabilize the identity of the context provider value ([#251](https://github.com/expo/react-native-action-sheet/issues/251)) ([55005ba](https://github.com/expo/react-native-action-sheet/commit/55005ba0fb4bc6aff546390cf324619bf2e0ed2a))

### Features

* support closing actionsheet with Esc key on web ([#247](https://github.com/expo/react-native-action-sheet/issues/247)) ([c4c3f8b](https://github.com/expo/react-native-action-sheet/commit/c4c3f8b873d76ff40daf8d2061d9f43346a3577f)), closes [#194](https://github.com/expo/react-native-action-sheet/issues/194)
2022-01-10 19:52:43 +00:00
BradByte 0f534dc1f5 chore: add GH actions again (#254) 2022-01-10 13:51:31 -06:00
Jonathan Baudanza 55005ba0fb fix: stabilize the identity of the context provider value (#251) 2022-01-10 13:17:25 -06:00
Tim Robertson bd0c001215 Fix disabledButtonIndices typo (#249) 2021-11-01 08:22:07 -05:00
BradByte c4c3f8b873 feat: support closing actionsheet with Esc key on web (#247)
- Closes #194
2021-10-19 16:44:39 -05:00
BradByte 1fb3411f57 fix: defer calling onSelect until after animation (#248)
- Fixes #203
2021-10-19 16:44:19 -05:00
semantic-release-bot 2f43b7e956 chore(release): 3.12.0 [skip ci]
# [3.12.0](https://github.com/expo/react-native-action-sheet/compare/v3.11.0...v3.12.0) (2021-10-14)

### Bug Fixes

* use correct callback type allowing for undefined `i` ([#239](https://github.com/expo/react-native-action-sheet/issues/239)) ([b54b9f1](https://github.com/expo/react-native-action-sheet/commit/b54b9f16c251cb2ca5f1bd41ca7cc41b1393c6b3))

### Features

* adds support for disabledButtonIndicies ([#246](https://github.com/expo/react-native-action-sheet/issues/246)) ([feed1f7](https://github.com/expo/react-native-action-sheet/commit/feed1f78b4c85855d48c1742fe9f8a67c0604609)), closes [#224](https://github.com/expo/react-native-action-sheet/issues/224)
2021-10-14 15:15:36 -05:00
BradByte feed1f78b4 feat: adds support for disabledButtonIndicies (#246)
- Closes #224
2021-10-14 14:54:53 -05:00
dependabot[bot] a561f34cda chore(deps): bump semver-regex from 3.1.2 to 3.1.3 (#243)
Bumps [semver-regex](https://github.com/sindresorhus/semver-regex) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/sindresorhus/semver-regex/releases)
- [Commits](https://github.com/sindresorhus/semver-regex/commits)

---
updated-dependencies:
- dependency-name: semver-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-21 08:12:43 -05:00
dependabot[bot] c6cc00fdc5 chore(deps): bump tmpl from 1.0.4 to 1.0.5 in /example (#244)
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-21 08:12:30 -05:00
dependabot[bot] c237838c63 chore(deps): bump tmpl from 1.0.4 to 1.0.5 (#245)
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-21 08:11:43 -05:00
Bartosz Kaszubowski d735b696ab chore: update Readme after lint stack bump (#242) 2021-09-17 11:27:05 -05:00
Bartosz Kaszubowski 7736e0e162 chore: lint stack update, switch to eslint-config-universe (#241)
* lint stack update, switch to `eslint-config-universe`

* fix ESLint autofix mischief
2021-09-16 14:40:49 -05:00
BradByte b54b9f16c2 fix: use correct callback type allowing for undefined i (#239) 2021-09-07 09:25:34 -05:00
semantic-release-bot 4d8ed00b66 chore(release): 3.11.0 [skip ci]
# [3.11.0](https://github.com/expo/react-native-action-sheet/compare/v3.10.0...v3.11.0) (2021-09-07)

### Bug Fixes

* yarn lock issues ([#238](https://github.com/expo/react-native-action-sheet/issues/238)) ([22fc214](https://github.com/expo/react-native-action-sheet/commit/22fc2144b3ce3b5fc1892eefd86f484dc1af58e9))

### Features

* default useModal to true when autoFocus is set ([688fd47](https://github.com/expo/react-native-action-sheet/commit/688fd47227dab6994b59ed85af622cb04ebed220))
2021-09-07 09:03:41 -05:00
BradByte 22fc2144b3 fix: yarn lock issues (#238) 2021-09-07 09:01:44 -05:00
Brad Bumbalough 224d992a53 chore: update docs for useModal when autoFocus is true 2021-09-07 08:48:28 -05:00
Andy Li 688fd47227 feat: default useModal to true when autoFocus is set 2021-09-07 08:45:56 -05:00
dependabot[bot] e2e141bf53 chore(deps): bump url-parse from 1.5.1 to 1.5.3 in /example (#234)
Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.1 to 1.5.3.
- [Release notes](https://github.com/unshiftio/url-parse/releases)
- [Commits](https://github.com/unshiftio/url-parse/compare/1.5.1...1.5.3)

---
updated-dependencies:
- dependency-name: url-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-07 08:22:03 -05:00
dependabot[bot] be3425a4fd chore(deps): bump path-parse from 1.0.6 to 1.0.7 in /example (#235)
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-07 08:21:27 -05:00
dependabot[bot] 7a388210b1 chore(deps): bump tar from 4.4.15 to 4.4.19 (#237)
Bumps [tar](https://github.com/npm/node-tar) from 4.4.15 to 4.4.19.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-tar/compare/v4.4.15...v4.4.19)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-07 08:21:06 -05:00
dependabot[bot] d3fe451642 chore(deps): bump path-parse from 1.0.6 to 1.0.7 (#233)
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-10 15:56:13 -05:00
Brad Bumbalough 682e46136f chore: correct version to 3.10.0 2021-08-09 10:15:40 -05:00
semantic-release-bot 0e5559fb45 chore(release): 3.9.0 [skip ci]
# [3.9.0](https://github.com/expo/react-native-action-sheet/compare/v3.8.0...v3.9.0) (2021-08-09)

### Bug Fixes

* allow callback to be async ([#183](https://github.com/expo/react-native-action-sheet/issues/183)) ([d0d5182](https://github.com/expo/react-native-action-sheet/commit/d0d518278028556a80deec3d9b57c332b82ba28d))
* center icons with titles ([#188](https://github.com/expo/react-native-action-sheet/issues/188)) ([d48c323](https://github.com/expo/react-native-action-sheet/commit/d48c323e4563363c8683c427d1803e1ff4cddcb5))

### Features

* add `userInterfaceStyle` option for iOS ([#206](https://github.com/expo/react-native-action-sheet/issues/206)) ([735cfa5](https://github.com/expo/react-native-action-sheet/commit/735cfa54ba1bfd90139671489aca525fdbd59626))
* Allow multiple destructive indices ([#210](https://github.com/expo/react-native-action-sheet/issues/210)) ([81112b9](https://github.com/expo/react-native-action-sheet/commit/81112b9553dc34725e2708b02b64b7a5e5c57509))
2021-08-09 10:09:57 -05:00
semantic-release-bot f9ac44a6cb chore(release): 3.9.0 [skip ci]
# [3.9.0](https://github.com/expo/react-native-action-sheet/compare/v3.8.0...v3.9.0) (2021-08-09)

### Bug Fixes

* allow callback to be async ([#183](https://github.com/expo/react-native-action-sheet/issues/183)) ([d0d5182](https://github.com/expo/react-native-action-sheet/commit/d0d518278028556a80deec3d9b57c332b82ba28d))
* center icons with titles ([#188](https://github.com/expo/react-native-action-sheet/issues/188)) ([d48c323](https://github.com/expo/react-native-action-sheet/commit/d48c323e4563363c8683c427d1803e1ff4cddcb5))

### Features

* add `userInterfaceStyle` option for iOS ([#206](https://github.com/expo/react-native-action-sheet/issues/206)) ([735cfa5](https://github.com/expo/react-native-action-sheet/commit/735cfa54ba1bfd90139671489aca525fdbd59626))
* Allow multiple destructive indices ([#210](https://github.com/expo/react-native-action-sheet/issues/210)) ([81112b9](https://github.com/expo/react-native-action-sheet/commit/81112b9553dc34725e2708b02b64b7a5e5c57509))
2021-08-09 10:08:10 -05:00
Brad Bumbalough d31681dfea chore: bump semantic-release versions 2021-08-09 09:57:06 -05:00
semantic-release-bot 8a1659d71d chore(release): 3.9.0 [skip ci]
# [3.9.0](https://github.com/expo/react-native-action-sheet/compare/v3.8.0...v3.9.0) (2021-03-12)

### Bug Fixes

* allow callback to be async ([#183](https://github.com/expo/react-native-action-sheet/issues/183)) ([d0d5182](https://github.com/expo/react-native-action-sheet/commit/d0d518278028556a80deec3d9b57c332b82ba28d))
* center icons with titles ([#188](https://github.com/expo/react-native-action-sheet/issues/188)) ([d48c323](https://github.com/expo/react-native-action-sheet/commit/d48c323e4563363c8683c427d1803e1ff4cddcb5))

### Features

* add `userInterfaceStyle` option for iOS ([#206](https://github.com/expo/react-native-action-sheet/issues/206)) ([735cfa5](https://github.com/expo/react-native-action-sheet/commit/735cfa54ba1bfd90139671489aca525fdbd59626))
2021-08-09 09:23:54 -05:00
dependabot[bot] fd731f0867 chore(deps): bump color-string from 1.5.4 to 1.6.0 in /example (#232)
Bumps [color-string](https://github.com/Qix-/color-string) from 1.5.4 to 1.6.0.
- [Release notes](https://github.com/Qix-/color-string/releases)
- [Changelog](https://github.com/Qix-/color-string/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Qix-/color-string/compare/1.5.4...1.6.0)

---
updated-dependencies:
- dependency-name: color-string
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-05 14:51:58 -05:00
dependabot[bot] 4dc8fcf7b2 chore(deps): bump tar from 4.4.13 to 4.4.15 (#231)
Bumps [tar](https://github.com/npm/node-tar) from 4.4.13 to 4.4.15.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-tar/compare/v4.4.13...v4.4.15)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-05 08:22:32 -05:00
Evrim Persembe 81112b9553 feat: Allow multiple destructive indices (#210) 2021-06-21 16:13:20 -05:00
dependabot[bot] f0b38daaac chore(deps): bump normalize-url from 5.3.0 to 5.3.1 (#229)
Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 5.3.0 to 5.3.1.
- [Release notes](https://github.com/sindresorhus/normalize-url/releases)
- [Commits](https://github.com/sindresorhus/normalize-url/commits)

---
updated-dependencies:
- dependency-name: normalize-url
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-09 08:15:52 -05:00
dependabot[bot] bb7c00fb72 chore(deps): bump browserslist from 4.15.0 to 4.16.6 in /example (#223)
Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.15.0 to 4.16.6.
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/browserslist/browserslist/compare/4.15.0...4.16.6)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-08 08:20:24 -05:00
dependabot[bot] 7c757ac7e5 chore(deps): bump trim-newlines from 3.0.0 to 3.0.1 (#227)
Bumps [trim-newlines](https://github.com/sindresorhus/trim-newlines) from 3.0.0 to 3.0.1.
- [Release notes](https://github.com/sindresorhus/trim-newlines/releases)
- [Commits](https://github.com/sindresorhus/trim-newlines/commits)

---
updated-dependencies:
- dependency-name: trim-newlines
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-08 08:20:14 -05:00
Jesse Katsumata 51cd2d1009 docs: replace slack badge with discord badge (#225) 2021-06-08 08:20:00 -05:00
dependabot[bot] 97505a2041 chore(deps): bump ua-parser-js from 0.7.22 to 0.7.28 (#215)
Bumps [ua-parser-js](https://github.com/faisalman/ua-parser-js) from 0.7.22 to 0.7.28.
- [Release notes](https://github.com/faisalman/ua-parser-js/releases)
- [Commits](https://github.com/faisalman/ua-parser-js/compare/0.7.22...0.7.28)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 06:41:02 -05:00
dependabot[bot] 0a5821e1a3 chore(deps): bump y18n from 3.2.1 to 3.2.2 (#208)
Bumps [y18n](https://github.com/yargs/y18n) from 3.2.1 to 3.2.2.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 06:40:54 -05:00
dependabot[bot] c465495515 chore(deps): bump ua-parser-js from 0.7.20 to 0.7.28 in /example (#214)
Bumps [ua-parser-js](https://github.com/faisalman/ua-parser-js) from 0.7.20 to 0.7.28.
- [Release notes](https://github.com/faisalman/ua-parser-js/releases)
- [Commits](https://github.com/faisalman/ua-parser-js/compare/0.7.20...0.7.28)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 06:39:16 -05:00
dependabot[bot] 51efe1c0e5 chore(deps): bump lodash from 4.17.20 to 4.17.21 (#216)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 06:39:01 -05:00
dependabot[bot] b1cbd92a2a chore(deps): bump handlebars from 4.7.6 to 4.7.7 (#217)
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.7.6 to 4.7.7.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.7.6...v4.7.7)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 06:38:49 -05:00
dependabot[bot] 00a3e8354a chore(deps): bump url-parse from 1.4.7 to 1.5.1 in /example (#218)
Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.4.7 to 1.5.1.
- [Release notes](https://github.com/unshiftio/url-parse/releases)
- [Commits](https://github.com/unshiftio/url-parse/compare/1.4.7...1.5.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 06:38:25 -05:00
dependabot[bot] af226d6aa0 chore(deps): bump hosted-git-info from 2.8.8 to 2.8.9 (#219)
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 06:38:15 -05:00
dependabot[bot] f9a8e47b49 chore(deps): bump lodash from 4.17.19 to 4.17.21 in /example (#220)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 06:38:05 -05:00
dependabot[bot] 4af170533f chore(deps): bump ssri from 6.0.1 to 6.0.2 (#213)
Bumps [ssri](https://github.com/npm/ssri) from 6.0.1 to 6.0.2.
- [Release notes](https://github.com/npm/ssri/releases)
- [Changelog](https://github.com/npm/ssri/blob/v6.0.2/CHANGELOG.md)
- [Commits](https://github.com/npm/ssri/compare/v6.0.1...v6.0.2)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-03 08:06:41 -05:00
Manu 735cfa54ba feat: add userInterfaceStyle option for iOS (#206) 2021-03-11 14:13:29 -06:00
Emmanuel Johnandemmanuel.john 1af3809e07 chore: allow setting useNativeDriver on the provider (#202)
Fixes #184 

Co-authored-by: emmanuel.john <[email protected]>
2021-02-12 11:00:32 -06:00
dependabot[bot] d76a61f593 chore(deps): bump ini from 1.3.5 to 1.3.7 (#196)
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.7)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-12 07:21:44 -06:00
Brad Bumbalough 3ef49be264 chore: upgrade example app to SDK 39 (#193) 2020-12-02 17:14:07 -06:00
Brad Bumbalough 18e63e275d chore: resolve dependency audit issues (#192)
* chore: update semantic-release to latest

* chore: update yarn.lock to resolve audit issues
2020-12-02 17:02:16 -06:00
Svarto d48c323e45 fix: center icons with titles (#188) 2020-12-02 16:37:09 -06:00
Vincent PizzoandVincent Pizzo d0d5182780 fix: allow callback to be async (#183)
Co-authored-by: Vincent Pizzo <[email protected]>
2020-12-02 16:27:15 -06:00
dependabot[bot] eb30b1ed14 chore(deps-dev): bump semantic-release from 15.13.31 to 17.2.3 (#190)
Bumps [semantic-release](https://github.com/semantic-release/semantic-release) from 15.13.31 to 17.2.3.
- [Release notes](https://github.com/semantic-release/semantic-release/releases)
- [Commits](https://github.com/semantic-release/semantic-release/compare/v15.13.31...v17.2.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-02 16:26:09 -06:00
dependabot[bot] f509356bdd chore(deps): bump npm-user-validate from 1.0.0 to 1.0.1 (#186)
Bumps [npm-user-validate](https://github.com/npm/npm-user-validate) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/npm/npm-user-validate/releases)
- [Commits](https://github.com/npm/npm-user-validate/compare/v1.0.0...v1.0.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-02 16:25:55 -06:00
dependabot[bot] 86007a32a0 chore(deps): bump npm from 6.13.4 to 6.14.6 (#175)
Bumps [npm](https://github.com/npm/cli) from 6.13.4 to 6.14.6.
- [Release notes](https://github.com/npm/cli/releases)
- [Changelog](https://github.com/npm/cli/blob/latest/CHANGELOG.md)
- [Commits](https://github.com/npm/cli/compare/v6.13.4...v6.14.6)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-08-03 13:20:43 -05:00
dependabot[bot] 76da5f5fe5 chore(deps): bump lodash from 4.17.14 to 4.17.19 (#178)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.14 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.14...4.17.19)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-20 15:11:36 -05:00
dependabot[bot] e1bd0b0415 chore(deps): bump lodash from 4.17.14 to 4.17.19 in /example
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.14 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.14...4.17.19)

Signed-off-by: dependabot[bot] <[email protected]>
2020-07-17 11:39:23 -07:00
26 changed files with 9567 additions and 6675 deletions

No files matched your search

+1 -2
View File
@@ -1,5 +1,4 @@
node_modules
exmaple/node_modules
# generated by bob
lib/
lib/
+1 -12
View File
@@ -1,14 +1,3 @@
module.exports = {
extends: [
'@react-native-community',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
],
rules: {
// Turn off rules which are useless and annoying for this project
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'react-native/no-inline-styles': 'off',
},
extends: ['universe/native', 'universe/web'],
};
+22
View File
@@ -0,0 +1,22 @@
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'yarn'
- run: yarn install
- run: npm run type-check
- run: npm run lint-check
+23
View File
@@ -0,0 +1,23 @@
name: Release
on:
push:
branches: [ master ]
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'yarn'
- run: yarn install
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
+1 -2
View File
@@ -1,5 +1,4 @@
node_modules
example/node_modules
# generated by bob
lib/
lib/
+1 -1
View File
@@ -2,6 +2,6 @@
"printWidth": 100,
"tabWidth": 2,
"singleQuote": true,
"jsxBracketSameLine": true,
"bracketSameLine": true,
"trailingComma": "es5"
}
+81
View File
@@ -1,5 +1,86 @@
# Changelog
# [4.0.0](https://github.com/expo/react-native-action-sheet/compare/v3.14.0...v4.0.0) (2022-10-26)
### Features
* iOS use custom action sheet ([#281](https://github.com/expo/react-native-action-sheet/issues/281)) ([372dc80](https://github.com/expo/react-native-action-sheet/commit/372dc8065006a4da510ef5f31c27225d14a71ff3))
### BREAKING CHANGES
* This implementation is backwards compatible, but just to be safe I'm marking this as breaking so that it bumps the major version.
# [3.14.0](https://github.com/expo/react-native-action-sheet/compare/v3.13.1...v3.14.0) (2022-10-03)
### Features
* support cancelButtonTintColor ([#278](https://github.com/expo/react-native-action-sheet/issues/278)) ([2dcd54c](https://github.com/expo/react-native-action-sheet/commit/2dcd54c56f35a64c66f8d9a7d09a9475801cf037))
## [3.13.1](https://github.com/expo/react-native-action-sheet/compare/v3.13.0...v3.13.1) (2022-10-03)
### Bug Fixes
* add return type to connectActionSheet ([#273](https://github.com/expo/react-native-action-sheet/issues/273)) ([f46a5cf](https://github.com/expo/react-native-action-sheet/commit/f46a5cfc473807478c558a733c8adb1440941017))
# [3.13.0](https://github.com/expo/react-native-action-sheet/compare/v3.12.0...v3.13.0) (2022-01-10)
### Bug Fixes
* defer calling onSelect until after animation ([#248](https://github.com/expo/react-native-action-sheet/issues/248)) ([1fb3411](https://github.com/expo/react-native-action-sheet/commit/1fb3411f575b4fa1cb762a804fc38cf3e2a5c73b)), closes [#203](https://github.com/expo/react-native-action-sheet/issues/203)
* stabilize the identity of the context provider value ([#251](https://github.com/expo/react-native-action-sheet/issues/251)) ([55005ba](https://github.com/expo/react-native-action-sheet/commit/55005ba0fb4bc6aff546390cf324619bf2e0ed2a))
### Features
* support closing actionsheet with Esc key on web ([#247](https://github.com/expo/react-native-action-sheet/issues/247)) ([c4c3f8b](https://github.com/expo/react-native-action-sheet/commit/c4c3f8b873d76ff40daf8d2061d9f43346a3577f)), closes [#194](https://github.com/expo/react-native-action-sheet/issues/194)
# [3.12.0](https://github.com/expo/react-native-action-sheet/compare/v3.11.0...v3.12.0) (2021-10-14)
### Bug Fixes
* use correct callback type allowing for undefined `i` ([#239](https://github.com/expo/react-native-action-sheet/issues/239)) ([b54b9f1](https://github.com/expo/react-native-action-sheet/commit/b54b9f16c251cb2ca5f1bd41ca7cc41b1393c6b3))
### Features
* adds support for disabledButtonIndices ([#246](https://github.com/expo/react-native-action-sheet/issues/246)) ([feed1f7](https://github.com/expo/react-native-action-sheet/commit/feed1f78b4c85855d48c1742fe9f8a67c0604609)), closes [#224](https://github.com/expo/react-native-action-sheet/issues/224)
# [3.11.0](https://github.com/expo/react-native-action-sheet/compare/v3.10.0...v3.11.0) (2021-09-07)
### Bug Fixes
* yarn lock issues ([#238](https://github.com/expo/react-native-action-sheet/issues/238)) ([22fc214](https://github.com/expo/react-native-action-sheet/commit/22fc2144b3ce3b5fc1892eefd86f484dc1af58e9))
### Features
* default useModal to true when autoFocus is set ([688fd47](https://github.com/expo/react-native-action-sheet/commit/688fd47227dab6994b59ed85af622cb04ebed220))
# [3.10.0](https://github.com/expo/react-native-action-sheet/compare/v3.8.0...v3.10.0) (2021-08-09)
### Features
* Allow multiple destructive indices ([#210](https://github.com/expo/react-native-action-sheet/issues/210)) ([81112b9](https://github.com/expo/react-native-action-sheet/commit/81112b9553dc34725e2708b02b64b7a5e5c57509))
# [3.9.0](https://github.com/expo/react-native-action-sheet/compare/v3.8.0...v3.9.0) (2021-03-12)
### Bug Fixes
* allow callback to be async ([#183](https://github.com/expo/react-native-action-sheet/issues/183)) ([d0d5182](https://github.com/expo/react-native-action-sheet/commit/d0d518278028556a80deec3d9b57c332b82ba28d))
* center icons with titles ([#188](https://github.com/expo/react-native-action-sheet/issues/188)) ([d48c323](https://github.com/expo/react-native-action-sheet/commit/d48c323e4563363c8683c427d1803e1ff4cddcb5))
### Features
* add `userInterfaceStyle` option for iOS ([#206](https://github.com/expo/react-native-action-sheet/issues/206)) ([735cfa5](https://github.com/expo/react-native-action-sheet/commit/735cfa54ba1bfd90139671489aca525fdbd59626))
# [3.8.0](https://github.com/expo/react-native-action-sheet/compare/v3.7.0...v3.8.0) (2020-05-19)
+117 -104
View File
@@ -1,91 +1,101 @@
# react-native-action-sheet
# @expo/react-native-action-sheet
[![npm](https://img.shields.io/npm/v/@expo/react-native-action-sheet.svg?style=flat-square)](https://www.npmjs.com/package/@expo/react-native-action-sheet)
[![License: MIT](https://img.shields.io/github/license/nd-02110114/goofi-mobile.svg)](https://opensource.org/licenses/MIT)
[![Slack](https://slack.expo.io/badge.svg)](https://slack.expo.io)
[![Discord](https://img.shields.io/badge/discord-expo-green?style=flat-square&logo=discord)](https://discord.gg/4gtbPAdpaE)
ActionSheet is a cross-platform React Native component that uses the native UIActionSheet on iOS and a JS implementation on Android. Almost a drop in replacement for [ActionSheetIOS](https://facebook.github.io/react-native/docs/actionsheetios.html) except it cannot be called statically.
React Native Action Sheet is a cross-platform React Native component that uses the native UIActionSheet on iOS and a pure JS implementation on Android.
| iOS | Android | Web |
|---------------------------|---------------------------|---------------------------|
| iOS | Android | Web |
| -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
| <img src="https://raw.githubusercontent.com/expo/react-native-action-sheet/master/gif/ios.gif" width="200" height="400"/> | <img src="https://raw.githubusercontent.com/expo/react-native-action-sheet/master/gif/android.gif" width="200" height="400"/> | <img src="https://raw.githubusercontent.com/expo/react-native-action-sheet/master/gif/web.gif" width="400" height="400"/> |
## [Check out the example snack here!](https://snack.expo.dev/@expo-action-sheet/example)
## Installation
```
$ npm install @expo/react-native-action-sheet -S
npm install @expo/react-native-action-sheet
```
or
```
$ yarn add @expo/react-native-action-sheet
yarn add @expo/react-native-action-sheet
```
## A basic ActionSheet Setup
### 1. Wrap your top-level component with `<ActionSheetProvider />`
```es6
ReactNativeActionSheet uses React context to allow your components to invoke the menu. This means your app needs to be wrapped with the `ActionSheetProvider` component first.
import { ActionSheetProvider } from '@expo/react-native-action-sheet'
```jsx
import { ActionSheetProvider } from '@expo/react-native-action-sheet';
class AppContainer extends React.Component {
render() {
return (
<ActionSheetProvider>
<ConnectedApp />
</ActionSheetProvider>
);
}
export default function AppContainer() {
return (
<ActionSheetProvider>
<App />
</ActionSheetProvider>
);
}
```
### 2. Connect your component which uses showActionSheetWithOptions.
```es6
import { connectActionSheet } from '@expo/react-native-action-sheet'
### 2. Call the `showActionSheetWithOptions` method with a hook or a higher order component.
class App extends React.Component {
/* ... */
}
```tsx
// Using the provided hook
import { useActionSheet } from '@expo/react-native-action-sheet';
const ConnectedApp = connectActionSheet(App)
export default Menu() {
const { showActionSheetWithOptions } = useActionSheet();
export default ConnectedApp
```
const onPress() => {
const options = ['Delete', 'Save', 'Cancel'];
const destructiveButtonIndex = 0;
const cancelButtonIndex = 2;
`App` component can access the actionSheet method as `this.props.showActionSheetWithOptions`
```es6
_onOpenActionSheet = () => {
// Same interface as https://facebook.github.io/react-native/docs/actionsheetios.html
const options = ['Delete', 'Save', 'Cancel'];
const destructiveButtonIndex = 0;
const cancelButtonIndex = 2;
this.props.showActionSheetWithOptions(
{
showActionSheetWithOptions({
options,
cancelButtonIndex,
destructiveButtonIndex,
},
buttonIndex => {
// Do something here depending on the button index selected
},
);
destructiveButtonIndex
}, (selectedIndex: number) => {
switch (selectedIndex) {
case 1:
// Save
break;
case destructiveButtonIndex:
// Delete
break;
case cancelButtonIndex:
// Canceled
}});
}
return (
<Button title="Menu" onPress={onPress}/>
)
};
```
You can use a hook instead of the higher order component if you are on React 16.8 or newer.
Alternatively, any component can use the higher order component to access the context and pass the `showActionSheetWithOptions` as a prop.
```es6
import { useActionSheet } from '@expo/react-native-action-sheet'
```tsx
// Using a Higher Order Component to wrap your component
import { connectActionSheet } from '@expo/react-native-action-sheet';
export default function App () {
const { showActionSheetWithOptions } = useActionSheet();
function Menu({ showActionSheetWithOptions }) {
/* ... */
}
export default connectActionSheet(Menu);
```
`Menu` component can now access the actionSheet prop as `showActionSheetWithOptions`.
## Options
The goal of this library is to mimic the native iOS and Android ActionSheets as closely as possible.
@@ -94,80 +104,82 @@ This library can also be used in the browser with Expo for web.
### Universal Props
The same options available on React Native's [ActionSheetIOS](https://facebook.github.io/react-native/docs/actionsheetios.html#showactionsheetwithoptions) component exist for both iOS and Android in this library.
| Name | Type | Description |
| ------------------------ | -------------------------- | ------------------------------------------------------------- |
| `options` | array of strings | A list of button titles **(required)** |
| `cancelButtonIndex` | number | Index of cancel button in options |
| `cancelButtonTintColor` | string | Color used for the change the text color of the cancel button |
| `destructiveButtonIndex` | number or array of numbers | Indices of destructive buttons in options |
| `title` | string | Title to show above the action sheet |
| `message` | string | Message to show below the title |
| `tintColor` | string | Color used for non-destructive button titles |
| `disabledButtonIndices` | array of numbers | Indices of disabled buttons in options |
### iOS Only Props
| Name | Type | Required | Default |
| -----------------| -------| -------- | ------- |
| anchor | number | No | |
| Name | Type | Description |
| -------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `anchor` | number | iPad only option that allows for docking the action sheet to a node. See [ShowActionSheetButton.tsx](/example/ShowActionSheetButton.tsx) for an example on how to implement this. |
| `userInterfaceStyle` | string | The interface style used for the action sheet, can be set to `light` or `dark`, otherwise the default system style will be used. |
#### `anchor` (optional)
iPad only option that allows for docking the action sheet to a node. See [ShowActionSheetButton.tsx](/example/ShowActionSheetButton.tsx) for an example on how to implement this.
### Android/Web-Only Props
### Custom Action Sheet Only (Android/Web) Props
The below props allow modification of the Android ActionSheet. They have no effect on the look on iOS as the native iOS Action Sheet does not have options for modifying these options.
| Name | Type | Description |
| ------------------ | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `icons` | array of required images or icons | Show icons to go along with each option. If image source paths are provided via `require`, images will be rendered for you. Alternatively, you can provide an array of elements such as vector icons, pre-rendered Images, etc. |
| `tintIcons` | boolean | Icons by default will be tinted to match the text color. When set to false, the icons will be the color of the source image. This is useful if you want to use multicolor icons. If you provide your own nodes/pre-rendered icons rather than required images in the `icons` array, you will need to tint them appropriately before providing them in the array of `icons`; `tintColor` will not be applied to icons unless they are images from a required source. |
| `textStyle` | TextStyle | Apply any text style props to the options. If the `tintColor` option is provided, it takes precedence over a color text style prop. |
| `titleTextStyle` | TextStyle | Apply any text style props to the title if present. |
| `messageTextStyle` | TextStyle | Apply any text style props to the message if present. |
| `autoFocus` | boolean | If `true`, this will give the first option screen reader focus automatically when the action sheet becomes visible. On iOS, this is the default behavior of the native action sheet. |
| `showSeparators` | boolean | Show separators between items. On iOS, separators always show so this prop has no effect. |
| `containerStyle` | ViewStyle | Apply any view style props to the container rather than use the default look (e.g. dark mode). |
| `separatorStyle` | ViewStyle | Modify the look of the separators rather than use the default look. |
| `useModal` | boolean | Defaults to `false` (`true` if autoFocus is also `true`) Wraps the ActionSheet with a Modal, in order to show in front of other Modals that were already opened ([issue reference](https://github.com/expo/react-native-action-sheet/issues/164)). |
| `destructiveColor` | string | Modify color for text of destructive option. Defaults to `#d32f2f`. |
| Name | Type | Required | Default |
| -----------------| ----------------------------------| -------- | ------- |
| icons | array of required images or icons | No | |
| tintIcons | boolean | No | true |
| textStyle | TextStyle | No | |
| titleTextStyle | TextStyle | No | |
| messageTextStyle | TextStyle | No | |
| autoFocus | boolean | No | false |
| showSeparators | boolean | No | false |
| containerStyle | ViewStyle | No | |
| separatorStyle | ViewStyle | No | |
| useModal | boolean | No | false |
| destructiveColor | string | No | #d32f2f |
## ActionSheetProvider Props
#### `icons` (optional)
The following props can be set directly on the `ActionSheetProvider`
Show icons to go along with each option. If image source paths are provided via `require`, images will be rendered for you. Alternatively, you can provide an array of elements such as vector icons, pre-rendered Images, etc.
| Name | Type | Description |
| ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `useCustomActionSheet` | boolean | iOS only prop that uses the custom pure JS action sheet (Android/Web version) instead of the native ActionSheetIOS component. Defaults to `false`. |
| `useNativeDriver` | boolean | Windows only option that provides the option to disable the [native animation](https://reactnative.dev/docs/animated#using-the-native-driver) driver for React Native Windows projects targeting _Windows 10 Version-1809 ; Build-10.0.17763.0_ and earlier. `useNativeDriver` is [supported in Version-1903 and later](https://microsoft.github.io/react-native-windows/docs/win10-compat) so if your project is targeting that, you don't need to set this prop. |
#### `tintIcons` (optional)
Icons by default will be tinted to match the text color. When set to false, the icons will be the color of the source image. This is useful if you want to use multicolor icons. If you provide your own nodes/pre-rendered icons rather than required images in the `icons` array, you will need to tint them appropriately before providing them in the array of `icons`; `tintColor` will not be applied to icons unless they are images from a required source.
```jsx
// example of using useCustomActionSheet on iOS
export default function AppContainer() {
return (
<ActionSheetProvider useCustomActionSheet={true}>
<App />
</ActionSheetProvider>
);
}
```
#### `textStyle` (optional)
Apply any text style props to the options. If the `tintColor` option is provided, it takes precedence over a color text style prop.
## Callback
#### `titleTextStyle` (optional)
Apply any text style props to the title if present.
The second parameter of the `showActionSheetWithOptions` function is a callback for when a button is selected. The callback takes a single argument which will be the zero-based index of the pressed option. You can check the value against your `cancelButtonIndex` to determine if the action was cancelled or not.
#### `messageTextStyle` (optional)
Apply any text style props to the message if present.
#### `autoFocus`: (optional)
If true, will give the first option screen reader focus automatically when the action sheet becomes visible.
On iOS, this is the default behavior of the native action sheet.
#### `showSeparators`: (optional)
Show separators between items. On iOS, separators always show so this prop has no effect.
#### `containerStyle`: (optional)
Apply any view style props to the container rather than use the default look (e.g. dark mode).
#### `separatorStyle`: (optional)
Modify the look of the separators rather than use the default look.
#### `useModal`: (optional)
Wrap the ActionSheet with a Modal, in order to show in front of other Modals that were already opened ([issue reference](https://github.com/expo/react-native-action-sheet/issues/164)).
#### `destructiveColor`: (optional)
Modify color for text of destructive option.
```tsx
function onButtonPress(selectedIndex: number) {
// handle it!
}
```
## Try it out
Try it in Expo: https://expo.io/@community/react-native-action-sheet-example
Try it in Expo Snack: https://snack.expo.dev/@expo-action-sheet/example.
## Example
See the [example app](https://github.com/expo/react-native-action-sheet/tree/master/example).
### Usage
```
$ cd example
$ yarn
@@ -183,6 +195,7 @@ $ yarn web
## Development
### Setup
```
$ git clone [email protected]:expo/react-native-action-sheet.git
$ cd react-native-action-sheet
@@ -190,19 +203,19 @@ $ yarn
```
### Build
We use [bob](https://github.com/react-native-community/bob).
```
$ yarn build
```
### Lint & Format
```
// tsc
$ yarn type-check
// ESLint
// ESLint + Prettier
$ yarn lint
// prettier
$ yarn fmt
```
+101 -21
View File
@@ -1,4 +1,11 @@
import {
ActionSheetProvider,
connectActionSheet,
ActionSheetProps,
} from '@expo/react-native-action-sheet';
import { Entypo } from '@expo/vector-icons';
import * as React from 'react';
import { useState } from 'react';
import {
Modal,
StyleSheet,
@@ -7,18 +14,19 @@ import {
ScrollView,
SafeAreaView,
TouchableOpacity,
Share,
Platform,
} from 'react-native';
import {
ActionSheetProvider,
connectActionSheet,
ActionSheetProps,
} from '@expo/react-native-action-sheet';
import ShowActionSheetButton from './ShowActionSheetButton';
type Props = ActionSheetProps;
type Props = ActionSheetProps & {
useCustomActionSheet: boolean;
setUseCustomActionSheet: (next: boolean) => void;
};
interface State {
selectedIndex: number | null;
selectedIndex?: number | null;
isModalOpen: boolean;
}
@@ -28,7 +36,7 @@ class App extends React.Component<Props, State> {
isModalOpen: false,
};
_updateSelectionText = (selectedIndex: number) => {
_updateSelectionText = (selectedIndex?: number) => {
this.setState({
selectedIndex,
});
@@ -37,7 +45,9 @@ class App extends React.Component<Props, State> {
_renderSelectionText = () => {
const { selectedIndex } = this.state;
const text =
selectedIndex === null ? 'No Option Selected' : `Option #${selectedIndex + 1} Selected`;
selectedIndex === null || selectedIndex === undefined
? 'No Option Selected'
: `Option #${selectedIndex + 1} Selected`;
return <Text style={styles.selectionText}>{text}</Text>;
};
@@ -46,9 +56,26 @@ class App extends React.Component<Props, State> {
};
_toggleModal = () => {
this.setState({ isModalOpen: !this.state.isModalOpen });
this.setState((prevState) => ({ isModalOpen: !prevState.isModalOpen }));
};
async _onShare() {
try {
const result = await Share.share({
message: 'React Native | A framework for building native apps using React',
});
if (result.action === Share.sharedAction) {
if (result.activityType) {
// shared with activity type of result.activityType
} else {
// shared
}
} else if (result.action === Share.dismissedAction) {
// dismissed
}
} catch (error) {}
}
_renderButtons() {
const { showActionSheetWithOptions } = this.props;
return (
@@ -56,6 +83,35 @@ class App extends React.Component<Props, State> {
style={{
alignItems: 'center',
}}>
<View
style={{
alignItems: 'center',
display: Platform.OS === 'ios' ? 'flex' : 'none',
}}>
{this._renderSectionHeader('Use Custom Action Sheet')}
<Text style={{ marginBottom: 10 }}>
On iOS the default action sheet will be the native UI. However, you can optionally
enable the custom JS action sheet by setting the useCustomActionSheet prop on the
provider.
</Text>
<Entypo.Button
backgroundColor={this.props.useCustomActionSheet ? '#3e3e3e' : 'white'}
name={this.props.useCustomActionSheet ? 'check' : 'circle'}
color={this.props.useCustomActionSheet ? '#fff' : '#3e3e3e'}
style={{
borderColor: '#3e3e3e',
borderWidth: 2,
}}
onPress={() => this.props.setUseCustomActionSheet(!this.props.useCustomActionSheet)}>
<Text
style={{
fontSize: 15,
color: this.props.useCustomActionSheet ? '#fff' : '#3e3e3e',
}}>
Use Custom Action Sheet
</Text>
</Entypo.Button>
</View>
{this._renderSectionHeader('Universal Options')}
<ShowActionSheetButton
title="Options Only"
@@ -75,6 +131,12 @@ class App extends React.Component<Props, State> {
onSelection={this._updateSelectionText}
showActionSheetWithOptions={showActionSheetWithOptions}
/>
<ShowActionSheetButton
title="Cancel Button Tint Color"
withCancelButtonTintColor
onSelection={this._updateSelectionText}
showActionSheetWithOptions={showActionSheetWithOptions}
/>
<ShowActionSheetButton
title="iPad Anchor"
withAnchor
@@ -84,8 +146,8 @@ class App extends React.Component<Props, State> {
/>
<ShowActionSheetButton
title="Nested Action Sheets"
onSelection={index => {
if (index < 3) {
onSelection={(index) => {
if (!index || index < 3) {
showActionSheetWithOptions(
{
title: 'Sub Action Sheet',
@@ -98,6 +160,21 @@ class App extends React.Component<Props, State> {
}}
showActionSheetWithOptions={showActionSheetWithOptions}
/>
<ShowActionSheetButton
title="Share Menu"
showActionSheetWithOptions={() =>
showActionSheetWithOptions(
{
title: 'Share Menu',
options: ['Share', 'Cancel'],
cancelButtonIndex: 1,
},
(i) => {
i === 0 && this._onShare();
}
)
}
/>
{this._renderSectionHeader('Android-Only Options')}
<ShowActionSheetButton
title="Icons"
@@ -175,16 +252,19 @@ class App extends React.Component<Props, State> {
}
}
const ConnectedApp = connectActionSheet<{}>(App);
const ConnectedApp = connectActionSheet<any>(App);
export default class AppContainer extends React.Component {
render() {
return (
<ActionSheetProvider>
<ConnectedApp />
</ActionSheetProvider>
);
}
export default function WrappedApp() {
const [useCustomActionSheet, setUseCustomActionSheet] = useState(false);
return (
<ActionSheetProvider useCustomActionSheet={useCustomActionSheet}>
<ConnectedApp
useCustomActionSheet={useCustomActionSheet}
setUseCustomActionSheet={setUseCustomActionSheet}
/>
</ActionSheetProvider>
);
}
const styles = StyleSheet.create({
+17 -9
View File
@@ -1,22 +1,25 @@
import * as React from 'react';
import { Text, View, TextStyle, ViewStyle, findNodeHandle, Button } from 'react-native';
import { MaterialIcons, Entypo } from '@expo/vector-icons';
import { ActionSheetOptions } from '@expo/react-native-action-sheet';
import { MaterialIcons, Entypo } from '@expo/vector-icons';
import * as React from 'react';
import { Text, View, TextStyle, ViewStyle, findNodeHandle } from 'react-native';
const icon = (name: string) => <MaterialIcons key={name} name={name} size={24} />;
const icon = (name: React.ComponentProps<typeof MaterialIcons>['name']) => (
<MaterialIcons key={name} name={name} size={24} />
);
interface Props {
title: string;
showActionSheetWithOptions: (
options: ActionSheetOptions,
callback: (buttonIndex: number) => void
callback: (buttonIndex?: number) => void
) => void;
onSelection: (index: number) => void;
onSelection: (index?: number) => void;
withTitle?: boolean;
withMessage?: boolean;
withIcons?: boolean;
withSeparators?: boolean;
withCustomStyles?: boolean;
withCancelButtonTintColor?: boolean;
withAnchor?: boolean;
useModal?: boolean;
}
@@ -30,11 +33,12 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
withSeparators: false,
withCustomStyles: false,
withAnchor: false,
withCancelButtonTintColor: false,
onSelection: null,
useModal: false,
};
_anchorRef = React.createRef<Button>();
_anchorRef = React.createRef<any>();
_showActionSheet = () => {
const {
@@ -44,13 +48,14 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
withIcons,
withSeparators,
withCustomStyles,
withCancelButtonTintColor,
onSelection,
showActionSheetWithOptions,
useModal,
} = this.props;
// Same interface as https://facebook.github.io/react-native/docs/actionsheetios.html
const options = ['Delete', 'Save', 'Share', 'Cancel'];
const options = ['Delete', 'Disabled', 'Save', 'Cancel'];
const icons = withIcons
? [icon('delete'), icon('save'), icon('share'), icon('cancel')]
: undefined;
@@ -59,6 +64,7 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
? 'This library tries to mimic the native share sheets as close as possible.'
: undefined;
const destructiveButtonIndex = 0;
const disabledButtonIndices = [1];
const cancelButtonIndex = 3;
const textStyle: TextStyle | undefined = withCustomStyles
? {
@@ -95,7 +101,9 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
{
options,
cancelButtonIndex,
cancelButtonTintColor: withCancelButtonTintColor ? '#D93F0B' : undefined,
destructiveButtonIndex,
disabledButtonIndices,
title,
message,
icons,
@@ -116,7 +124,7 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
// Android only,
useModal,
},
(buttonIndex: number) => {
(buttonIndex?: number) => {
// Do something here depending on the button index selected
onSelection(buttonIndex);
}
+1 -2
View File
@@ -4,7 +4,6 @@
"description": "A cross-platform ActionSheet component. https://github.com/expo/react-native-action-sheet",
"slug": "react-native-action-sheet-example",
"privacy": "public",
"sdkVersion": "35.0.0",
"version": "3.0.0",
"orientation": "portrait",
"primaryColor": "#cccccc",
@@ -15,4 +14,4 @@
"web"
]
}
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
module.exports = function(api) {
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
};
+10 -10
View File
@@ -13,18 +13,18 @@
},
"dependencies": {
"@expo/react-native-action-sheet": "../src",
"@expo/vector-icons": "^10.0.0",
"expo": "^35.0.0",
"@expo/vector-icons": "^13.0.0",
"expo": "^46.0.0",
"hoist-non-react-statics": "^3.3.0",
"react": "16.8.3",
"react-dom": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
"react-native-web": "^0.11.5"
"react": "18.0.0",
"react-dom": "18.0.0",
"react-native": "0.69.6",
"react-native-web": "~0.18.7"
},
"devDependencies": {
"@types/react": "^16.8.23",
"@types/react-native": "^0.57.65",
"babel-preset-expo": "^7.0.0",
"typescript": "^3.5.3"
"@types/react": "~18.0.0",
"@types/react-native": "~0.69.1",
"babel-preset-expo": "~9.2.0",
"typescript": "^4.6.3"
}
}
+10 -3
View File
@@ -2,14 +2,21 @@
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react-native",
"lib": ["esnext"],
"lib": [
"esnext"
],
"moduleResolution": "node",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "esnext",
"typeRoots": ["./node_modules/@types"],
"typeRoots": [
"./node_modules/@types"
]
},
"include": ["./**.tsx"],
"include": [
"./**.tsx"
],
"extends": "expo/tsconfig.base"
}
+5103 -2409
View File
File diff suppressed because it is too large. Load diff
+9 -14
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/react-native-action-sheet",
"version": "3.8.0",
"version": "4.0.0",
"description": "A cross-platform ActionSheet for React Native",
"react-native": "lib/module/index.js",
"types": "lib/typescript/index.d.ts",
@@ -13,8 +13,8 @@
"prepare": "bob build",
"build": "bob build",
"type-check": "tsc --noEmit",
"lint": "eslint . --ext .ts,.tsx --fix",
"fmt": "prettier --write \"{src,example}/**/*.{ts,tsx}\"",
"lint": "eslint . --fix",
"lint-check": "eslint",
"semantic-release": "semantic-release"
},
"repository": {
@@ -34,22 +34,18 @@
"homepage": "https://github.com/expo/react-native-action-sheet",
"devDependencies": {
"@react-native-community/bob": "^0.6.1",
"@react-native-community/eslint-config": "^0.0.5",
"@semantic-release/changelog": "^3.0.5",
"@semantic-release/git": "^7.0.18",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"@types/react": "^16.8.23",
"@types/react-native": "^0.57.65",
"@typescript-eslint/eslint-plugin": "^1.12.0",
"@typescript-eslint/parser": "^1.12.0",
"eslint": "^6.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-prettier": "3.1.0",
"eslint": "^7.32.0",
"eslint-config-universe": "^8.0.0",
"husky": "^3.0.0",
"lint-staged": "^9.2.0",
"prettier": "^1.18.2",
"prettier": "^2.3.2",
"react": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
"semantic-release": "^15.13.28",
"semantic-release": "^19.0.3",
"typescript": "^3.5.3"
},
"peerDependencies": {
@@ -72,7 +68,6 @@
"lint-staged": {
"*.{js,ts,tsx}": [
"yarn lint",
"yarn fmt",
"git add"
]
},
+36 -9
View File
@@ -1,17 +1,18 @@
import * as React from 'react';
import {
AccessibilityInfo,
findNodeHandle,
Image,
Platform,
ScrollView,
StyleSheet,
Text,
Image,
View,
ScrollView,
findNodeHandle,
AccessibilityInfo,
Platform,
UIManager,
View,
} from 'react-native';
import TouchableNativeFeedbackSafe from './TouchableNativeFeedbackSafe';
import { ActionSheetOptions } from '../types';
import TouchableNativeFeedbackSafe from './TouchableNativeFeedbackSafe';
type Props = ActionSheetOptions & {
tintIcons: boolean | null;
@@ -46,6 +47,18 @@ const focusViewOnRender = (ref: React.Component | null) => {
}
};
const isIndexDestructive = (index: number, destructiveIndex?: number | number[]) => {
if (Array.isArray(destructiveIndex)) {
return destructiveIndex.includes(index);
}
return index === destructiveIndex;
};
const isIndexDisabled = (index: number, disabledButtonIndices: number[] = []) => {
return disabledButtonIndices.includes(index);
};
export default class ActionGroup extends React.Component<Props> {
static defaultProps = {
title: null,
@@ -106,7 +119,10 @@ export default class ActionGroup extends React.Component<Props> {
const {
options,
icons,
cancelButtonIndex,
cancelButtonTintColor,
destructiveButtonIndex,
disabledButtonIndices,
destructiveColor = DESTRUCTIVE_COLOR,
onSelect,
startIndex,
@@ -126,7 +142,13 @@ export default class ActionGroup extends React.Component<Props> {
const defaultColor = tintColor
? tintColor
: (textStyle || {}).color || BLACK_87PC_TRANSPARENT;
const color = i === destructiveButtonIndex ? destructiveColor : defaultColor;
const disabled = isIndexDisabled(i, disabledButtonIndices);
const isCancelButton = i === cancelButtonIndex;
const color = isIndexDestructive(i, destructiveButtonIndex)
? destructiveColor
: isCancelButton
? cancelButtonTintColor || defaultColor
: defaultColor;
const iconSource = icons != null ? icons[i] : null;
optionViews.push(
@@ -135,8 +157,9 @@ export default class ActionGroup extends React.Component<Props> {
key={i}
pressInDelay={0}
background={nativeFeedbackBackground}
disabled={disabled}
onPress={() => onSelect(i)}
style={styles.button}
style={[styles.button, disabled && styles.disabledButton]}
accessibilityRole="button"
accessibilityLabel={options[i]}>
{this._renderIconElement(iconSource, color)}
@@ -161,6 +184,9 @@ const styles = StyleSheet.create({
height: 56,
paddingHorizontal: 16,
},
disabledButton: {
opacity: 0.5,
},
groupContainer: {
backgroundColor: '#ffffff',
overflow: 'hidden',
@@ -169,6 +195,7 @@ const styles = StyleSheet.create({
width: 24,
height: 24,
marginRight: 32,
justifyContent: 'center',
},
message: {
marginTop: 12,
+333
View File
@@ -0,0 +1,333 @@
import * as React from 'react';
import {
Animated,
BackHandler,
Easing,
Modal,
Platform,
StyleSheet,
TouchableWithoutFeedback,
View,
ViewProps,
} from 'react-native';
import { ActionSheetOptions } from '../types';
import ActionGroup from './ActionGroup';
interface State {
isVisible: boolean;
isAnimating: boolean;
options: ActionSheetOptions | null;
onSelect: ((i: number) => void) | null;
overlayOpacity: any;
sheetOpacity: any;
}
export interface Props {
readonly children: React.ReactNode;
readonly useNativeDriver?: boolean;
readonly pointerEvents?: ViewProps['pointerEvents'];
}
const OPACITY_ANIMATION_IN_TIME = 225;
const OPACITY_ANIMATION_OUT_TIME = 195;
const EASING_OUT = Easing.bezier(0.25, 0.46, 0.45, 0.94);
const EASING_IN = Easing.out(EASING_OUT);
const ESCAPE_KEY = 'Escape';
// Has same API as https://facebook.github.io/react-native/docs/actionsheetios.html
export default class CustomActionSheet extends React.Component<Props, State> {
_actionSheetHeight = 360;
state: State = {
isVisible: false,
isAnimating: false,
options: null,
onSelect: null,
overlayOpacity: new Animated.Value(0),
sheetOpacity: new Animated.Value(0),
};
_deferAfterAnimation?: () => void = undefined;
componentDidMount() {
if (Platform.OS === 'web') {
document.addEventListener('keydown', this._handleWebKeyDown);
}
}
componentWillUnmount() {
if (Platform.OS === 'web') {
document.removeEventListener('keydown', this._handleWebKeyDown);
}
}
_handleWebKeyDown = (event: KeyboardEvent): void => {
if (event.key === ESCAPE_KEY && this.state.isVisible) {
event.preventDefault();
this._selectCancelButton();
}
};
_setActionSheetHeight = ({ nativeEvent }: any) =>
(this._actionSheetHeight = nativeEvent.layout.height);
render() {
const { isVisible, overlayOpacity, options } = this.state;
const useModal = options ? options.autoFocus || options.useModal === true : false;
const overlay = isVisible ? (
<Animated.View
style={[
styles.overlay,
{
opacity: overlayOpacity,
},
]}
/>
) : null;
// While the sheet is visible, hide the rest of the app's content from screen readers.
const appContent = (
<View
style={styles.flexContainer}
importantForAccessibility={isVisible ? 'no-hide-descendants' : 'auto'}>
{React.Children.only(this.props.children)}
</View>
);
return (
<View pointerEvents={this.props.pointerEvents} style={styles.flexContainer}>
{appContent}
{isVisible && !useModal && (
<>
{overlay}
{this._renderSheet()}
</>
)}
{isVisible && useModal && (
<Modal animationType="none" transparent onRequestClose={this._selectCancelButton}>
{overlay}
{this._renderSheet()}
</Modal>
)}
</View>
);
}
_renderSheet() {
const { options, isAnimating, sheetOpacity } = this.state;
if (!options) {
return null;
}
const {
options: optionsArray,
icons,
tintIcons,
destructiveButtonIndex,
disabledButtonIndices,
destructiveColor,
textStyle,
tintColor,
title,
titleTextStyle,
message,
messageTextStyle,
autoFocus,
showSeparators,
containerStyle,
separatorStyle,
cancelButtonIndex,
cancelButtonTintColor,
} = options;
return (
<TouchableWithoutFeedback importantForAccessibility="yes" onPress={this._selectCancelButton}>
<Animated.View
needsOffscreenAlphaCompositing={isAnimating}
style={[
styles.sheetContainer,
{
opacity: sheetOpacity,
transform: [
{
translateY: sheetOpacity.interpolate({
inputRange: [0, 1],
outputRange: [this._actionSheetHeight, 0],
}),
},
],
},
]}>
<View style={styles.sheet} onLayout={this._setActionSheetHeight}>
<ActionGroup
options={optionsArray}
icons={icons}
tintIcons={tintIcons === undefined ? true : tintIcons}
cancelButtonIndex={cancelButtonIndex}
cancelButtonTintColor={cancelButtonTintColor}
destructiveButtonIndex={destructiveButtonIndex}
destructiveColor={destructiveColor}
disabledButtonIndices={disabledButtonIndices}
onSelect={this._onSelect}
startIndex={0}
length={optionsArray.length}
textStyle={textStyle || {}}
tintColor={tintColor}
title={title || undefined}
titleTextStyle={titleTextStyle}
message={message || undefined}
messageTextStyle={messageTextStyle}
autoFocus={autoFocus}
showSeparators={showSeparators}
containerStyle={containerStyle}
separatorStyle={separatorStyle}
/>
</View>
</Animated.View>
</TouchableWithoutFeedback>
);
}
showActionSheetWithOptions = (options: ActionSheetOptions, onSelect: (i: number) => void) => {
const { isVisible, overlayOpacity, sheetOpacity } = this.state;
const { useNativeDriver = true } = this.props;
if (isVisible) {
this._deferAfterAnimation = this.showActionSheetWithOptions.bind(this, options, onSelect);
return;
}
this.setState({
options,
onSelect,
isVisible: true,
isAnimating: true,
});
overlayOpacity.setValue(0);
sheetOpacity.setValue(0);
Animated.parallel([
Animated.timing(overlayOpacity, {
toValue: 0.32,
easing: EASING_OUT,
duration: OPACITY_ANIMATION_IN_TIME,
useNativeDriver,
}),
Animated.timing(sheetOpacity, {
toValue: 1,
easing: EASING_OUT,
duration: OPACITY_ANIMATION_IN_TIME,
useNativeDriver,
}),
]).start((result) => {
if (result.finished) {
this.setState({
isAnimating: false,
});
this._deferAfterAnimation = undefined;
}
});
// @ts-ignore: Argument of type '"actionSheetHardwareBackPress"' is not assignable to parameter of type '"hardwareBackPress"'
BackHandler.addEventListener('actionSheetHardwareBackPress', this._selectCancelButton);
};
_selectCancelButton = () => {
const { options } = this.state;
if (!options) {
return false;
}
if (typeof options.cancelButtonIndex === 'undefined') {
return false;
} else if (typeof options.cancelButtonIndex === 'number') {
return this._onSelect(options.cancelButtonIndex);
} else {
return this._animateOut();
}
};
_onSelect = (index: number): boolean => {
const { isAnimating, onSelect } = this.state;
if (isAnimating) {
return false;
}
if (onSelect) {
this._deferAfterAnimation = onSelect.bind(this, index);
}
return this._animateOut();
};
_animateOut = (): boolean => {
const { isAnimating, overlayOpacity, sheetOpacity } = this.state;
const { useNativeDriver = true } = this.props;
if (isAnimating) {
return false;
}
// @ts-ignore: Argument of type '"actionSheetHardwareBackPress"' is not assignable to parameter of type '"hardwareBackPress"'
BackHandler.removeEventListener('actionSheetHardwareBackPress', this._selectCancelButton);
this.setState({
isAnimating: true,
});
Animated.parallel([
Animated.timing(overlayOpacity, {
toValue: 0,
easing: EASING_IN,
duration: OPACITY_ANIMATION_OUT_TIME,
useNativeDriver,
}),
Animated.timing(sheetOpacity, {
toValue: 0,
easing: EASING_IN,
duration: OPACITY_ANIMATION_OUT_TIME,
useNativeDriver,
}),
]).start((result) => {
if (result.finished) {
this.setState({
isVisible: false,
isAnimating: false,
});
if (this._deferAfterAnimation) {
this._deferAfterAnimation();
}
}
});
return true;
};
}
const styles = StyleSheet.create({
flexContainer: {
flex: 1,
},
overlay: {
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
left: 0,
backgroundColor: 'black',
},
sheetContainer: {
position: 'absolute',
left: 0,
right: 0,
bottom: 0,
top: 0,
backgroundColor: 'transparent',
alignItems: 'flex-end',
justifyContent: 'center',
flexDirection: 'row',
},
sheet: {
flex: 1,
backgroundColor: 'transparent',
},
});
+12 -2
View File
@@ -1,5 +1,4 @@
import * as React from 'react';
import { ActionSheetIOS, View, ViewProps } from 'react-native';
import { ActionSheetIOSOptions } from '../types';
@@ -22,17 +21,28 @@ export default class ActionSheet extends React.Component<Props> {
showActionSheetWithOptions(dataOptions: ActionSheetIOSOptions, onSelect: onSelect) {
// ...dataOptions include other keys which use in android and web, thats why `Android-Only options` Crash on IOS
const { cancelButtonIndex, destructiveButtonIndex, options, tintColor } = dataOptions;
const {
cancelButtonIndex,
destructiveButtonIndex,
options,
tintColor,
cancelButtonTintColor,
disabledButtonIndices,
} = dataOptions;
const iosOptions: ActionSheetIOSOptions = {
cancelButtonIndex,
destructiveButtonIndex,
options,
tintColor,
cancelButtonTintColor,
disabledButtonIndices,
// A null title or message on iOS causes a crash
title: dataOptions.title || undefined,
message: dataOptions.message || undefined,
anchor: dataOptions.anchor || undefined,
userInterfaceStyle: dataOptions.userInterfaceStyle || undefined,
};
// @ts-ignore: Even though ActionSheetIOS supports array of numbers for `destructiveIndex` the types are not yet updated. See https://github.com/facebook/react-native/pull/18254.
ActionSheetIOS.showActionSheetWithOptions(iosOptions, onSelect);
}
}
+2 -303
View File
@@ -1,303 +1,2 @@
import * as React from 'react';
import {
Animated,
BackHandler,
Easing,
Modal,
StyleSheet,
TouchableWithoutFeedback,
View,
ViewProps,
} from 'react-native';
import ActionGroup from './ActionGroup';
import { ActionSheetOptions } from '../types';
interface State {
isVisible: boolean;
isAnimating: boolean;
options: ActionSheetOptions | null;
onSelect: ((i: number) => void) | null;
overlayOpacity: any;
sheetOpacity: any;
}
interface Props {
readonly useNativeDriver: boolean | undefined;
readonly pointerEvents?: ViewProps['pointerEvents'];
}
const OPACITY_ANIMATION_IN_TIME = 225;
const OPACITY_ANIMATION_OUT_TIME = 195;
const EASING_OUT = Easing.bezier(0.25, 0.46, 0.45, 0.94);
const EASING_IN = Easing.out(EASING_OUT);
// Has same API as https://facebook.github.io/react-native/docs/actionsheetios.html
export default class ActionSheet extends React.Component<Props, State> {
static defaultProps = {
useNativeDriver: true,
};
_actionSheetHeight = 360;
state: State = {
isVisible: false,
isAnimating: false,
options: null,
onSelect: null,
overlayOpacity: new Animated.Value(0),
sheetOpacity: new Animated.Value(0),
};
_deferNextShow?: () => void = undefined;
_setActionSheetHeight = ({ nativeEvent }: any) =>
(this._actionSheetHeight = nativeEvent.layout.height);
render() {
const { isVisible, overlayOpacity, options } = this.state;
const useModal = options ? options.useModal === true : false;
const overlay = isVisible ? (
<Animated.View
style={[
styles.overlay,
{
opacity: overlayOpacity,
},
]}
/>
) : null;
// While the sheet is visible, hide the rest of the app's content from screen readers.
const appContent = (
<View
style={styles.flexContainer}
importantForAccessibility={isVisible ? 'no-hide-descendants' : 'auto'}>
{React.Children.only(this.props.children)}
</View>
);
return (
<View pointerEvents={this.props.pointerEvents} style={styles.flexContainer}>
{appContent}
{isVisible && !useModal && (
<React.Fragment>
{overlay}
{this._renderSheet()}
</React.Fragment>
)}
{isVisible && useModal && (
<Modal animationType="none" transparent={true} onRequestClose={this._selectCancelButton}>
{overlay}
{this._renderSheet()}
</Modal>
)}
</View>
);
}
_renderSheet() {
const { options, isAnimating, sheetOpacity } = this.state;
if (!options) {
return null;
}
const {
options: optionsArray,
icons,
tintIcons,
destructiveButtonIndex,
destructiveColor,
textStyle,
tintColor,
title,
titleTextStyle,
message,
messageTextStyle,
autoFocus,
showSeparators,
containerStyle,
separatorStyle,
} = options;
return (
<TouchableWithoutFeedback importantForAccessibility="yes" onPress={this._selectCancelButton}>
<Animated.View
needsOffscreenAlphaCompositing={isAnimating}
style={[
styles.sheetContainer,
{
opacity: sheetOpacity,
transform: [
{
translateY: sheetOpacity.interpolate({
inputRange: [0, 1],
outputRange: [this._actionSheetHeight, 0],
}),
},
],
},
]}>
<View style={styles.sheet} onLayout={this._setActionSheetHeight}>
<ActionGroup
options={optionsArray}
icons={icons}
tintIcons={tintIcons === undefined ? true : tintIcons}
destructiveButtonIndex={destructiveButtonIndex}
destructiveColor={destructiveColor}
onSelect={this._onSelect}
startIndex={0}
length={optionsArray.length}
textStyle={textStyle || {}}
tintColor={tintColor}
title={title || undefined}
titleTextStyle={titleTextStyle}
message={message || undefined}
messageTextStyle={messageTextStyle}
autoFocus={autoFocus}
showSeparators={showSeparators}
containerStyle={containerStyle}
separatorStyle={separatorStyle}
/>
</View>
</Animated.View>
</TouchableWithoutFeedback>
);
}
showActionSheetWithOptions = (options: ActionSheetOptions, onSelect: (i: number) => void) => {
const { isVisible, overlayOpacity, sheetOpacity } = this.state;
if (isVisible) {
this._deferNextShow = this.showActionSheetWithOptions.bind(this, options, onSelect);
return;
}
this.setState({
options,
onSelect,
isVisible: true,
isAnimating: true,
});
overlayOpacity.setValue(0);
sheetOpacity.setValue(0);
Animated.parallel([
Animated.timing(overlayOpacity, {
toValue: 0.32,
easing: EASING_OUT,
duration: OPACITY_ANIMATION_IN_TIME,
useNativeDriver: this.props.useNativeDriver,
}),
Animated.timing(sheetOpacity, {
toValue: 1,
easing: EASING_OUT,
duration: OPACITY_ANIMATION_IN_TIME,
useNativeDriver: this.props.useNativeDriver,
}),
]).start(result => {
if (result.finished) {
this.setState({
isAnimating: false,
});
this._deferNextShow = undefined;
}
});
// @ts-ignore: Argument of type '"actionSheetHardwareBackPress"' is not assignable to parameter of type '"hardwareBackPress"'
BackHandler.addEventListener('actionSheetHardwareBackPress', this._selectCancelButton);
};
_selectCancelButton = () => {
const { options } = this.state;
if (!options) {
return false;
}
if (typeof options.cancelButtonIndex === 'undefined') {
return;
} else if (typeof options.cancelButtonIndex === 'number') {
return this._onSelect(options.cancelButtonIndex);
} else {
return this._animateOut();
}
};
_onSelect = (index: number): boolean => {
const { isAnimating, onSelect } = this.state;
if (isAnimating) {
return false;
}
onSelect && onSelect(index);
return this._animateOut();
};
_animateOut = (): boolean => {
const { isAnimating, overlayOpacity, sheetOpacity } = this.state;
if (isAnimating) {
return false;
}
// @ts-ignore: Argument of type '"actionSheetHardwareBackPress"' is not assignable to parameter of type '"hardwareBackPress"'
BackHandler.removeEventListener('actionSheetHardwareBackPress', this._selectCancelButton);
this.setState({
isAnimating: true,
});
Animated.parallel([
Animated.timing(overlayOpacity, {
toValue: 0,
easing: EASING_IN,
duration: OPACITY_ANIMATION_OUT_TIME,
useNativeDriver: this.props.useNativeDriver,
}),
Animated.timing(sheetOpacity, {
toValue: 0,
easing: EASING_IN,
duration: OPACITY_ANIMATION_OUT_TIME,
useNativeDriver: this.props.useNativeDriver,
}),
]).start(result => {
if (result.finished) {
this.setState({
isVisible: false,
isAnimating: false,
});
if (this._deferNextShow) {
this._deferNextShow();
}
}
});
return true;
};
}
const styles = StyleSheet.create({
flexContainer: {
flex: 1,
},
overlay: {
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
left: 0,
backgroundColor: 'black',
},
sheetContainer: {
position: 'absolute',
left: 0,
right: 0,
bottom: 0,
top: 0,
backgroundColor: 'transparent',
alignItems: 'flex-end',
justifyContent: 'center',
flexDirection: 'row',
},
sheet: {
flex: 1,
backgroundColor: 'transparent',
},
});
import CustomActionSheet from './CustomActionSheet';
export default CustomActionSheet;
+32 -23
View File
@@ -1,36 +1,45 @@
import * as React from 'react';
import ActionSheet from './ActionSheet';
// NativeActionSheet will always be custom when on Android/web
import NativeActionSheet from './ActionSheet';
import CustomActionSheet from './ActionSheet/CustomActionSheet';
import { Provider } from './context';
import { ActionSheetOptions } from './types';
interface Props {
children: React.ReactNode;
useNativeDriver?: boolean;
useCustomActionSheet?: boolean;
}
export default class ActionSheetProvider extends React.Component<Props> {
_actionSheetRef: React.RefObject<ActionSheet>;
export default function ActionSheetProvider({
children,
useNativeDriver,
useCustomActionSheet = false,
}: Props) {
const actionSheetRef = React.useRef<NativeActionSheet>(null);
constructor(props: Props) {
super(props);
this._actionSheetRef = React.createRef();
}
getContext = () => {
return {
const context = React.useMemo(
() => ({
showActionSheetWithOptions: (options: ActionSheetOptions, callback: (i: number) => void) => {
this._actionSheetRef.current !== null &&
this._actionSheetRef.current.showActionSheetWithOptions(options, callback);
if (actionSheetRef.current) {
actionSheetRef.current.showActionSheetWithOptions(options, callback);
}
},
};
};
}),
[actionSheetRef]
);
render() {
return (
<Provider value={this.getContext()}>
<ActionSheet ref={this._actionSheetRef}>
{React.Children.only(this.props.children)}
</ActionSheet>
</Provider>
);
}
const ActionSheet = React.useMemo(
() => (useCustomActionSheet ? CustomActionSheet : NativeActionSheet),
[useCustomActionSheet]
);
return (
<Provider value={context}>
<ActionSheet ref={actionSheetRef} useNativeDriver={useNativeDriver}>
{React.Children.only(children)}
</ActionSheet>
</Provider>
);
}
+4 -3
View File
@@ -1,11 +1,12 @@
import * as React from 'react';
import { Consumer } from './context';
import hoistNonReactStatic from 'hoist-non-react-statics';
import * as React from 'react';
import { Consumer } from './context';
import { ActionSheetProps } from './types';
export default function connectActionSheet<OwnProps = any>(
WrappedComponent: React.ComponentType<OwnProps & ActionSheetProps>
) {
): React.FunctionComponent<OwnProps & ActionSheetProps> {
const ConnectedActionSheet = (props: OwnProps) => {
return (
<Consumer>
+1
View File
@@ -1,4 +1,5 @@
import * as React from 'react';
import { ActionSheetOptions, ActionSheetProps } from './types';
const context = React.createContext<ActionSheetProps>({
+8 -2
View File
@@ -2,7 +2,10 @@ import * as React from 'react';
import { TextStyle, ViewStyle } from 'react-native';
export interface ActionSheetProps {
showActionSheetWithOptions: (options: ActionSheetOptions, callback: (i: number) => void) => void;
showActionSheetWithOptions: (
options: ActionSheetOptions,
callback: (i?: number) => void | Promise<void>
) => void;
}
// for iOS
@@ -12,8 +15,11 @@ export interface ActionSheetIOSOptions {
message?: string;
tintColor?: string;
cancelButtonIndex?: number;
destructiveButtonIndex?: number;
cancelButtonTintColor?: string;
destructiveButtonIndex?: number | number[];
anchor?: number;
userInterfaceStyle?: 'light' | 'dark';
disabledButtonIndices?: number[];
}
// for Android or Web
+3 -2
View File
@@ -5,9 +5,10 @@
"module": "commonjs",
"strict": true,
"moduleResolution": "node",
"lib": ["es2015", "es2016", "esnext"],
"lib": ["dom", "es2015", "es2016", "esnext"],
"jsx": "react-native",
"esModuleInterop": true
"esModuleInterop": true,
"skipLibCheck": true
},
"exclude": ["node_modules"]
}
+3636 -3740
View File
File diff suppressed because it is too large. Load diff