react-native-s-pen 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -0
- package/android/build.gradle +33 -0
- package/android/consumer-rules.pro +2 -0
- package/android/gradle.properties +3 -0
- package/android/libs/README.md +10 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/samsungspen/NativeSpenModule.java +910 -0
- package/android/src/main/java/com/samsungspen/SpenCanvasManager.java +67 -0
- package/android/src/main/java/com/samsungspen/SpenCanvasView.java +186 -0
- package/android/src/main/java/com/samsungspen/SpenPackage.java +57 -0
- package/package.json +46 -0
- package/react-native.config.js +9 -0
- package/src/SPen.ts +179 -0
- package/src/SpenCanvas.tsx +47 -0
- package/src/index.ts +15 -0
- package/src/native.ts +29 -0
- package/src/specs/NativeSpenModule.ts +50 -0
- package/src/specs/SpenCanvasNativeComponent.ts +23 -0
- package/src/types.ts +79 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { codegenNativeComponent } from "react-native";
|
|
2
|
+
import type { CodegenTypes, HostComponent, ViewProps } from "react-native";
|
|
3
|
+
|
|
4
|
+
export type NativeSpenCanvasPoint = Readonly<{
|
|
5
|
+
x: CodegenTypes.Float;
|
|
6
|
+
y: CodegenTypes.Float;
|
|
7
|
+
pressure: CodegenTypes.Float;
|
|
8
|
+
tilt: CodegenTypes.Float;
|
|
9
|
+
hoverDistance: CodegenTypes.Float;
|
|
10
|
+
timestamp: CodegenTypes.Double;
|
|
11
|
+
action: string;
|
|
12
|
+
toolType: string;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
export interface NativeProps extends ViewProps {
|
|
16
|
+
inkColor?: string;
|
|
17
|
+
minStrokeWidth?: CodegenTypes.Float;
|
|
18
|
+
maxStrokeWidth?: CodegenTypes.Float;
|
|
19
|
+
clearToken?: CodegenTypes.Int32;
|
|
20
|
+
onSpenDraw?: CodegenTypes.DirectEventHandler<NativeSpenCanvasPoint>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default codegenNativeComponent<NativeProps>("SpenCanvas") as HostComponent<NativeProps>;
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export type SpenCapability =
|
|
2
|
+
| "stylusInput"
|
|
3
|
+
| "hover"
|
|
4
|
+
| "button"
|
|
5
|
+
| "airActions"
|
|
6
|
+
| "airCommand"
|
|
7
|
+
| "pressure";
|
|
8
|
+
|
|
9
|
+
export type SpenRemoteFeature = "button" | "airMotion";
|
|
10
|
+
|
|
11
|
+
export type SpenInsertionState = "inserted" | "detached" | "unknown";
|
|
12
|
+
|
|
13
|
+
export type SpenConnectionState =
|
|
14
|
+
| "connected"
|
|
15
|
+
| "disconnected"
|
|
16
|
+
| "disconnectedByUnknownReason"
|
|
17
|
+
| "connectionFailed"
|
|
18
|
+
| "unsupportedDevice"
|
|
19
|
+
| "unknown";
|
|
20
|
+
|
|
21
|
+
export type SpenErrorCode =
|
|
22
|
+
| "unsupportedDevice"
|
|
23
|
+
| "connectionFailed"
|
|
24
|
+
| "unknown";
|
|
25
|
+
|
|
26
|
+
export type SpenDeviceInfo = {
|
|
27
|
+
platform: "android";
|
|
28
|
+
manufacturer: string;
|
|
29
|
+
brand: string;
|
|
30
|
+
model: string;
|
|
31
|
+
sdkInt: number;
|
|
32
|
+
isSamsungDevice: boolean;
|
|
33
|
+
capabilities: SpenCapability[];
|
|
34
|
+
samsungSdk?: {
|
|
35
|
+
available: boolean;
|
|
36
|
+
versionCode?: number;
|
|
37
|
+
versionName?: string;
|
|
38
|
+
connected?: boolean;
|
|
39
|
+
featureFlags?: Partial<Record<SpenRemoteFeature, boolean>>;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type SpenEventName =
|
|
44
|
+
| "spen-hover"
|
|
45
|
+
| "spen-button"
|
|
46
|
+
| "spen-down"
|
|
47
|
+
| "spen-move"
|
|
48
|
+
| "spen-up"
|
|
49
|
+
| "spen-status"
|
|
50
|
+
| "spen-insertion-state"
|
|
51
|
+
| "spen-connection-state"
|
|
52
|
+
| "spen-error"
|
|
53
|
+
| "spen-air-action";
|
|
54
|
+
|
|
55
|
+
export type SpenPoint = {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
pressure?: number;
|
|
59
|
+
/** Raw device-specific distance from the display during hover events. */
|
|
60
|
+
hoverDistance?: number;
|
|
61
|
+
tilt?: number;
|
|
62
|
+
tiltX?: number;
|
|
63
|
+
tiltY?: number;
|
|
64
|
+
toolType?: "stylus" | "finger" | "mouse" | "unknown";
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type SpenEventPayload = {
|
|
68
|
+
name: SpenEventName;
|
|
69
|
+
timestamp: number;
|
|
70
|
+
point?: SpenPoint;
|
|
71
|
+
action?: string;
|
|
72
|
+
buttonState?: number;
|
|
73
|
+
connectionState?: SpenConnectionState;
|
|
74
|
+
insertionState?: SpenInsertionState;
|
|
75
|
+
errorCode?: SpenErrorCode;
|
|
76
|
+
raw?: Record<string, unknown>;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type SpenListener = (event: SpenEventPayload) => void;
|