Skip to content

Commit

Permalink
wip - react native sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-quiltt committed Oct 23, 2023
1 parent a070ff7 commit c2ac994
Show file tree
Hide file tree
Showing 21 changed files with 10,674 additions and 206 deletions.
81 changes: 81 additions & 0 deletions ECMAScript/react-native/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
const prettierConfig = require('./prettier.config.cjs')

const reactPatterns = {
files: ['*.{jsx,tsx}'],
}

module.exports = {
root: true,
env: {
browser: true,
es6: true,
node: true,
},
settings: {
react: {
version: 'detect',
},
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
ecmaFeatures: {
jsx: true,
},
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'prettier',
],
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
ignoreRestSiblings: true,
argsIgnorePattern: 'res|response|resolve|reject|done|next|err|error|^_',
varsIgnorePattern: '^_',
},
],
'prettier/prettier': ['error', prettierConfig],
},
overrides: [
{
files: reactPatterns.files,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
'plugin:react-hooks/recommended',
'prettier',
],
rules: {
'sort-imports': 'off',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
'react/no-unescaped-entities': ['error', { forbid: ['>'] }],
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',
// Fine-tune naming convention react typescript jsx (function components)
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/naming-convention.md
'prettier/prettier': ['error', prettierConfig],
},
},
{
files: ['*.cjs'],
env: {
node: true,
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
],
}
24 changes: 24 additions & 0 deletions ECMAScript/react-native/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Quiltt Connector React Native SDK

```typescript
import { useState } from 'react'
import { QuilttConnector } from '@quiltt/react-native'

export const App = () => {
const [connectionId, setConnectionId] = useState<string>()
const oAuthRedirectUrl = "quilttexample://open.reactnative.app"
const handleExitSuccess = (metadata) => {
setConnectionId(metadata?.connectionId)
}

return (
<QuilttConnector
connectorId="<CONNECTOR_ID>"
oAuthRedirectUrl={oAuthRedirectUrl}
onExitSuccess={handleExitSuccess}
/>
)
}

export default App
```
35 changes: 35 additions & 0 deletions ECMAScript/react-native/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# dependencies
node_modules/

# Expo
.expo/
dist/
web-build/

# Native
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo
22 changes: 22 additions & 0 deletions ECMAScript/react-native/example/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { StatusBar } from 'expo-status-bar'
import { StyleSheet, Text, View } from 'react-native'
import { QuilttConnector } from '@quiltt/react-native'

export default function App() {
return (
<View style={styles.container}>
<Text>Open up App.tsx to start working on your app!</Text>
<StatusBar style="auto" />
<QuilttConnector connectorId="yldluevd9q" oauthRedirectUrl="https://www.example.com" />
</View>
)
}

const styles = StyleSheet.create({
container: {
flex: 1,
// backgroundColor: '#fff',
// alignItems: 'center',
// justifyContent: 'center',
},
})
30 changes: 30 additions & 0 deletions ECMAScript/react-native/example/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"expo": {
"name": "example",
"slug": "example",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
}
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ECMAScript/react-native/example/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ECMAScript/react-native/example/assets/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions ECMAScript/react-native/example/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
31 changes: 31 additions & 0 deletions ECMAScript/react-native/example/metro.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Link local packages in React Native, metro doesn't like symlink
// https://medium.com/@alielmajdaoui/linking-local-packages-in-react-native-the-right-way-2ac6587dcfa2

// Learn more https://docs.expo.io/guides/customizing-metro

const { resolve } = require('path')

const siblings = {
'@quiltt/react-native': resolve(__dirname, '..', 'src'),
}

module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
resolver: {
extraNodeModules: new Proxy(
{},
{
get: (target, name) =>
name in siblings ? siblings[name] : resolve(process.cwd(), 'node_modules', name),
}
),
},
watchFolders: [...Object.values(siblings)],
}
24 changes: 24 additions & 0 deletions ECMAScript/react-native/example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "example",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"expo": "~49.0.15",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-native": "0.72.6",
"react-native-webview": "13.2.2"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@types/react": "~18.2.14",
"typescript": "^5.1.3"
},
"private": true
}
6 changes: 6 additions & 0 deletions ECMAScript/react-native/example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true
}
}
Loading

0 comments on commit c2ac994

Please sign in to comment.