Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jobeso committed Apr 11, 2019
0 parents commit 968be61
Show file tree
Hide file tree
Showing 21 changed files with 2,677 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": ["airbnb", "prettier", "prettier/react"],
"parser": "babel-eslint",
"plugins": ["react", "jsx-a11y", "import", "prettier"],
"rules": {
"import/no-extraneous-dependencies": 0,
"func-names": 0,
"import/extensions": 0,
"import/no-named-as-default": 0,
"import/no-named-as-default-member": 0,
"import/no-unresolved": 1,
"jsx-a11y/no-static-element-interactions": 0,
"no-extra-boolean-cast": 0,
"no-plusplus": 0,
"no-sequences": 0,
"no-script-url": 0,
"no-unused-vars": 1,
"react/no-did-update-set-state": 0,
"spaced-comment": 0
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

# OSX
#
.DS_Store

# node.js
#
node_modules/
npm-debug.log
yarn-error.log


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


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

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

14 changes: 14 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"bracketSpacing": true,
"insertPragma": false,
"jsxBracketSameLine": false,
"parser": "babylon",
"printWidth": 80,
"proseWrap": "always",
"requirePragma": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
}
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
]
}
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# react-native-story-share

Currently only supports sharing of base64 images

## Getting started

`$ npm install react-native-story-share --save`

or

`$ yarn add react-native-story-share`

## Installation
1. Either choose `Mostly automatic installation` or `Manual installation`
2. Follow the `Integration` guide

### Mostly automatic installation

`$ react-native link react-native-story-share`

### Manual installation

#### iOS

1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
2. Go to `node_modules``react-native-story-share` and add `RNStoryShare.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libRNStoryShare.a` to your project's `Build Phases``Link Binary With Libraries`
4. Run your project (`Cmd+R`)

#### Android

1. Open up `android/app/src/main/java/[...]/MainActivity.java`

- Add `import com.jobeso.RNStorySharePackage;` to the imports at the top of the file
- Add `new RNStorySharePackage()` to the list returned by the `getPackages()` method

2. Append the following lines to `android/settings.gradle`:
```
include ':react-native-story-share'
project(':react-native-story-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-story-share/android')
```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
```
compile project(':react-native-story-share')
```

## Integration

### iOS

#### Swift

1. Under `Build Settings` section `Build Options` set `Always Embed Swift Started Libraries` to `true`
2. Make sure you have the following under `library search paths`

```
$(inherited)
$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
```

#### Info.plist

+ add `instagram-stories` and `snapchat` to the `LSApplicationQueriesSchemes` key in your app's Info.plist.

```
...
<key>LSApplicationQueriesSchemes</key>
<array>
...
<string>instagram-stories</string>
<string>snapchat</string>
</array>
...
```

## Usage

```javascript
import RNStoryShare from "react-native-story-share";

RNStoryShare.isInstagramAvailable()
.then(isAvailable => {
// your code
})
.catch(e => console.log(e));

RNStoryShare.share({
type: RNStoryShare.Types.BASE64,
attributionLink: 'https://myproject.com',
backgroundAsset: '',
stickerAsset: '', // currently iOS only
});
```
36 changes: 36 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}

repositories {
mavenCentral()
}

dependencies {
compile 'com.facebook.react:react-native:+'
}

22 changes: 22 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jobeso">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application>

<provider
android:name="com.jobeso.RNStoryShareFileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>

</application>

</manifest>

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.jobeso;

import android.support.v4.content.FileProvider;

public class RNStoryShareFileProvider extends FileProvider {
}
Loading

0 comments on commit 968be61

Please sign in to comment.