Skip to content

Commit dc2f4a9

Browse files
committed
Add Share Hook
1 parent 3224d86 commit dc2f4a9

Some content is hidden

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

73 files changed

+17368
-0
lines changed

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 2
6+
end_of_line = lf
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintrc.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"extends": [
3+
"airbnb",
4+
"prettier",
5+
"plugin:prettier/recommended",
6+
"prettier/flowtype",
7+
"prettier/react",
8+
"prettier/standard"
9+
],
10+
"parser": "babel-eslint",
11+
"plugins": ["react-native", "jest", "prettier"],
12+
"env": {
13+
"jest": true
14+
},
15+
"rules": {
16+
"react/jsx-no-bind": "off",
17+
"react/no-string-refs": "off",
18+
"no-underscore-dangle": "off",
19+
"no-unused-vars": ["error", { "argsIgnorePattern": "(state|dispatch)" }],
20+
"new-cap": ["error", { "capIsNewExceptions": ["Immutable"] }],
21+
"import/no-extraneous-dependencies": "off",
22+
"no-console": "off",
23+
"react/jsx-filename-extension": "off",
24+
"global-require": "off",
25+
"no-alert": "off",
26+
"react/forbid-prop-types": "off",
27+
"class-methods-use-this": "off",
28+
"react/no-unused-prop-types": "warn",
29+
"react/prefer-stateless-function": [
30+
"error",
31+
{ "ignorePureComponents": true }
32+
],
33+
"react/require-default-props": "off"
34+
}
35+
}

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.idea
2+
node_modules
3+
dist
4+
.DS_Store
5+
.vscode
6+
*.log
7+
coverage
8+
.yalc

.npmignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.idea
2+
node_modules
3+
_tests_
4+
.DS_Store
5+
.vscode
6+
*.log
7+
coverage
8+
example
9+
yalc.lock

.prettierignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
dist
3+
*.log
4+
coverage
5+
.yalc
6+
ios/
7+
android/

.prettierrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
singleQuote: true,
3+
trailingComma: 'all',
4+
};

.travis.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
language: node_js
2+
node_js:
3+
- 10
4+
- 8
5+
addons:
6+
code_climate:
7+
repo_token:
8+
secure: "PnisVkP1GBCiyHW4LSIiQGt1i1EfgWfdZnSYy2JRj6d8wkVWkeVNe/tVJUBUxm+mXtbFO89Omr4SCiE5ZUD/SHFkItq0M/w3GusepO2ZxPs4rTMTnn/5GRPRfRleuhyRWG3TqdRI/JS1wv5aMAM08xTyB/JxYlu+lakCUauU8r+gbL2qj5Ym0RSsDYkccOI6peITAH0VFbl52JW7voeVBY2e9hz5toNe2zwHHy+3/Fh9Kgp+jYC1Qp7PGjU2YmcfHBFFT2RIAWRZMThQ4/kYjZK78nhH0TSWXyFt4XKcYyxAUIpe+UbnyQxbopbMoxW8GOGUCXKfAuVEGK0wE3vT2sUiWZUdEsybPsPFqNgh+dZtcaphBNGqPyZ85Il/j7aTemI+Y30Ys1yri5lkVMjOXTRI3k3jVbjL9pgzjBk+3+zCQel9DxoKCawG45CyibUFtwHUsRqamDv22qIIOxAYTCa7rxp0MkhpO2wYdhf0kNFBHPF4k7o8K90UklC5+HFAcsmGAIHb8krtmKcP7LGaxUbEFAFKvk21720ehtKOG4PEJSGPNctaSwY34E3Jb4Skud4yHpU/O0Gl+PJVwrYvGn0ZH/tmxctLjpXlM3tkooZiT3MroVo91RPM31su+oYyyiv+F1nC2HwRNn1kAOiRRMPL5gQwMiRUZYKppcItJ9o="
9+
script: npm run test:coverage
10+
before_script:
11+
- npm install codeclimate-test-reporter -g
12+
after_script:
13+
- codeclimate-test-reporter < ./coverage/lcov.info
14+
notifications:
15+
email:
16+
recipients:
17+
18+
on_success: never
19+
on_failure: always

.yalcignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
example

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# template [![Build Status](https://travis-ci.com/react-native-hooks/template.svg?branch=master)](https://travis-ci.com/react-native-hooks/template) [![Maintainability](https://api.codeclimate.com/v1/badges/66997889d9122a22f79b/maintainability)](https://codeclimate.com/github/react-native-hooks/template/maintainability)
2+
> A template for creating React Native hooks project
3+
4+
### Installation
5+
6+
```bash
7+
$ git clone https://github.com/react-native-hooks/template.git example-template
8+
$ cd example-template
9+
```
10+
11+
The dependencies are linked using [yalc](https://github.com/whitecolor/yalc).
12+
You can link them locally and test using the [examples](https://github.com/react-native-hooks/template/tree/master/example) directory.

_tests_/index.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import useShare from '../src';
2+
3+
describe('Test Share function', () => {
4+
it('should be a function', () => {
5+
expect(typeof useShare).toBe('function');
6+
});
7+
});

example/.buckconfig

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

example/.flowconfig

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore unexpected extra "@providesModule"
9+
.*/node_modules/.*/node_modules/fbjs/.*
10+
11+
; Ignore duplicate module providers
12+
; For RN Apps installed via npm, "Libraries" folder is inside
13+
; "node_modules/react-native" but in the source repo it is in the root
14+
.*/Libraries/react-native/React.js
15+
16+
; Ignore polyfills
17+
.*/Libraries/polyfills/.*
18+
19+
; Ignore metro
20+
.*/node_modules/metro/.*
21+
22+
[include]
23+
24+
[libs]
25+
node_modules/react-native/Libraries/react-native/react-native-interface.js
26+
node_modules/react-native/flow/
27+
28+
[options]
29+
emoji=true
30+
31+
esproposal.optional_chaining=enable
32+
esproposal.nullish_coalescing=enable
33+
34+
module.system=haste
35+
module.system.haste.use_name_reducers=true
36+
# get basename
37+
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
38+
# strip .js or .js.flow suffix
39+
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
40+
# strip .ios suffix
41+
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
42+
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
43+
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
44+
module.system.haste.paths.blacklist=.*/__tests__/.*
45+
module.system.haste.paths.blacklist=.*/__mocks__/.*
46+
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
47+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
48+
49+
munge_underscores=true
50+
51+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
52+
53+
module.file_ext=.js
54+
module.file_ext=.jsx
55+
module.file_ext=.json
56+
module.file_ext=.native.js
57+
58+
suppress_type=$FlowIssue
59+
suppress_type=$FlowFixMe
60+
suppress_type=$FlowFixMeProps
61+
suppress_type=$FlowFixMeState
62+
63+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
64+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
65+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
66+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
67+
68+
[version]
69+
^0.92.0

example/.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

example/.gitignore

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
project.xcworkspace
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
33+
# node.js
34+
#
35+
node_modules/
36+
npm-debug.log
37+
yarn-error.log
38+
39+
# BUCK
40+
buck-out/
41+
\.buckd/
42+
*.keystore
43+
44+
# fastlane
45+
#
46+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47+
# screenshots whenever they are needed.
48+
# For more information about the recommended setup visit:
49+
# https://docs.fastlane.tools/best-practices/source-control/
50+
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots
54+
55+
# Bundle artifact
56+
*.jsbundle

example/.watchmanconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

example/App.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* eslint-disable no-useless-concat, no-unused-vars */
2+
import React from 'react';
3+
import { StyleSheet, Text, Button, View } from 'react-native';
4+
import useShare from '@rnhooks/share';
5+
6+
const styles = StyleSheet.create({
7+
container: {
8+
flex: 1,
9+
justifyContent: 'center',
10+
alignItems: 'center',
11+
backgroundColor: '#F5FCFF',
12+
},
13+
welcome: {
14+
fontSize: 20,
15+
textAlign: 'center',
16+
margin: 10,
17+
},
18+
instructions: {
19+
textAlign: 'center',
20+
color: '#333333',
21+
marginBottom: 5,
22+
},
23+
});
24+
25+
function App() {
26+
const [onShare, shared, loading, error] = useShare();
27+
return (
28+
<View style={styles.container}>
29+
<Text style={styles.welcome}>@rnhooks/share</Text>
30+
<Button title="Share" onPress={onShare} />
31+
{!(loading || error) && (
32+
<Text style={styles.instructions}>{shared.toString()}</Text>
33+
)}
34+
</View>
35+
);
36+
}
37+
38+
export default App;

example/__tests__/App-test.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import renderer from 'react-test-renderer';
8+
import App from '../App';
9+
10+
// Note: test renderer must be required after react-native.
11+
12+
it('renders correctly', () => {
13+
renderer.create(<App />);
14+
});

example/android/app/BUCK

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# To learn about Buck see [Docs](https://buckbuild.com/).
2+
# To run your application with Buck:
3+
# - install Buck
4+
# - `npm start` - to start the packager
5+
# - `cd android`
6+
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7+
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8+
# - `buck install -r android/app` - compile, install and run application
9+
#
10+
11+
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12+
13+
lib_deps = []
14+
15+
create_aar_targets(glob(["libs/*.aar"]))
16+
17+
create_jar_targets(glob(["libs/*.jar"]))
18+
19+
android_library(
20+
name = "all-libs",
21+
exported_deps = lib_deps,
22+
)
23+
24+
android_library(
25+
name = "app-code",
26+
srcs = glob([
27+
"src/main/java/**/*.java",
28+
]),
29+
deps = [
30+
":all-libs",
31+
":build_config",
32+
":res",
33+
],
34+
)
35+
36+
android_build_config(
37+
name = "build_config",
38+
package = "com.example",
39+
)
40+
41+
android_resource(
42+
name = "res",
43+
package = "com.example",
44+
res = "src/main/res",
45+
)
46+
47+
android_binary(
48+
name = "app",
49+
keystore = "//android/keystores:debug",
50+
manifest = "src/main/AndroidManifest.xml",
51+
package_type = "debug",
52+
deps = [
53+
":app-code",
54+
],
55+
)

0 commit comments

Comments
 (0)