forked from envoy/react-native-key-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f5be8e
commit e2e7c54
Showing
7 changed files
with
431 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// <reference types="react" /> | ||
import { ViewStyle } from 'react-native'; | ||
import React from 'react'; | ||
export declare const constants: { | ||
keyModifierShift: number; | ||
keyModifierControl: number; | ||
keyModifierAlternate: number; | ||
keyModifierCommand: number; | ||
keyModifierNumericPad: number; | ||
keyInputUpArrow: string; | ||
keyInputDownArrow: string; | ||
keyInputLeftArrow: string; | ||
keyInputRightArrow: string; | ||
keyInputEscape: string; | ||
}; | ||
export interface KeyCommand { | ||
input: string; | ||
keyModifier?: number; | ||
discoverabilityTitle?: string; | ||
} | ||
export interface Props { | ||
style?: ViewStyle; | ||
keyCommands: Array<KeyCommand>; | ||
testID?: string; | ||
} | ||
export default class KeyCommands extends React.Component<Props> { | ||
render(): JSX.Element; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) | ||
t[p[i]] = s[p[i]]; | ||
return t; | ||
}; | ||
import { NativeModules, StyleSheet, requireNativeComponent } from 'react-native'; | ||
import React from 'react'; | ||
const { KeyCommandConstants } = NativeModules; | ||
const RCTKeyCommands = requireNativeComponent('RCTRCTKeyCommands'); | ||
const defaultStyles = StyleSheet.create({ | ||
main: { | ||
backgroundColor: 'transparent' | ||
} | ||
}); | ||
export const constants = { | ||
keyModifierShift: KeyCommandConstants.keyModifierShift, | ||
keyModifierControl: KeyCommandConstants.keyModifierControl, | ||
keyModifierAlternate: KeyCommandConstants.keyModifierAlternate, | ||
keyModifierCommand: KeyCommandConstants.keyModifierCommand, | ||
keyModifierNumericPad: KeyCommandConstants.keyModifierNumericPad, | ||
keyInputUpArrow: KeyCommandConstants.keyInputUpArrow, | ||
keyInputDownArrow: KeyCommandConstants.keyInputDownArrow, | ||
keyInputLeftArrow: KeyCommandConstants.keyInputLeftArrow, | ||
keyInputRightArrow: KeyCommandConstants.keyInputRightArrow, | ||
keyInputEscape: KeyCommandConstants.keyInputEscape, | ||
}; | ||
export default class KeyCommands extends React.Component { | ||
render() { | ||
const _a = this.props, { style } = _a, props = __rest(_a, ["style"]); | ||
return (<RCTKeyCommands {...Object.assign({}, props, { style: [defaultStyles.main, style] })}/>); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// RCTKeyCommandConstants.h | ||
// Envoy | ||
// | ||
// Created by Fang-Pen Lin on 3/14/18. | ||
// Copyright © 2018 Envoy Inc. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <React/RCTBridgeModule.h> | ||
|
||
@interface RCTKeyCommandConstants : NSObject<RCTBridgeModule> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// RCTKeyCommandConstants.m | ||
// Envoy | ||
// | ||
// Created by Fang-Pen Lin on 3/14/18. | ||
// Copyright © 2018 Envoy Inc. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "RCTKeyCommandConstants.h" | ||
|
||
@implementation RCTKeyCommandConstants | ||
|
||
RCT_EXPORT_MODULE(); | ||
|
||
- (NSDictionary *)constantsToExport { | ||
return @{ | ||
@"keyModifierShift": @(UIKeyModifierAlphaShift), | ||
@"keyModifierControl": @(UIKeyModifierControl), | ||
@"keyModifierAlternate": @(UIKeyModifierAlternate), | ||
@"keyModifierCommand": @(UIKeyModifierCommand), | ||
@"keyModifierNumericPad": @(UIKeyModifierNumericPad), | ||
@"keyInputUpArrow": UIKeyInputUpArrow, | ||
@"keyInputDownArrow": UIKeyInputDownArrow, | ||
@"keyInputLeftArrow": UIKeyInputLeftArrow, | ||
@"keyInputRightArrow": UIKeyInputRightArrow, | ||
@"keyInputEscape": UIKeyInputEscape | ||
}; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.