Skip to content

Commit

Permalink
TS Migration - v.0.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
MadeinFrance committed Aug 25, 2023
1 parent 4f40d2e commit 0f5341f
Show file tree
Hide file tree
Showing 148 changed files with 29,682 additions and 12,679 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ version: 2
jobs:
build:
docker:
- image: circleci/node:11.10.1
- image: circleci/node:16.13.0
steps:
- checkout
- run: yarn install
- run: yarn lint
- run: yarn flow
- run: yarn check-types
- run: yarn test
- run: yarn test --coverage
- run: yarn test-coverage-report -t 9f251d4c-7f8a-41cf-a469-8fa096d58584
- run: yarn test-coverage-report -t 9f251d4c-7f8a-41cf-a469-8fa096d58584
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ charset = utf-8
end_of_line = lf
insert_final_newline = true

[**/{.js,package.json}]
[**/{.js,.ts{x},package.json}]
indent_style = space
indent_size = 2
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
demo/**/*
lib/**/*
flow-typed/**/*
preprocessor.js
mockData.js
mockData.js
63 changes: 50 additions & 13 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,57 @@
{
"parser": "babel-eslint",
"extends": "airbnb",
"env": {
"es6": true,
"jest": true
},
"extends": ["plugin:react/recommended", "airbnb"],
"globals": {
"jest": false
"jest": false,
"__DEV__": false
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint"],
"rules": {
"no-mixed-operators": 0,
"react/jsx-filename-extension": 0,
"react/prefer-stateless-function": 0,
"import/no-extraneous-dependencies": 0,
"react/destructuring-assignment": 0,
"operator-linebreak": 0,
"react/sort-comp": 0,
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 0 }],
"no-underscore-dangle": 0,
"class-methods-use-this": 0,
"import/extensions": 0,
"no-plusplus": 0,
"no-await-in-loop": 0,
"max-classes-per-file": 0,
"global-require": 0,
"react/jsx-filename-extension": 0,
"react/require-default-props": 0,
"lines-between-class-members": 0,
"react/destructuring-assignment": 0
}
"no-use-before-define": 0,
"react/jsx-props-no-spreading": 0,
"react/static-property-placement": 0,
"@typescript-eslint/no-use-before-define": ["error"]
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"parser": "@typescript-eslint/parser",
"rules": {
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/consistent-type-imports": [
2,
{ "prefer": "type-imports" }
]
}
}
]
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ build/
.gradle
.idea
local.properties
*.iml
*.iml

# generated
/lib/
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ __tests__
.github
.babelrc
.eslintignore
preprocessor.js
**/__tests__/**/*
build
CONTRIBUTING.md
Expand Down
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
bracketSpacing: true,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: "all",
arrowParens: "avoid",
};
44 changes: 23 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@

# react-native-share-pdf

[![npm version](https://badge.fury.io/js/react-native-share-pdf.svg)](https://badge.fury.io/js/react-native-share-pdf)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/3a793d6ce3894ea490cddd4c78fadc1a)](https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=MadeinFrance/react-native-share-base64-pdf&utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/cba8fd0874ac4f569f4f880e473cbac9?branch=master)](https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=MadeinFrance/react-native-share-base64-pdf&utm_campaign=Badge_Grade)
[![codecov](https://codecov.io/gh/MadeinFrance/react-native-share-pdf/branch/master/graph/badge.svg?token=zRjKYpheMI)](https://codecov.io/gh/MadeinFrance/react-native-share-pdf)
[![CircleCI](https://circleci.com/gh/MadeinFrance/react-native-share-pdf/tree/master.svg?style=shield)](https://circleci.com/gh/MadeinFrance/react-native-share-base64-pdf/)


Android Library for saving and sharing a base64 encoded PDF.

## Motivation
****

---

Sharing a base64 PDF works on iOS with the React Native API but it's not working for Android. The `ShareFile` JAVA module shows that's possible by saving the document on local storage of the device and sharing it.

## Demo

Android | iOS
------- | ---
![Android](https://github.com/MadeinFrance/react-native-share-pdf/raw/master/demo/res/android.gif) | ![iOS](https://github.com/MadeinFrance/react-native-share-pdf/raw/master/demo/res/ios.gif)
| Android | iOS |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| ![Android](https://github.com/MadeinFrance/react-native-share-pdf/raw/master/demo/res/android.gif) | ![iOS](https://github.com/MadeinFrance/react-native-share-pdf/raw/master/demo/res/ios.gif) |

## Install

Expand All @@ -28,37 +28,39 @@ npm i react-native-share-pdf
## Usage

```js
import RNShareFile from 'react-native-share-pdf';
import sharePDF from 'react-native-share-pdf';

async function loadAndSharePDF() {
const showError = await RNShareFile.sharePDF(mockData.document, mockData.filename);
if (showError) {
const showError = await sharePDF(mockData.document, mockData.filename);
if (showError !== undefined) {
console.log(showError);
// Do something with the error
}
}

```

## Methods

* RNShareFile.share(base64Data, documentFileName);
- RNShareFile.share(base64Data, documentFileName);

### Manual Installation

React Native > 0.60 will autolink. For earlier versions:

1. Open up `android/app/src/main/java/[...]/MainApplication.java`
- Add `import com.maximegerbe.reactnative.sharefile.ShareFilePackage;` to the imports at the top of the file
- Add `new ShareFilePackage()` to the list returned by the `getPackages()` method

- Add `import com.maximegerbe.reactnative.sharefile.ShareFilePackage;` to the imports at the top of the file
- Add `new ShareFilePackage()` to the list returned by the `getPackages()` method

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

## License

Expand Down
4 changes: 3 additions & 1 deletion android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion android/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions android/.idea/runConfigurations.xml

This file was deleted.

59 changes: 22 additions & 37 deletions android/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions android/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1692884024733</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
4 changes: 2 additions & 2 deletions android/local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Fri Feb 08 16:11:57 CET 2019
sdk.dir=/Users/HB60UY/Library/Android/sdk
#Fri Aug 18 14:53:38 CEST 2023
sdk.dir=/Users/mage/Library/Android/sdk
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package="com.maximegerbe.reactnative.sharefile">
<application>
<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
Expand Down
Loading

0 comments on commit 0f5341f

Please sign in to comment.