@applicaster/quick-brick-core 13.0.0-alpha.2510266138 → 13.0.0-alpha.2535725541

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.
@@ -300,7 +300,6 @@ export class DraggableBottomSheet extends Component<Props, ComponentState> {
300
300
  simultaneousHandlers={this.drawer}
301
301
  >
302
302
  <Animated.ScrollView
303
- style={{ marginBottom: this._snapPoints.top }}
304
303
  bounces={false}
305
304
  onScrollBeginDrag={this._onRegisterLastScroll}
306
305
  scrollEventThrottle={1}
@@ -1,21 +1,20 @@
1
1
  import React from "react";
2
- import { StyleSheet, View } from "react-native";
2
+ import { LayoutChangeEvent, StyleSheet } from "react-native";
3
3
 
4
4
  import { Handle, HandleProps } from "./Handle";
5
5
  import { DraggableBottomSheet } from "./DraggableBottomSheet";
6
+ import { SafeAreaView } from "react-native-safe-area-context";
6
7
 
7
8
  type Props = {
8
9
  children: React.ReactChild;
9
10
  backgroundColor: string;
10
11
  cornerRadius: number;
11
- contentHeight: number;
12
12
  maxHeight: number;
13
13
  maxWidth: number;
14
14
  visible: boolean;
15
15
  handleProps: HandleProps;
16
16
  closeToast: () => void;
17
17
  dimensions: { width: number; height: number };
18
- paddingBottom: number;
19
18
  };
20
19
 
21
20
  const styles = StyleSheet.create({
@@ -34,9 +33,7 @@ export function ModalBottomSheetFrame(props: Props) {
34
33
  maxWidth,
35
34
  visible,
36
35
  handleProps,
37
- contentHeight,
38
36
  dimensions,
39
- paddingBottom,
40
37
  } = props;
41
38
 
42
39
  const extraStyles = {
@@ -44,13 +41,22 @@ export function ModalBottomSheetFrame(props: Props) {
44
41
  borderTopLeftRadius: cornerRadius,
45
42
  borderTopRightRadius: cornerRadius,
46
43
  maxHeight,
47
- paddingBottom,
48
44
  maxWidth: Math.min(Number(maxWidth), dimensions.width),
49
45
  };
50
46
 
47
+ const [height, setHeight] = React.useState(0);
48
+
49
+ const onLayout = (event: LayoutChangeEvent) => {
50
+ const { height } = event.nativeEvent.layout;
51
+
52
+ if (height !== 0) {
53
+ setHeight((oldHeight) => oldHeight || height);
54
+ }
55
+ };
56
+
51
57
  return (
52
58
  <DraggableBottomSheet
53
- sheetHeight={contentHeight}
59
+ sheetHeight={height}
54
60
  visible={visible}
55
61
  dismiss={props.closeToast}
56
62
  hasHeader={handleProps.enabled}
@@ -58,7 +64,13 @@ export function ModalBottomSheetFrame(props: Props) {
58
64
  maxWidth={maxWidth}
59
65
  {...dimensions}
60
66
  >
61
- <View style={[styles.toastFrameContainer, extraStyles]}>{children}</View>
67
+ <SafeAreaView
68
+ edges={["left", "right", "bottom"]}
69
+ style={[styles.toastFrameContainer, extraStyles]}
70
+ onLayout={onLayout}
71
+ >
72
+ {children}
73
+ </SafeAreaView>
62
74
  </DraggableBottomSheet>
63
75
  );
64
76
  }
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { StyleSheet, TouchableOpacity, Easing, View } from "react-native";
3
3
 
4
4
  import { AnimatedInOut } from "@applicaster/zapp-react-native-ui-components/Components/AnimatedInOut";
5
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
5
+ import { dismissModal } from "@applicaster/zapp-react-native-utils/modalState";
6
6
 
7
7
  type Props = {
8
8
  overlayColor: string;
@@ -35,21 +35,19 @@ const fadeInAnimation = {
35
35
  delay,
36
36
  };
37
37
 
38
- const animationConfig = (onAnimationEnd) => ({
38
+ const animationConfig = {
39
39
  in: fadeInAnimation,
40
40
  out: {
41
41
  ...fadeInAnimation,
42
- onAnimationEnd,
42
+ onAnimationEnd: dismissModal,
43
43
  },
44
- });
44
+ };
45
45
 
46
46
  export function Overlay(props: Props) {
47
- const navigator = useNavigation();
48
-
49
47
  return (
50
48
  <AnimatedInOut
51
49
  visible={props.visible}
52
- animationConfig={animationConfig(navigator.closeModalBottomSheet)}
50
+ animationConfig={animationConfig}
53
51
  staticStyles={styles.container}
54
52
  >
55
53
  <TouchableOpacity
@@ -3,7 +3,7 @@ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
3
3
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
4
4
  import { useSafeAreaInsets } from "react-native-safe-area-context";
5
5
 
6
- import React, { useCallback, useEffect, useMemo, useState } from "react";
6
+ import React, { useEffect, useState } from "react";
7
7
  import { Keyboard, StyleSheet, View } from "react-native";
8
8
 
9
9
  import { Overlay } from "./Overlay";
@@ -38,12 +38,11 @@ export function ModalBottomSheet(props: Props) {
38
38
  const theme = useTheme<BaseThemePropertiesMobile>();
39
39
  const navigator = useNavigation();
40
40
  const dimensions = useDimensions();
41
- const [sheetHeight, setSheetHeight] = useState(0);
42
41
  const [visible, setVisible] = useState(true);
43
42
  const dismiss = () => setVisible(false);
44
43
  const { bottom = defaultBottomOffset } = useSafeAreaInsets();
45
44
 
46
- const bottomOffset = bottom + dimensions.statusBarHeight;
45
+ const bottomOffset = bottom;
47
46
 
48
47
  const {
49
48
  modal_bottom_sheet_background_color: sheetBackgroundColor,
@@ -61,29 +60,13 @@ export function ModalBottomSheet(props: Props) {
61
60
  modalBottomSheetContentProps,
62
61
  } = props;
63
62
 
64
- const onLayout = useCallback(({ nativeEvent }) => {
65
- const calculatedHeight = nativeEvent?.layout?.height;
66
-
67
- if (calculatedHeight > 0 && sheetHeight === 0) {
68
- setSheetHeight(Math.min(calculatedHeight, sheetMaxHeight));
69
- }
70
- }, []);
71
-
72
63
  useEffect(() => {
73
64
  Keyboard.dismiss();
74
65
  }, []);
75
66
 
76
67
  const isTablet = useIsTablet();
77
68
 
78
- const maxWidth = useMemo(
79
- () =>
80
- isTablet
81
- ? Math.max(sheetTabletMaxWidth, dimensions.width)
82
- : dimensions.width,
83
- [isTablet]
84
- );
85
-
86
- const modalVisible = visible && sheetHeight > 0;
69
+ const maxWidth = isTablet ? sheetTabletMaxWidth : dimensions.width;
87
70
 
88
71
  return (
89
72
  <View style={styles.container}>
@@ -95,12 +78,10 @@ export function ModalBottomSheet(props: Props) {
95
78
  <ModalBottomSheetFrame
96
79
  backgroundColor={sheetBackgroundColor}
97
80
  cornerRadius={sheetCornerRadius}
98
- contentHeight={sheetHeight + bottomOffset}
99
81
  maxHeight={sheetMaxHeight + bottomOffset}
100
- paddingBottom={bottomOffset}
101
82
  maxWidth={maxWidth}
102
83
  dimensions={dimensions}
103
- visible={modalVisible}
84
+ visible={visible}
104
85
  closeToast={dismiss}
105
86
  handleProps={{
106
87
  enabled: sheetHandleEnabled,
@@ -108,18 +89,15 @@ export function ModalBottomSheet(props: Props) {
108
89
  focusedColor: sheetHandleFocusedColor,
109
90
  }}
110
91
  >
111
- <View onLayout={onLayout}>
112
- <ModalBottomSheetContent
113
- width={
114
- Math.min(sheetTabletMaxWidth, dimensions.width) ||
115
- dimensions.width
116
- }
117
- maxHeight={sheetMaxHeight}
118
- {...modalBottomSheetContentProps}
119
- dismiss={dismiss}
120
- currentRoute={navigator.currentRoute}
121
- />
122
- </View>
92
+ <ModalBottomSheetContent
93
+ width={
94
+ Math.min(sheetTabletMaxWidth, dimensions.width) || dimensions.width
95
+ }
96
+ maxHeight={sheetMaxHeight}
97
+ {...modalBottomSheetContentProps}
98
+ dismiss={dismiss}
99
+ currentRoute={navigator.currentRoute}
100
+ />
123
101
  </ModalBottomSheetFrame>
124
102
  </View>
125
103
  );
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { Modal, ModalProps } from "react-native";
3
3
 
4
- type Props = {
4
+ type Props = ModalProps & {
5
5
  children: React.ReactChild;
6
6
  ModalContainer?: React.FC<ModalProps> | React.ComponentClass<ModalProps>;
7
7
  visible: boolean;
@@ -6,10 +6,10 @@ import { ModalChildrenWrapper } from "./ModalChildrenWrapper";
6
6
  import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
7
7
  import { ScreenContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
8
8
  import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
9
- import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
9
+ import { useModalStoreState } from "@applicaster/zapp-react-native-utils/modalState";
10
10
 
11
11
  export function ModalProvider() {
12
- const { modalState } = useModalStore();
12
+ const modalState = useModalStoreState();
13
13
 
14
14
  const [modalVisible, setModalVisible] = React.useState(false);
15
15
  const [modalShown, setModalShown] = React.useState(false);
@@ -40,7 +40,11 @@ export function ModalProvider() {
40
40
  return (
41
41
  <PathnameContext.Provider value={pathname}>
42
42
  <ScreenContextProvider pathname={pathname}>
43
- <ModalPresenter visible={shouldShowModal} {...modalState?.options}>
43
+ <ModalPresenter
44
+ visible={shouldShowModal}
45
+ {...modalState?.options}
46
+ statusBarTranslucent
47
+ >
44
48
  <ModalChildrenWrapper>
45
49
  <ModalContent modalScreenProps={modalScreenProps} />
46
50
  </ModalChildrenWrapper>
@@ -58,13 +58,20 @@ import {
58
58
  legacyScreenData,
59
59
  openExternalUrl,
60
60
  } from "./utils";
61
- import { debounce } from "@applicaster/zapp-react-native-utils/functionUtils";
61
+ import {
62
+ debounce,
63
+ getJsonReplacer,
64
+ } from "@applicaster/zapp-react-native-utils/functionUtils";
62
65
 
63
66
  import { findParent } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappPipesContext/ZappPipesEntryContext";
64
67
  import { ZappPipesEntryContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
65
68
  import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
66
69
  import { inflateUrl } from "@applicaster/zapp-react-native-ui-components/Components/LinkHandler/LinkHandler";
67
- import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
70
+ import {
71
+ dismissModal,
72
+ modalStore,
73
+ openModal,
74
+ } from "@applicaster/zapp-react-native-utils/modalState";
68
75
  import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
69
76
  import { QBUIComponentEvents } from "@applicaster/zapp-react-native-ui-components/events";
70
77
  import { Hook } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager/Hook";
@@ -120,8 +127,6 @@ export function NavigationProvider({ children }: Props) {
120
127
 
121
128
  const { context } = React.useContext(ZappPipesEntryContext.Context);
122
129
 
123
- const { openModal, dismissModal } = useModalStore();
124
-
125
130
  const playNextOverlayState = React.useRef();
126
131
 
127
132
  const online = useConnectionInfo(true);
@@ -147,7 +152,7 @@ export function NavigationProvider({ children }: Props) {
147
152
  );
148
153
 
149
154
  const getModalState: () => ModalState = () => {
150
- const { modalState } = useModalStore.getState();
155
+ const { modalState } = modalStore.getState();
151
156
 
152
157
  return modalState;
153
158
  };
@@ -391,7 +396,7 @@ export function NavigationProvider({ children }: Props) {
391
396
  }
392
397
 
393
398
  if (hookPlugin.isModalHook()) {
394
- navigator.openModal({
399
+ openModal({
395
400
  item: payload,
396
401
  props: { screenType: "hooks" },
397
402
  options: { ModalContainer: hookPlugin.getModalContainer() },
@@ -411,7 +416,7 @@ export function NavigationProvider({ children }: Props) {
411
416
  }
412
417
 
413
418
  if (hookPlugin.isModalHook()) {
414
- navigator.dismissModal();
419
+ dismissModal();
415
420
  } else {
416
421
  goBack(true, true);
417
422
  }
@@ -433,7 +438,7 @@ export function NavigationProvider({ children }: Props) {
433
438
 
434
439
  if (!abort) {
435
440
  if (hookPlugin.isModalHook()) {
436
- navigator.dismissModal();
441
+ dismissModal();
437
442
  } else {
438
443
  goBack(true, true);
439
444
  }
@@ -446,7 +451,7 @@ export function NavigationProvider({ children }: Props) {
446
451
  callback?.();
447
452
 
448
453
  if (hookPlugin.isModalHook()) {
449
- navigator.dismissModal();
454
+ dismissModal();
450
455
  }
451
456
  };
452
457
 
@@ -683,33 +688,6 @@ export function NavigationProvider({ children }: Props) {
683
688
  }
684
689
  }, [state?.options?.videoModal?.previousMode]);
685
690
 
686
- const openModalBottomSheet = React.useCallback(
687
- ({
688
- ModalBottomSheetContent,
689
- modalBottomSheetContentProps,
690
- props = {},
691
- options = {},
692
- }) => {
693
- openModal({
694
- item: {
695
- ModalBottomSheetContent,
696
- modalBottomSheetContentProps,
697
- },
698
- props,
699
- options: {
700
- animationType: "none",
701
- animated: false,
702
- ...options,
703
- },
704
- });
705
- },
706
- [openModal]
707
- );
708
-
709
- const closeModalBottomSheet = React.useCallback(() => {
710
- dismissModal();
711
- }, [dismissModal]);
712
-
713
691
  const getNestedEntry = () => state?.location?.state?.nested?.entry ?? null;
714
692
 
715
693
  // It will only work for the regular stack and pathname, It won't work for modals
@@ -750,8 +728,6 @@ export function NavigationProvider({ children }: Props) {
750
728
  openModal,
751
729
  dismissModal,
752
730
  getModalState,
753
- openModalBottomSheet,
754
- closeModalBottomSheet,
755
731
  videoModalState: state.options.videoModal,
756
732
  openVideoModal,
757
733
  closeVideoModal,
@@ -768,7 +744,15 @@ export function NavigationProvider({ children }: Props) {
768
744
  getStackForPathname,
769
745
  mainStack: state.stack.mainStack,
770
746
  }),
771
- [rivers, plugins, JSON.stringify(state), appLaunched, startUpHooks]
747
+ [
748
+ rivers,
749
+ plugins,
750
+ // TODO: Compare entire screen data from state must be removed
751
+ // State size could be large ~150kb and take 80ms on android tv on 8 rails
752
+ JSON.stringify(state, getJsonReplacer()),
753
+ appLaunched,
754
+ startUpHooks,
755
+ ]
772
756
  );
773
757
 
774
758
  // when running the tests, we pass the dispatch function
@@ -461,48 +461,4 @@ describe("<NavigationProvider />", () => {
461
461
  });
462
462
  });
463
463
  });
464
-
465
- describe("modal feature", () => {
466
- it("sets the modalState when opening a modal", () => {
467
- act(() => {
468
- wrapper = renderContextConsumer();
469
- });
470
-
471
- const view = getByTestId(wrapper, "WrapperView");
472
- act(() => view.props.navigator.openModal({ item: rivers.A1234 }));
473
- expect(view.props.navigator.get).toMatchSnapshot();
474
- });
475
-
476
- it("removes the visible flag when dismissing a modal", () => {
477
- act(() => {
478
- wrapper = renderContextConsumer();
479
- });
480
-
481
- const view = getByTestId(wrapper, "WrapperView");
482
- act(() => view.props.navigator.openModal({ item: rivers.A1234 }));
483
- expect(view.props.navigator.getModalState()).toMatchSnapshot();
484
- act(() => view.props.navigator.dismissModal());
485
- expect(view.props.navigator.getModalState().visible).toBeFalsy();
486
- expect(view.props.navigator.getModalState()).toMatchSnapshot();
487
- });
488
-
489
- it("should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet", () => {
490
- act(() => {
491
- wrapper = renderContextConsumer();
492
- });
493
-
494
- const view = getByTestId(wrapper, "WrapperView");
495
-
496
- act(() =>
497
- view.props.navigator.openModalBottomSheet({
498
- ModalBottomSheetContent: rivers.A1234,
499
- modalBottomSheetContentProps: { some: "props" },
500
- })
501
- );
502
-
503
- expect(view.props.navigator.getModalState()).toMatchSnapshot();
504
- act(() => view.props.navigator.closeModalBottomSheet());
505
- expect(view.props.navigator.getModalState()).toMatchSnapshot();
506
- });
507
- });
508
464
  });
package/App/index.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
+
3
4
  import {
4
5
  initialWindowMetrics,
5
6
  SafeAreaProvider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "13.0.0-alpha.2510266138",
3
+ "version": "13.0.0-alpha.2535725541",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,13 +28,13 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "13.0.0-alpha.2510266138",
32
- "@applicaster/quick-brick-core-plugins": "13.0.0-alpha.2510266138",
33
- "@applicaster/zapp-pipes-v2-client": "13.0.0-alpha.2510266138",
34
- "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.2510266138",
35
- "@applicaster/zapp-react-native-redux": "13.0.0-alpha.2510266138",
36
- "@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.2510266138",
37
- "@applicaster/zapp-react-native-utils": "13.0.0-alpha.2510266138",
31
+ "@applicaster/applicaster-types": "13.0.0-alpha.2535725541",
32
+ "@applicaster/quick-brick-core-plugins": "13.0.0-alpha.2535725541",
33
+ "@applicaster/zapp-pipes-v2-client": "13.0.0-alpha.2535725541",
34
+ "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.2535725541",
35
+ "@applicaster/zapp-react-native-redux": "13.0.0-alpha.2535725541",
36
+ "@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.2535725541",
37
+ "@applicaster/zapp-react-native-utils": "13.0.0-alpha.2535725541",
38
38
  "atob": "^2.1.2",
39
39
  "axios": "^0.28.0",
40
40
  "btoa": "^1.2.1",
@@ -1 +0,0 @@
1
- export { Fragment as ModalChildrenWrapper } from "react";
@@ -1,68 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`<NavigationProvider /> modal feature removes the visible flag when dismissing a modal 1`] = `
4
- {
5
- "options": {
6
- "animated": true,
7
- "animationType": "slide",
8
- "onDismiss": [Function],
9
- "onRequestClose": [Function],
10
- "onShow": [Function],
11
- "presentationStyle": "overFullScreen",
12
- "transparent": true,
13
- },
14
- "props": undefined,
15
- "screen": {
16
- "id": "A1234",
17
- "navigations": [],
18
- "ui_components": [],
19
- },
20
- "visible": true,
21
- }
22
- `;
23
-
24
- exports[`<NavigationProvider /> modal feature removes the visible flag when dismissing a modal 2`] = `
25
- {
26
- "options": {},
27
- "props": {},
28
- "screen": null,
29
- "visible": false,
30
- }
31
- `;
32
-
33
- exports[`<NavigationProvider /> modal feature sets the modalState when opening a modal 1`] = `undefined`;
34
-
35
- exports[`<NavigationProvider /> modal feature should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet 1`] = `
36
- {
37
- "options": {
38
- "animated": false,
39
- "animationType": "none",
40
- "onDismiss": [Function],
41
- "onRequestClose": [Function],
42
- "onShow": [Function],
43
- "presentationStyle": "overFullScreen",
44
- "transparent": true,
45
- },
46
- "props": {},
47
- "screen": {
48
- "ModalBottomSheetContent": {
49
- "id": "A1234",
50
- "navigations": [],
51
- "ui_components": [],
52
- },
53
- "modalBottomSheetContentProps": {
54
- "some": "props",
55
- },
56
- },
57
- "visible": true,
58
- }
59
- `;
60
-
61
- exports[`<NavigationProvider /> modal feature should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet 2`] = `
62
- {
63
- "options": {},
64
- "props": {},
65
- "screen": null,
66
- "visible": false,
67
- }
68
- `;