Skip to content

Commit f4253b9

Browse files
committed
initial commit
0 parents  commit f4253b9

84 files changed

Lines changed: 20563 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
version: 2.1
2+
3+
orbs:
4+
rn: react-native-community/react-native@1.2.1
5+
6+
jobs:
7+
checkout_code:
8+
executor: rn/linux_js
9+
steps:
10+
- checkout
11+
- persist_to_workspace:
12+
root: .
13+
paths: .
14+
analyse_js:
15+
executor: rn/linux_js
16+
steps:
17+
- attach_workspace:
18+
at: .
19+
- rn/yarn_install
20+
- run:
21+
name: Run Tests
22+
command: yarn test
23+
publish:
24+
executor: rn/linux_js
25+
steps:
26+
- attach_workspace:
27+
at: .
28+
- rn/yarn_install
29+
- run:
30+
name: Build the project
31+
command: yarn build
32+
- run:
33+
name: Publish to NPM
34+
command: yarn release
35+
36+
workflows:
37+
ci:
38+
jobs:
39+
- checkout_code
40+
- analyse_js:
41+
requires:
42+
- checkout_code
43+
# - rn/android_build:
44+
# name: build_android_release
45+
# project_path: "example/android"
46+
# build_type: release
47+
# requires:
48+
# - analyse_js
49+
# - rn/android_test:
50+
# detox_configuration: "android.emu.release"
51+
# requires:
52+
# - build_android_release
53+
# - rn/ios_build_and_test:
54+
# project_path: "example/ios/ModalExample.xcodeproj"
55+
# derived_data_path: "example/ios/build"
56+
# device: "iPhone 8"
57+
# build_configuration: "Release"
58+
# scheme: "ModalExample"
59+
# detox_configuration: "ios.sim.release"
60+
# requires:
61+
# - analyse_js
62+
- publish:
63+
requires:
64+
- analyse_js
65+
filters:
66+
branches:
67+
only: master

.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
parser: '@typescript-eslint/parser',
5+
plugins: ['@typescript-eslint'],
6+
};

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

.github/images/example.gif

15.9 MB
Loading

.gitignore

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# macOS
2+
.DS_Store
3+
4+
# Xcode
5+
build/
6+
*.pbxuser
7+
!default.pbxuser
8+
*.mode1v3
9+
!default.mode1v3
10+
*.mode2v3
11+
!default.mode2v3
12+
*.perspectivev3
13+
!default.perspectivev3
14+
xcuserdata
15+
*.xccheckout
16+
*.moved-aside
17+
DerivedData
18+
*.hmap
19+
*.ipa
20+
*.xcuserstate
21+
xcshareddata
22+
contents.xcworkspacedata
23+
24+
# Android/IntelliJ
25+
build/
26+
dist/
27+
.idea
28+
.gradle
29+
local.properties
30+
*.iml
31+
32+
# NodeJs
33+
node_modules/
34+
npm-debug.log
35+
yarn-error.log
36+
package-lock.json
37+
38+
# BUCK
39+
buck-out/
40+
\.buckd/
41+
*.keystore
42+
!debug.keystore
43+
44+
# VS Code
45+
.vscode/*
46+
!.vscode/settings.json
47+
!.vscode/tasks.json
48+
!.vscode/launch.json
49+
!.vscode/extensions.json

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
example/
2+
src

.prettierrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
bracketSpacing: false,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
};

.releaserc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"plugins": [
3+
"@semantic-release/commit-analyzer",
4+
"@semantic-release/release-notes-generator",
5+
"@semantic-release/npm",
6+
"@semantic-release/github",
7+
[
8+
"@semantic-release/git",
9+
{
10+
"assets": "package.json",
11+
"message": "chore(release): ${nextRelease.version} [skip ci] \n\n${nextRelease.notes}"
12+
}
13+
]
14+
]
15+
}

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Thomas
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# react-native-share-preview
2+
3+
[![npm version](https://badge.fury.io/js/react-native-share-preview.svg)](https://badge.fury.io/js/react-native-share-preview)
4+
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
5+
6+
Animated preview of a React Native page for sharing.
7+
8+
<p align="center">
9+
<img src="/.github/images/example.gif" height="500" />
10+
</p>
11+
12+
## Features
13+
14+
- Smooth animations by React Native Reanimated
15+
- Customizable loading (Todo)
16+
- Customizable ShareBar (Todo)
17+
18+
## Setup
19+
20+
This library is available on npm, install it with: `npm i react-native-share-preview` or `yarn add react-native-share-preview`.
21+
22+
Need also to install the related dependencies:
23+
`npm i react-native-reanimated react-native-view-shot` or `yarn add react-native-reanimated react-native-view-shot`.
24+
25+
Recommend to use with RN > 0.60 so the auto-linking will handle all the dependencies
26+
27+
For RN < 0.60, you need to manually install `react-native-view-shot` and `react-native-reanimated`
28+
29+
## Usage
30+
31+
1. Import react-native-share-preview:
32+
33+
```typescript
34+
import {ShareView} from 'react-native-share-preview';
35+
```
36+
37+
2. Create a new page and wrap the content you want to share inside a ShareView:
38+
39+
```tsx
40+
<ShareView
41+
onBackPress={handleBack}
42+
onSharePress={handleShareByType}
43+
onCaptureError={handleCaptureError}>
44+
<Text>Your Content</Text>
45+
</ShareView>
46+
```
47+
48+
3. Handle the logic for the selected share option
49+
50+
```javascript
51+
/**
52+
* Callback called with the user's selected share option
53+
*/
54+
const handleShareType = (type: ShareTypes, screenshotUri: string) => {
55+
return new Promise((resolve, _) => {
56+
// Call native implementation with your share logic
57+
// For example you can use react-native-share or your favorite share library
58+
return Share.open({type, filename: screenshotUri}).catch(err => {
59+
// Handle share error
60+
Alert.alert(err.message);
61+
throw err;
62+
});
63+
});
64+
};
65+
66+
const handleCaptureError = (message: string) => {
67+
Alert.alert(message);
68+
};
69+
```
70+
71+
## A complete example
72+
73+
For a more complex example take a look at the `/example` directory.
74+
75+
## Available props
76+
77+
| Name | Type | Default | Description |
78+
| -------------- | -------------- | ------------ | ------------------------------------------ |
79+
| outerBgColor | string | #dddddd | Background color of the share page |
80+
| innerBgColor | string | #f7f7f7 | Background color of the share content view |
81+
| shareBar | ReactNode | <ShareBar /> | Custom bottom Share Bar component |
82+
| shareBarHeight | number | 140 | Height of the bottom Share Bar |
83+
| captureOptions | CaptureOptions | {} | Capture options for ViewShot component |
84+
| onBackPress | Function | undefined | Handle share cancel and page go back |
85+
| onSharePress | Function | undefined | Handle user selected share option action |
86+
| onCaptureError | Function | undefined | Handle capture view Screenshot error |
87+
88+
## Frequently Asked Questions
89+
90+
### Why on iOS i can't capture the whole screen?
91+
92+
This is problem with the `react-native-view-shot` library, the fix has not been merged yet and can be found in this PR [#209](https://github.com/gre/react-native-view-shot/pull/209/files).
93+
94+
## Acknowledgements
95+
96+
Thanks [@software-mansion](https://github.com/software-mansion/react-native-reanimated) for react-native-reanimated and [@gre](https://github.com/gre/react-native-view-shot) for react-native-view-shot!
97+
98+
Pull requests, feedbacks and suggestions are welcome!

0 commit comments

Comments
 (0)