Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasgazzoni committed Jan 5, 2020
0 parents commit f4253b9
Show file tree
Hide file tree
Showing 84 changed files with 20,563 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: 2.1

orbs:
rn: react-native-community/react-native@1.2.1

jobs:
checkout_code:
executor: rn/linux_js
steps:
- checkout
- persist_to_workspace:
root: .
paths: .
analyse_js:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
name: Run Tests
command: yarn test
publish:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
name: Build the project
command: yarn build
- run:
name: Publish to NPM
command: yarn release

workflows:
ci:
jobs:
- checkout_code
- analyse_js:
requires:
- checkout_code
# - rn/android_build:
# name: build_android_release
# project_path: "example/android"
# build_type: release
# requires:
# - analyse_js
# - rn/android_test:
# detox_configuration: "android.emu.release"
# requires:
# - build_android_release
# - rn/ios_build_and_test:
# project_path: "example/ios/ModalExample.xcodeproj"
# derived_data_path: "example/ios/build"
# device: "iPhone 8"
# build_configuration: "Release"
# scheme: "ModalExample"
# detox_configuration: "ios.sim.release"
# requires:
# - analyse_js
- publish:
requires:
- analyse_js
filters:
branches:
only: master
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
root: true,
extends: '@react-native-community',
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
};
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
Binary file added .github/images/example.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# macOS
.DS_Store

# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
xcshareddata
contents.xcworkspacedata

# Android/IntelliJ
build/
dist/
.idea
.gradle
local.properties
*.iml

# NodeJs
node_modules/
npm-debug.log
yarn-error.log
package-lock.json

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# VS Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
example/
src
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
};
15 changes: 15 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github",
[
"@semantic-release/git",
{
"assets": "package.json",
"message": "chore(release): ${nextRelease.version} [skip ci] \n\n${nextRelease.notes}"
}
]
]
}
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Thomas

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# react-native-share-preview

[![npm version](https://badge.fury.io/js/react-native-share-preview.svg)](https://badge.fury.io/js/react-native-share-preview)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

Animated preview of a React Native page for sharing.

<p align="center">
<img src="/.github/images/example.gif" height="500" />
</p>

## Features

- Smooth animations by React Native Reanimated
- Customizable loading (Todo)
- Customizable ShareBar (Todo)

## Setup

This library is available on npm, install it with: `npm i react-native-share-preview` or `yarn add react-native-share-preview`.

Need also to install the related dependencies:
`npm i react-native-reanimated react-native-view-shot` or `yarn add react-native-reanimated react-native-view-shot`.

Recommend to use with RN > 0.60 so the auto-linking will handle all the dependencies

For RN < 0.60, you need to manually install `react-native-view-shot` and `react-native-reanimated`

## Usage

1. Import react-native-share-preview:

```typescript
import {ShareView} from 'react-native-share-preview';
```

2. Create a new page and wrap the content you want to share inside a ShareView:

```tsx
<ShareView
onBackPress={handleBack}
onSharePress={handleShareByType}
onCaptureError={handleCaptureError}>
<Text>Your Content</Text>
</ShareView>
```

3. Handle the logic for the selected share option

```javascript
/**
* Callback called with the user's selected share option
*/
const handleShareType = (type: ShareTypes, screenshotUri: string) => {
return new Promise((resolve, _) => {
// Call native implementation with your share logic
// For example you can use react-native-share or your favorite share library
return Share.open({type, filename: screenshotUri}).catch(err => {
// Handle share error
Alert.alert(err.message);
throw err;
});
});
};

const handleCaptureError = (message: string) => {
Alert.alert(message);
};
```

## A complete example

For a more complex example take a look at the `/example` directory.

## Available props

| Name | Type | Default | Description |
| -------------- | -------------- | ------------ | ------------------------------------------ |
| outerBgColor | string | #dddddd | Background color of the share page |
| innerBgColor | string | #f7f7f7 | Background color of the share content view |
| shareBar | ReactNode | <ShareBar /> | Custom bottom Share Bar component |
| shareBarHeight | number | 140 | Height of the bottom Share Bar |
| captureOptions | CaptureOptions | {} | Capture options for ViewShot component |
| onBackPress | Function | undefined | Handle share cancel and page go back |
| onSharePress | Function | undefined | Handle user selected share option action |
| onCaptureError | Function | undefined | Handle capture view Screenshot error |

## Frequently Asked Questions

### Why on iOS i can't capture the whole screen?

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).

## Acknowledgements

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!

Pull requests, feedbacks and suggestions are welcome!
6 changes: 6 additions & 0 deletions example/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
75 changes: 75 additions & 0 deletions example/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore polyfills
node_modules/react-native/Libraries/polyfills/.*

; These should not be required directly
; require from fbjs/lib instead: require('fbjs/lib/warning')
node_modules/warning/.*

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

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

[include]

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

[options]
emoji=true

esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

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

munge_underscores=true

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

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

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

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

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

[version]
^0.105.0
1 change: 1 addition & 0 deletions example/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
Loading

0 comments on commit f4253b9

Please sign in to comment.