forked from react-native-tvos/react-native-tvos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtvos-types.d.ts
165 lines (148 loc) · 4.79 KB
/
tvos-types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import React from 'react';
import { ViewProps, ScrollViewProps } from 'react-native';
declare module 'react-native' {
interface ViewProps {
/**
* TV next focus down (see documentation for the View component).
*/
nextFocusDown?: number,
/**
* TV next focus forward (see documentation for the View component).
*
* @platform android
*/
nextFocusForward?: number,
/**
* TV next focus left (see documentation for the View component).
*/
nextFocusLeft?: number,
/**
* TV next focus right (see documentation for the View component).
*/
nextFocusRight?: number,
/**
* TV next focus up (see documentation for the View component).
*/
nextFocusUp?: number,
}
export const useTVEventHandler: (handleEvent: (event: HWEvent) => void) => void;
export const TVEventControl: {
enableTVMenuKey(): void;
disableTVMenuKey(): void;
enableTVPanGesture(): void;
disableTVPanGesture(): void;
enableGestureHandlersCancelTouches(): void;
disableGestureHandlersCancelTouches(): void;
};
export type HWEvent = {
eventType: 'up' | 'down' | 'right' | 'left' | 'longUp' | 'longDown' | 'longRight' | 'longLeft' | 'blur' | 'focus' | 'pan' | string;
eventKeyAction?: -1 | 1 | 0 | number;
tag?: number;
body?: {
state: "Began" | "Changed" | "Ended",
x: number,
y: number,
velocityx: number,
velocityy: number
}
};
export class TVEventHandler {
enable<T extends React.Component<unknown>>(
component?: T,
callback?: (component: T, data: HWEvent) => void
): void;
disable(): void;
}
export interface FocusGuideProps extends ViewProps {
/**
* If the view should be "visible". display "flex" if visible, otherwise "none".
* Defaults to true
*/
enabled?: boolean;
/**
* Array of `Component`s to register as destinations with `UIFocusGuide`
*/
destinations?: (null | number | React.Component<any, any> | React.ComponentClass<any>)[];
/**
* If true, `TVFocusGuide` will automatically manage focus for you.
* It will redirect the focus to the first focusable child on the first visit.
* It also remembers the last focused child and redirects the focus
* to it on the subsequent visits.
*
* @default false
*/
autoFocus?: boolean;
/**
* @deprecated Don't use it, no longer necessary.
*/
safePadding?: 'both' | 'vertical' | 'horizontal' | null;
}
/**
* This component provides support for Apple's `UIFocusGuide` API,
* to help ensure that focusable controls can be navigated to,
* even if they are not directly in line with other controls.
* An example is provided in `RNTester` that shows two different ways of using this component.
* https://github.com/react-native-tvos/react-native-tvos/blob/tvos-v0.63.4/RNTester/js/examples/TVFocusGuide/TVFocusGuideExample.js
*/
export class TVFocusGuideView extends React.Component<FocusGuideProps> {}
export interface TVTextScrollViewProps extends ScrollViewProps {
/**
* The duration of the scroll animation when a swipe is detected.
* Default value is 0.3 s
*/
scrollDuration?: number;
/**
* Scrolling distance when a swipe is detected
* Default value is half the visible height (vertical scroller)
* or width (horizontal scroller)
*/
pageSize?: number;
/**
* If true, will scroll to start when focus moves out past the beginning
* of the scroller
* Defaults to true
*/
snapToStart?: boolean;
/**
* If true, will scroll to end when focus moves out past the end of the
* scroller
* Defaults to true
*/
snapToEnd?: boolean;
/**
* Called when the scroller comes into focus (e.g. for highlighting)
*/
onFocus?(evt: HWEvent): void;
/**
* Called when the scroller goes out of focus
*/
onBlur?(evt: HWEvent): void;
}
export class TVTextScrollView extends React.Component<TVTextScrollViewProps> {}
export interface PressableStateCallbackType {
readonly focused: boolean;
}
export interface TouchableWithoutFeedbackPropsIOS {
/**
* *(Apple TV only)* TV preferred focus (see documentation for the View component).
*
* @platform ios
*/
hasTVPreferredFocus?: boolean;
/**
* *(Apple TV only)* Object with properties to control Apple TV parallax effects.
*
* enabled: If true, parallax effects are enabled. Defaults to true.
* shiftDistanceX: Defaults to 2.0.
* shiftDistanceY: Defaults to 2.0.
* tiltAngle: Defaults to 0.05.
* magnification: Defaults to 1.0.
* pressMagnification: Defaults to 1.0.
* pressDuration: Defaults to 0.3.
* pressDelay: Defaults to 0.0.
*
* @platform ios
*/
tvParallaxProperties?: TVParallaxProperties;
}
}