@applicaster/zapp-react-dom-app 12.0.5 → 12.0.6
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/App/InteractionManager/index.tsx +145 -69
- package/package.json +6 -6
|
@@ -33,7 +33,10 @@ import {
|
|
|
33
33
|
import { PlayerContentContext } from "@applicaster/zapp-react-dom-ui-components/Contexts";
|
|
34
34
|
|
|
35
35
|
import { withNavigator } from "@applicaster/zapp-react-native-ui-components/Decorators/Navigator";
|
|
36
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
getXray,
|
|
38
|
+
createLogger,
|
|
39
|
+
} from "@applicaster/zapp-react-native-utils/logger";
|
|
37
40
|
|
|
38
41
|
import {
|
|
39
42
|
confirmationDialogStore,
|
|
@@ -52,6 +55,11 @@ import { KeyboardLongPressManager } from "@applicaster/zapp-react-dom-ui-compone
|
|
|
52
55
|
const { withXray } = getXray();
|
|
53
56
|
const globalAny: any = global;
|
|
54
57
|
|
|
58
|
+
const { log_debug, log_warning } = createLogger({
|
|
59
|
+
category: "InteractionManager",
|
|
60
|
+
subsystem: "zapp-react-dom-app",
|
|
61
|
+
});
|
|
62
|
+
|
|
55
63
|
const shouldUseOnScreenKeyboard = () =>
|
|
56
64
|
isVizioPlatform() || window.applicaster.useOnScreenKeyboard;
|
|
57
65
|
|
|
@@ -149,13 +157,16 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
149
157
|
this.onConfirmDialogOpen = this.onConfirmDialogOpen.bind(this);
|
|
150
158
|
this.onConfirmDialogClose = this.onConfirmDialogClose.bind(this);
|
|
151
159
|
|
|
160
|
+
this.handlePhysicalKeyboardDismiss =
|
|
161
|
+
this.handlePhysicalKeyboardDismiss.bind(this);
|
|
162
|
+
|
|
152
163
|
this.confirmDialog.setConfirmAction(this.performExit);
|
|
153
164
|
this.confirmDialog.setCancelAction(this.onConfirmDialogClose);
|
|
154
165
|
this.longPressDetector = new KeyboardLongPressManager();
|
|
155
166
|
}
|
|
156
167
|
|
|
157
168
|
componentDidMount() {
|
|
158
|
-
window.addEventListener("keydown", this.onKeyDownListener);
|
|
169
|
+
window.addEventListener("keydown", this.onKeyDownListener, true);
|
|
159
170
|
window.addEventListener("keyup", this.onKeyUp);
|
|
160
171
|
window.addEventListener("mousemove", this.onMouseMoveListener);
|
|
161
172
|
|
|
@@ -185,6 +196,11 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
185
196
|
"onLongPressRelease",
|
|
186
197
|
this.handleLongPressRelease.bind(this)
|
|
187
198
|
);
|
|
199
|
+
|
|
200
|
+
document.addEventListener(
|
|
201
|
+
"keyboardDismissedByPhysicalKeypress",
|
|
202
|
+
this.handlePhysicalKeyboardDismiss
|
|
203
|
+
);
|
|
188
204
|
}
|
|
189
205
|
|
|
190
206
|
componentWillUnmount() {
|
|
@@ -213,6 +229,11 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
213
229
|
"onLongPressRelease",
|
|
214
230
|
this.handleLongPressRelease
|
|
215
231
|
);
|
|
232
|
+
|
|
233
|
+
document.removeEventListener(
|
|
234
|
+
"keyboardDismissedByPhysicalKeypress",
|
|
235
|
+
this.handlePhysicalKeyboardDismiss
|
|
236
|
+
);
|
|
216
237
|
}
|
|
217
238
|
|
|
218
239
|
performExit() {
|
|
@@ -274,8 +295,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
274
295
|
this.handleWebOsBack();
|
|
275
296
|
}
|
|
276
297
|
} catch (e) {
|
|
277
|
-
|
|
278
|
-
console.warn("Failed to execute platformBack", e);
|
|
298
|
+
log_warning("Failed to execute platformBack", e);
|
|
279
299
|
}
|
|
280
300
|
}
|
|
281
301
|
|
|
@@ -344,23 +364,103 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
344
364
|
}
|
|
345
365
|
}
|
|
346
366
|
|
|
347
|
-
|
|
367
|
+
/**
|
|
368
|
+
When pressing escape or the Native "Back" button:
|
|
369
|
+
if on the transport controls: we show the player
|
|
370
|
+
if on the player : we show the UI
|
|
371
|
+
if on the UI : we exit the app
|
|
372
|
+
note: backspace affects the keyboard input, so it behaves differently
|
|
373
|
+
*/
|
|
374
|
+
onBackPress(event) {
|
|
348
375
|
const { displayState, setDisplayState, navigator } = this.props;
|
|
376
|
+
const { isDialogVisible } = confirmationDialogStore.getState();
|
|
349
377
|
const { isKeyboardVisible } = this.state;
|
|
350
378
|
|
|
351
|
-
|
|
379
|
+
log_debug("onBackPress", {
|
|
380
|
+
eventCode: event.code,
|
|
381
|
+
displayState,
|
|
382
|
+
isDialogVisible,
|
|
383
|
+
isKeyboardVisible,
|
|
384
|
+
});
|
|
352
385
|
|
|
353
386
|
if (isKeyboardVisible && shouldUseOnScreenKeyboard()) {
|
|
354
|
-
|
|
355
|
-
this.handleKeyboardDismiss();
|
|
356
|
-
}
|
|
357
|
-
|
|
387
|
+
this.handleKeyboardDismiss();
|
|
358
388
|
event.preventDefault();
|
|
359
389
|
event.stopPropagation();
|
|
360
390
|
|
|
361
391
|
return;
|
|
362
392
|
}
|
|
363
393
|
|
|
394
|
+
switch (displayState) {
|
|
395
|
+
case DISPLAY_STATES.DEFAULT:
|
|
396
|
+
case DISPLAY_STATES.PLAYER:
|
|
397
|
+
if (isDialogVisible) {
|
|
398
|
+
this.onConfirmDialogClose();
|
|
399
|
+
} else if (navigator.canGoBack()) {
|
|
400
|
+
navigator.goBack();
|
|
401
|
+
} else if (this.isHomeScreen()) {
|
|
402
|
+
this.platformBack();
|
|
403
|
+
} else if (navigator.currentRoute.includes("hook")) {
|
|
404
|
+
// If code reaches this block navigator cant go back, it is not home,
|
|
405
|
+
// and this is a login plugin that was pushed on top of the home
|
|
406
|
+
// Treat it like a home screen and run platformBack()
|
|
407
|
+
const entryData = navigator?.data?.entry;
|
|
408
|
+
const isHookInHomescreen = entryData?.payload?.home;
|
|
409
|
+
|
|
410
|
+
const isHookFlowBlocker =
|
|
411
|
+
typeof entryData?.hookPlugin?.module?.isFlowBlocker === "function"
|
|
412
|
+
? entryData?.hookPlugin?.module?.isFlowBlocker()
|
|
413
|
+
: entryData?.hookPlugin?.module?.isFlowBlocker;
|
|
414
|
+
|
|
415
|
+
if (isHookInHomescreen && isHookFlowBlocker) {
|
|
416
|
+
this.platformBack();
|
|
417
|
+
} else {
|
|
418
|
+
navigator.goBack(false, true);
|
|
419
|
+
}
|
|
420
|
+
} else {
|
|
421
|
+
this.goToHome();
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
break;
|
|
425
|
+
case DISPLAY_STATES.HUD:
|
|
426
|
+
// IF transport controls are open, close them instead of closing player
|
|
427
|
+
setDisplayState(DISPLAY_STATES.PLAYER);
|
|
428
|
+
break;
|
|
429
|
+
default:
|
|
430
|
+
setDisplayState(DISPLAY_STATES.PLAYER);
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
onBackspacePress(event) {
|
|
436
|
+
const isInputFocused =
|
|
437
|
+
document.activeElement instanceof HTMLInputElement ||
|
|
438
|
+
document.activeElement instanceof HTMLTextAreaElement;
|
|
439
|
+
|
|
440
|
+
// Don't handle backspace if input is focused
|
|
441
|
+
if (isInputFocused) {
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
this.onBackPress(event);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
onKeyDown(event) {
|
|
449
|
+
const { displayState, setDisplayState, navigator } = this.props;
|
|
450
|
+
const { isDialogVisible } = confirmationDialogStore.getState();
|
|
451
|
+
|
|
452
|
+
if (keyCode(event).matches("Backspace")) {
|
|
453
|
+
this.onBackspacePress(event);
|
|
454
|
+
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (keyCode(event).matchesAny(KEYS.Back, KEYS.Escape, KEYS.EscapeDevice)) {
|
|
459
|
+
this.onBackPress(event);
|
|
460
|
+
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
|
|
364
464
|
if (this.keySupportsLongPress(event)) {
|
|
365
465
|
this.longPressDetector.monitorKeyPress(event.code, event);
|
|
366
466
|
}
|
|
@@ -419,61 +519,10 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
419
519
|
}
|
|
420
520
|
}
|
|
421
521
|
|
|
422
|
-
/**
|
|
423
|
-
When pressing backspace or the Native "Back" button:
|
|
424
|
-
if on the transport controls: we show the player
|
|
425
|
-
if on the player : we show the UI
|
|
426
|
-
if on the UI : we exit the app
|
|
427
|
-
*/
|
|
428
|
-
|
|
429
522
|
if (
|
|
430
|
-
keyCode(event).
|
|
431
|
-
|
|
432
|
-
KEYS.Escape,
|
|
433
|
-
KEYS.EscapeDevice,
|
|
434
|
-
KEYS.Backspace
|
|
435
|
-
)
|
|
523
|
+
keyCode(event).matches(KEYS.Enter) ||
|
|
524
|
+
(__DEV__ && keyCode(event).matches(KEYS.X))
|
|
436
525
|
) {
|
|
437
|
-
switch (displayState) {
|
|
438
|
-
case DISPLAY_STATES.DEFAULT:
|
|
439
|
-
case DISPLAY_STATES.PLAYER:
|
|
440
|
-
if (isDialogVisible) {
|
|
441
|
-
this.onConfirmDialogClose();
|
|
442
|
-
} else if (navigator.canGoBack()) {
|
|
443
|
-
navigator.goBack();
|
|
444
|
-
} else if (this.isHomeScreen()) {
|
|
445
|
-
this.platformBack();
|
|
446
|
-
} else if (navigator.currentRoute.includes("hook")) {
|
|
447
|
-
// If code reaches this block navigator cant go back, it is not home,
|
|
448
|
-
// and this is a login plugin that was pushed on top of the home
|
|
449
|
-
// Treat it like a home screen and run platformBack()
|
|
450
|
-
const entryData = navigator?.data?.entry;
|
|
451
|
-
const isHookInHomescreen = entryData?.payload?.home;
|
|
452
|
-
|
|
453
|
-
const isHookFlowBlocker =
|
|
454
|
-
entryData?.hookPlugin?.module?.isFlowBlocker();
|
|
455
|
-
|
|
456
|
-
if (isHookInHomescreen && isHookFlowBlocker) {
|
|
457
|
-
this.platformBack();
|
|
458
|
-
} else {
|
|
459
|
-
navigator.goBack(false, true);
|
|
460
|
-
}
|
|
461
|
-
} else {
|
|
462
|
-
this.goToHome();
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
break;
|
|
466
|
-
case DISPLAY_STATES.HUD:
|
|
467
|
-
// IF transport controls are open, close them instead of closing player
|
|
468
|
-
setDisplayState(DISPLAY_STATES.PLAYER);
|
|
469
|
-
break;
|
|
470
|
-
default:
|
|
471
|
-
setDisplayState(DISPLAY_STATES.PLAYER);
|
|
472
|
-
break;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
if (keyCode(event).matches(KEYS.Enter)) {
|
|
477
526
|
if (displayState === DISPLAY_STATES.PLAYER) {
|
|
478
527
|
setDisplayState(DISPLAY_STATES.HUD);
|
|
479
528
|
} else {
|
|
@@ -493,10 +542,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
493
542
|
this.platformBack();
|
|
494
543
|
}
|
|
495
544
|
|
|
496
|
-
if (
|
|
497
|
-
keyCode(event).matchesAny(...ARROW_KEYS) &&
|
|
498
|
-
!this.state.isKeyboardVisible
|
|
499
|
-
) {
|
|
545
|
+
if (keyCode(event).matchesAny(...ARROW_KEYS)) {
|
|
500
546
|
if (displayState === DISPLAY_STATES.PLAYER) {
|
|
501
547
|
setDisplayState(DISPLAY_STATES.HUD);
|
|
502
548
|
}
|
|
@@ -619,7 +665,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
619
665
|
}
|
|
620
666
|
}
|
|
621
667
|
|
|
622
|
-
handleKeyboardDismiss
|
|
668
|
+
handleKeyboardDismiss() {
|
|
623
669
|
this.isDismissing = true;
|
|
624
670
|
|
|
625
671
|
this.setState(
|
|
@@ -630,9 +676,10 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
630
676
|
},
|
|
631
677
|
() => {
|
|
632
678
|
this.isDismissing = false;
|
|
679
|
+
focusManager.recoverFocus();
|
|
633
680
|
}
|
|
634
681
|
);
|
|
635
|
-
}
|
|
682
|
+
}
|
|
636
683
|
|
|
637
684
|
handleKeyboardInput = (value: string) => {
|
|
638
685
|
const { activeInputRef } = this.state;
|
|
@@ -739,6 +786,35 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
739
786
|
);
|
|
740
787
|
}
|
|
741
788
|
|
|
789
|
+
handlePhysicalKeyboardDismiss(event: CustomEvent) {
|
|
790
|
+
const { value, position, inputElement } = event.detail;
|
|
791
|
+
|
|
792
|
+
this.isDismissing = true;
|
|
793
|
+
|
|
794
|
+
this.setState(
|
|
795
|
+
{
|
|
796
|
+
isKeyboardVisible: false,
|
|
797
|
+
keyboardInput: "",
|
|
798
|
+
activeInputRef: null,
|
|
799
|
+
},
|
|
800
|
+
() => {
|
|
801
|
+
if (inputElement) {
|
|
802
|
+
inputElement.value = value;
|
|
803
|
+
inputElement.focus();
|
|
804
|
+
inputElement.setSelectionRange(position, position);
|
|
805
|
+
|
|
806
|
+
const keyboardEvent = new CustomEvent("keyboardUpdate", {
|
|
807
|
+
detail: { value },
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
document.dispatchEvent(keyboardEvent);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
this.isDismissing = false;
|
|
814
|
+
}
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
|
|
742
818
|
render() {
|
|
743
819
|
return (
|
|
744
820
|
(shouldUseOnScreenKeyboard() && this.state.isKeyboardVisible && (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-dom-app",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.6",
|
|
4
4
|
"description": "Zapp App Component for Applicaster's Quick Brick React Native App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/applicaster/zapp-react-dom-app#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@applicaster/zapp-react-dom-ui-components": "12.0.
|
|
26
|
-
"@applicaster/zapp-react-native-bridge": "12.0.
|
|
27
|
-
"@applicaster/zapp-react-native-redux": "12.0.
|
|
28
|
-
"@applicaster/zapp-react-native-ui-components": "12.0.
|
|
29
|
-
"@applicaster/zapp-react-native-utils": "12.0.
|
|
25
|
+
"@applicaster/zapp-react-dom-ui-components": "12.0.6",
|
|
26
|
+
"@applicaster/zapp-react-native-bridge": "12.0.6",
|
|
27
|
+
"@applicaster/zapp-react-native-redux": "12.0.6",
|
|
28
|
+
"@applicaster/zapp-react-native-ui-components": "12.0.6",
|
|
29
|
+
"@applicaster/zapp-react-native-utils": "12.0.6",
|
|
30
30
|
"abortcontroller-polyfill": "^1.7.5",
|
|
31
31
|
"history": "^4.7.2",
|
|
32
32
|
"react-router-dom": "^5.1.2",
|