Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dotconnor committed Jan 31, 2020
1 parent 92cf345 commit 98afae0
Show file tree
Hide file tree
Showing 10 changed files with 1,196 additions and 242 deletions.
17 changes: 17 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "a1motion/typescript-react",
"parserOptions": {
"project": "./tsconfig.json",
"createDefaultProgram": true
},
"settings": {
"react": {
"version": "999"
}
},
"rules": {
"require-atomic-updates": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/member-delimiter-style": 0
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,5 @@ DerivedData
*.ipa
*.xcuserstate
project.xcworkspace

dist/
19 changes: 19 additions & 0 deletions KeyCommands.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = package['name']
s.version = package['version']
s.summary = package['description']
s.license = package['license']

s.authors = package['author']
s.homepage = package['homepage']
s.platform = :ios, "9.0"

s.source = { :git => "https://github.com/dotconnor/react-native-key-commands.git" }
s.source_files = "ios/**/*.{h,m}"

s.dependency 'React'
end
29 changes: 0 additions & 29 deletions dist/index.d.ts

This file was deleted.

36 changes: 0 additions & 36 deletions dist/index.js

This file was deleted.

34 changes: 24 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
{
"name": "@envoy/react-native-key-commands",
"name": "@dotconnor/react-native-key-commands",
"version": "0.0.5",
"homepage": "https://github.com/dotconnor/react-native-key-commands",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"keywords": ["react-native"],
"keywords": [
"react-native"
],
"files": [
"dist",
"ios",
"KeyCommands.podspec"
],
"license": "MIT",
"author": {
"name": "Fang-Pen Lin",
"email": "[email protected]",
"url": "https://fangpenlin.com"
"author": "Fang-Pen Lin <[email protected]>",
"scripts": {
"test": "exit 0;",
"build": "tsc",
"prepublishOnly": "yarn build"
},
"rnpm": {},
"devDependencies": {
"@types/node": "^8.0.26",
"@types/react": "^16.0.5",
"@types/react-native": "^0.47.8",
"tslint": "^5.7.0",
"tslint-config-standard": "^6.0.1",
"tslint-react": "^3.2.0",
"@typescript-eslint/eslint-plugin": "^2.18.0",
"@typescript-eslint/parser": "^2.18.0",
"babel-eslint": "^10.0.3",
"eslint": "^6.8.0",
"eslint-config-a1motion": "^3.1.2",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.18.0",
"prettier": "^1.19.1",
"typescript": "^2.4.2"
}
}
52 changes: 23 additions & 29 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ import {
NativeSyntheticEvent,
StyleSheet,
ViewStyle,
requireNativeComponent
} from 'react-native'
requireNativeComponent,
} from "react-native";
import React from "react";

import React from 'react'

const { KeyCommandConstants } = NativeModules
const RCTKeyCommands = requireNativeComponent('RCTKeyCommands')
const { KeyCommandConstants } = NativeModules;
const RCTKeyCommands = requireNativeComponent(`RCTKeyCommands`);
const defaultStyles = StyleSheet.create({
main: {
backgroundColor: 'transparent'
}
})
backgroundColor: `transparent`,
},
});

export const constants = {
keyModifierShift: KeyCommandConstants.keyModifierShift as number,
Expand All @@ -27,41 +26,36 @@ export const constants = {
keyInputLeftArrow: KeyCommandConstants.keyInputLeftArrow as string,
keyInputRightArrow: KeyCommandConstants.keyInputRightArrow as string,
keyInputEscape: KeyCommandConstants.keyInputEscape as string,
}

};
export interface KeyCommand {
/// The input key, could be something like '1' stands for '1' key,
/// constatns like keyInputUpArrow and others can also be used here
input: string
input: string;
/// Key modifier to be used along with the key press, like Command + Alt
/// can be passed like
///
/// constatns.keyModifierCommand | constants.keyModifierAlternate
///
keyModifier?: number
keyModifier?: number;
/// Title of discoverability to display, leave it as undefined means we
/// don't want the key command to be displayed in discoverability overlayer
/// UI
discoverabilityTitle?: string
discoverabilityTitle?: string;
}

export interface Props {
style?: ViewStyle
style?: ViewStyle;
/// Key commands
keyCommands: Array<KeyCommand>
keyCommands: KeyCommand[];
/// Callback function to be called when key command event emits
onKeyCommand?: (event: NativeSyntheticEvent<KeyCommand>) => void
onKeyCommand?: (event: NativeSyntheticEvent<KeyCommand>) => void;
/// ID for UI automatic testing
testID?: string
testID?: string;
}

export default class KeyCommands extends React.Component<Props> {
render () {
const { style, ...props } = this.props
return (
<RCTKeyCommands
{...{...props, style: [defaultStyles.main, style]}}
/>
)
}
export default function KeyCommands({
style,
...props
}: React.PropsWithChildren<Props>) {
return (
<RCTKeyCommands {...{ ...props, style: [defaultStyles.main, style] }} />
);
}
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"noUnusedParameters": true,
"noImplicitReturns": true,
"declaration": true,
"outDir": "./dist"
},
"types": ["jest", "node"]
"outDir": "./dist",
"rootDir": "./src"
}
}
13 changes: 0 additions & 13 deletions tslint.json

This file was deleted.

Loading

0 comments on commit 98afae0

Please sign in to comment.