@applicaster/zapp-react-native-ui-components 15.0.0-alpha.3441591506 → 15.0.0-alpha.3512356987

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.
@@ -208,14 +208,14 @@ export class CellComponent extends React.Component<Props, State> {
208
208
  this.accessibilityManager.readText({
209
209
  text: " ",
210
210
  });
211
- } else {
211
+ } else if (this.state.cellFocused) {
212
212
  this.accessibilityManager.readText({
213
213
  text: `${positionLabel}`,
214
214
  });
215
215
  }
216
216
  }
217
217
 
218
- componentDidUpdate(prevProps: Readonly<Props>) {
218
+ componentDidUpdate(prevProps: Readonly<Props>, prevState: Readonly<State>) {
219
219
  if (prevProps.item !== this.props.item) {
220
220
  this.setState({
221
221
  hasFocusableInside: this.props.CellRenderer.hasFocusableInside?.(
@@ -224,7 +224,12 @@ export class CellComponent extends React.Component<Props, State> {
224
224
  });
225
225
  }
226
226
 
227
- this.handleAccessibilityFocus(this.props.index, this.props.dataLength);
227
+ if (
228
+ prevState.cellFocused !== this.state.cellFocused ||
229
+ this.state.hasFocusableInside
230
+ ) {
231
+ this.handleAccessibilityFocus(this.props.index, this.props.dataLength);
232
+ }
228
233
  }
229
234
 
230
235
  render() {
@@ -17,6 +17,7 @@ import { CellWithFocusable } from "./CellWithFocusable";
17
17
  import { FocusableWrapper } from "./FocusableWrapper";
18
18
 
19
19
  import { focusableButtonsRegistration$ } from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux/utils/utils.ios";
20
+ import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
20
21
 
21
22
  type Props = {
22
23
  item: ZappEntry;
@@ -37,6 +38,9 @@ type Props = {
37
38
  component: {
38
39
  id: number | string;
39
40
  component_type: string;
41
+ styles?: {
42
+ component_margin_top?: number;
43
+ };
40
44
  };
41
45
  selected: boolean;
42
46
  CellRenderer: React.FunctionComponent<any> & {
@@ -204,11 +208,16 @@ class TvOSCell extends React.Component<Props, State> {
204
208
  const extraAnchorPointYOffset =
205
209
  screenLayout?.extraAnchorPointYOffset || 0;
206
210
 
211
+ const componentMarginTop = toNumberWithDefaultZero(
212
+ component?.styles?.component_margin_top
213
+ );
214
+
207
215
  const totalOffset =
208
216
  headerOffset +
209
- (componentAnchorPointY || 0) +
210
- extraAnchorPointYOffset -
211
- componentsMapOffset || 0;
217
+ (componentAnchorPointY || 0) +
218
+ extraAnchorPointYOffset -
219
+ (componentsMapOffset || 0) +
220
+ componentMarginTop;
212
221
 
213
222
  mainOffsetUpdater?.(
214
223
  { tag: this.target },
@@ -1,8 +1,8 @@
1
+ import * as React from "react";
1
2
  import {
2
3
  BorderContainerView,
3
4
  getBorderPadding, // Export for testing (using a double underscore prefix is a common convention)
4
5
  } from "../index";
5
- import * as React from "react";
6
6
  import { render } from "@testing-library/react-native";
7
7
  import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
8
8
  import { View } from "react-native";
@@ -11,6 +11,15 @@ jest.mock("@applicaster/zapp-react-native-utils/numberUtils", () => ({
11
11
  toNumberWithDefaultZero: jest.fn((value) => Number(value) || 0),
12
12
  }));
13
13
 
14
+ jest.mock(
15
+ "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks",
16
+ () => ({
17
+ useAccessibilityManager: jest.fn(() => ({
18
+ addHeading: jest.fn(),
19
+ })),
20
+ })
21
+ );
22
+
14
23
  describe("BorderContainerView", () => {
15
24
  describe("getBorderPadding", () => {
16
25
  it("returns 0 for inside", () => {
@@ -42,6 +51,8 @@ describe("BorderContainerView", () => {
42
51
  };
43
52
 
44
53
  const borderPosition = null;
54
+ const mockEntry = { id: "test-entry" } as ZappEntry;
55
+ const mockHasFocusableInside = jest.fn(() => false);
45
56
 
46
57
  const { queryByTestId } = render(
47
58
  <BorderContainerView
@@ -52,6 +63,10 @@ describe("BorderContainerView", () => {
52
63
  borderPaddingRight={toNumberWithDefaultZero(padding.paddingRight)}
53
64
  borderPaddingBottom={toNumberWithDefaultZero(padding.paddingBottom)}
54
65
  borderPaddingLeft={toNumberWithDefaultZero(padding.paddingLeft)}
66
+ hasFocusableInside={mockHasFocusableInside}
67
+ entry={mockEntry}
68
+ state="focused"
69
+ hasTextLabels={false}
55
70
  >
56
71
  <View testID="child" />
57
72
  </BorderContainerView>
@@ -1,10 +1,16 @@
1
- import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
2
- import * as React from "react";
1
+ import React, { useMemo, useContext, useEffect } from "react";
3
2
  import { ImageStyle, StyleSheet, View, ViewStyle } from "react-native";
3
+ import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
4
+ import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
5
+ import { MeasurementPortalContext } from "../../../MeasurmentsPortal/MeasurementsPortal";
4
6
 
5
7
  type BorderPosition = "inside" | "outside" | "center";
6
8
 
7
9
  interface Props {
10
+ hasFocusableInside: (entry: ZappEntry) => boolean;
11
+ entry: ZappEntry;
12
+ state: CellState;
13
+ hasTextLabels: boolean;
8
14
  style: ImageStyle | ViewStyle;
9
15
  borderPosition: BorderPosition;
10
16
  borderPaddingTop: number;
@@ -118,8 +124,30 @@ export const BorderContainerView = (props: Props) => {
118
124
  borderPaddingLeft,
119
125
  style,
120
126
  children,
127
+ hasFocusableInside,
128
+ entry,
129
+ state,
130
+ hasTextLabels,
121
131
  } = props;
122
132
 
133
+ const accessibilityManager = useAccessibilityManager();
134
+ const isMeasurement = useContext(MeasurementPortalContext);
135
+
136
+ const isImageOnlyCell = useMemo(
137
+ () =>
138
+ !hasFocusableInside(entry) &&
139
+ !hasTextLabels &&
140
+ state === "focused" &&
141
+ !isMeasurement,
142
+ [hasFocusableInside, entry, hasTextLabels, state, isMeasurement]
143
+ );
144
+
145
+ useEffect(() => {
146
+ if (isImageOnlyCell && entry?.title) {
147
+ accessibilityManager.addHeading(String(entry.title));
148
+ }
149
+ }, [isImageOnlyCell, entry?.title]);
150
+
123
151
  const padding =
124
152
  borderPosition === "outside"
125
153
  ? {
@@ -52,14 +52,14 @@ const _Text = ({
52
52
  : textTransform(transformText, _label);
53
53
 
54
54
  React.useLayoutEffect(() => {
55
- // For FocusableCells with action buttons
56
- if (otherProps.state) {
57
- if (otherProps.state === "focused" && cellFocused === true) {
58
- accessibilityManager.addHeading(textLabel);
59
- }
60
- } else {
61
- if (cellFocused === true) {
62
- accessibilityManager.addHeading(textLabel);
55
+ if (cellFocused) {
56
+ switch (otherProps.state) {
57
+ case "focused":
58
+ accessibilityManager.addHeading(textLabel);
59
+ break;
60
+ case "focused_selected":
61
+ accessibilityManager.addHeading(`${textLabel}, Selected`);
62
+ break;
63
63
  }
64
64
  }
65
65
  }, [cellFocused, otherProps.state, textLabel]);
@@ -103,6 +103,8 @@ export function masterCellBuilder({
103
103
  wrapperRef,
104
104
  cellUUID,
105
105
  skipButtons,
106
+ hasFocusableInside,
107
+ entry: item,
106
108
  })
107
109
  );
108
110
 
@@ -8,6 +8,7 @@ import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
8
8
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
9
9
  import { FocusableGroup } from "@applicaster/zapp-react-native-ui-components/Components/FocusableGroup";
10
10
  import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable";
11
+ import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
11
12
  import { Gutter } from "../Gutter";
12
13
  import Tab from "./Tab";
13
14
  import { getStyles } from "./styles";
@@ -28,11 +29,14 @@ const TabsComponent = ({
28
29
  style,
29
30
  selectedEntryIndex,
30
31
  setSelectedEntry,
32
+ accessibility,
31
33
  }: TabsProps & Partial<TabsSelectionContextType>) => {
32
34
  const configuration = useConfiguration();
33
35
  const config = applyFontConfig(configuration);
34
36
  const styles = useMemo(() => getStyles(config), [config]);
35
37
 
38
+ const accessibilityManager = useAccessibilityManager({});
39
+
36
40
  const {
37
41
  tab_bar_gutter: horizontalGutter,
38
42
  tab_bar_background_image: bgImage,
@@ -60,10 +64,20 @@ const TabsComponent = ({
60
64
  );
61
65
 
62
66
  const onListElementFocus = useCallback(
63
- (index) => {
67
+ (index, isSelected: boolean, item: ZappEntry) => {
68
+ if (isSelected) {
69
+ accessibilityManager.readText({
70
+ text: `${accessibility?.selectedHint} ${item.title}`,
71
+ });
72
+ } else {
73
+ accessibilityManager.readText({
74
+ text: `${accessibility?.hint} ${item.title}`,
75
+ });
76
+ }
77
+
64
78
  scrollToSelectedIndex(index, VIEW_POSITION);
65
79
  },
66
- [scrollToSelectedIndex]
80
+ [scrollToSelectedIndex, accessibility]
67
81
  );
68
82
 
69
83
  const renderItem = useCallback(
@@ -94,7 +108,7 @@ const TabsComponent = ({
94
108
  id={itemId}
95
109
  testID={itemId}
96
110
  preferredFocus={isSelected}
97
- onFocus={() => onListElementFocus(index)}
111
+ onFocus={() => onListElementFocus(index, isSelected, item)}
98
112
  onPress={() => setSelectedEntry && setSelectedEntry(item)}
99
113
  style={style}
100
114
  >
@@ -149,6 +163,9 @@ const TabsComponent = ({
149
163
  shouldUsePreferredFocus
150
164
  isWithMemory={false}
151
165
  nextFocusDown={parentFocus?.nextFocusDown}
166
+ onFocus={() => {
167
+ accessibilityManager.addHeading(accessibility?.announcement);
168
+ }}
152
169
  >
153
170
  <View style={tabs}>
154
171
  <ImageBackground
@@ -1,62 +1,155 @@
1
- import React, { useEffect, useMemo } from "react";
1
+ import React, { useMemo } from "react";
2
2
  import { Animated, Dimensions } from "react-native";
3
3
 
4
4
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
5
5
 
6
6
  import { useConfiguration } from "../utils";
7
- import { useIsTabletLandscape } from "@applicaster/zapp-react-native-utils/reactHooks/device/useMemoizedIsTablet";
7
+ import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
8
+ import { isMenuVisible } from "../../Screen/navigationHandler";
9
+
10
+ import {
11
+ useSafeAreaFrame,
12
+ useSafeAreaInsets,
13
+ } from "react-native-safe-area-context";
14
+ import {
15
+ isAndroidPlatform,
16
+ isAndroidVersionAtLeast,
17
+ } from "@applicaster/zapp-react-native-utils/reactUtils";
18
+ import { getTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/getTabBarHeight";
19
+ import { PROGRESS_BAR_HEIGHT } from "./utils";
20
+ import { useIsTablet as getIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
21
+ import { useAppSelector } from "@applicaster/zapp-react-native-redux";
8
22
 
9
23
  export type ModalAnimationContextT = {
10
- yTranslate: React.MutableRefObject<Animated.Value | null>;
24
+ yTranslate: React.MutableRefObject<Animated.AnimatedInterpolation<number>>;
25
+ offsetAnimatedValueRef: React.MutableRefObject<Animated.Value>;
26
+ offset: React.MutableRefObject<number>;
27
+ heightAboveMinimised: number;
28
+ gestureTranslationRef: React.MutableRefObject<Animated.Value>;
11
29
  minimisedHeight: number;
12
30
  };
13
31
 
14
32
  export const ReactContext = React.createContext<ModalAnimationContextT>({
15
33
  yTranslate: React.createRef<Animated.Value | null>(),
34
+ offsetAnimatedValueRef: React.createRef<Animated.Value>(),
35
+ offset: React.createRef<number>(),
36
+ heightAboveMinimised: 0,
37
+ gestureTranslationRef: React.createRef<Animated.Value>(),
16
38
  minimisedHeight: 60,
17
39
  });
18
40
 
41
+ const SAFE_AREA_BREAKING_API_VERSION = 35;
42
+
43
+ export const isOldAndroidDevice =
44
+ isAndroidPlatform() &&
45
+ !isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION);
46
+
47
+ const bottomTabBarHeight = getTabBarHeight();
48
+
19
49
  const Provider = ({ children }: { children: React.ReactNode }) => {
50
+ const { height } = Dimensions.get("window");
51
+
20
52
  const yTranslate = React.useRef(
21
- new Animated.Value(Dimensions.get("window").height)
53
+ new Animated.Value(height).interpolate<number>({
54
+ inputRange: [0, height],
55
+ outputRange: [0, height],
56
+ })
22
57
  );
23
58
 
59
+ const { minimised_height: minimisedHeight } = useConfiguration();
60
+
24
61
  const {
25
- videoModalState: { visible },
62
+ videoModalState: { visible, mode },
63
+ currentRoute,
64
+ screenData,
26
65
  } = useNavigation();
27
66
 
28
- const { minimised_height: minimisedHeight } = useConfiguration();
67
+ const isTabletPortrait = useAppSelector(
68
+ (state) => state.appData.isTabletPortrait
69
+ );
70
+
71
+ const plugins = usePlugins();
72
+
73
+ const menuVisible = isMenuVisible(currentRoute, screenData, plugins);
74
+
75
+ const frame = useSafeAreaFrame();
76
+ const insets = useSafeAreaInsets();
77
+
78
+ const [heightAboveMinimised, setHeightAboveMinimised] = React.useState(0);
79
+
80
+ // memoizing heightAboveMinimised value
81
+ const offset = React.useRef(heightAboveMinimised);
82
+
83
+ // Used for memoizing modal y position after start/end of transition
84
+ const offsetAnimatedValueRef = React.useRef(
85
+ new Animated.Value(-offset.current)
86
+ );
87
+
88
+ // Used for gesture handling
89
+ const gestureTranslationRef = React.useRef(new Animated.Value(0));
90
+
91
+ const videoModalStateRef = React.useRef({ visible, mode });
92
+
93
+ React.useEffect(() => {
94
+ videoModalStateRef.current = { visible, mode };
95
+ }, [visible, mode]);
96
+
97
+ const translateY = useMemo(() => {
98
+ const maxRange = heightAboveMinimised;
99
+
100
+ const combined: Animated.AnimatedAddition<number> = Animated.add(
101
+ offsetAnimatedValueRef.current,
102
+ gestureTranslationRef.current
103
+ );
104
+
105
+ return combined.interpolate({
106
+ inputRange: [0, maxRange],
107
+ outputRange: [0, maxRange],
108
+ extrapolate: "clamp",
109
+ });
110
+ }, [visible, heightAboveMinimised]);
111
+
112
+ offset.current = heightAboveMinimised;
113
+ yTranslate.current = translateY;
114
+
115
+ React.useEffect(() => {
116
+ const collapsedHeight =
117
+ minimisedHeight +
118
+ (menuVisible ? bottomTabBarHeight : 0) +
119
+ (isOldAndroidDevice ? 0 : insets.bottom) + // insets.bottom is added to properly display docked modal
120
+ PROGRESS_BAR_HEIGHT;
121
+
122
+ const heightAboveMinimised = frame.height - collapsedHeight;
123
+
124
+ const isLandscape = frame.width > frame.height;
125
+
126
+ const isTablet = getIsTablet();
127
+
128
+ const shouldIgnoreLandscape = isTablet ? isTabletPortrait : true;
29
129
 
30
- const isTabletLandscape = useIsTabletLandscape();
31
- const windowDimensions = Dimensions.get("window");
32
-
33
- useEffect(() => {
34
- // Reset player animation state when video modal is closed
35
- if (!visible) {
36
- if (!isTabletLandscape) {
37
- // restore to portrait ( in portrait mode height is bigger)
38
- if (windowDimensions.height > windowDimensions.width) {
39
- yTranslate.current?.setValue(windowDimensions.height);
40
- }
41
- } else {
42
- yTranslate.current?.setValue(windowDimensions.height);
43
- }
130
+ if (
131
+ heightAboveMinimised !== offset.current &&
132
+ videoModalStateRef.current.mode !== "PIP" &&
133
+ videoModalStateRef.current.mode !== "FULLSCREEN"
134
+ ) {
135
+ if (isLandscape && shouldIgnoreLandscape) return;
136
+ setHeightAboveMinimised(heightAboveMinimised);
137
+ offset.current = heightAboveMinimised;
44
138
  }
45
- }, [
46
- visible,
47
- windowDimensions.height,
48
- isTabletLandscape,
49
- windowDimensions.width,
50
- ]);
139
+ }, [frame.height, insets.bottom, menuVisible, minimisedHeight]);
51
140
 
52
141
  return (
53
142
  <ReactContext.Provider
54
143
  value={useMemo(
55
144
  () => ({
56
145
  yTranslate,
146
+ offsetAnimatedValueRef,
147
+ offset,
148
+ heightAboveMinimised,
57
149
  minimisedHeight,
150
+ gestureTranslationRef,
58
151
  }),
59
- [minimisedHeight]
152
+ [minimisedHeight, heightAboveMinimised]
60
153
  )}
61
154
  >
62
155
  {children}
@@ -1,23 +1,11 @@
1
1
  import * as React from "react";
2
- import { StyleSheet, View, ViewStyle } from "react-native";
3
- import {
4
- Edge,
5
- SafeAreaView,
6
- useSafeAreaInsets,
7
- } from "react-native-safe-area-context";
2
+ import { View, ViewStyle } from "react-native";
3
+ import { Edge, SafeAreaView } from "react-native-safe-area-context";
8
4
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
9
5
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
10
6
  import { playerDimensionsHack } from "./utils";
11
- import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
12
- import {
13
- DimensionsT,
14
- Configuration,
15
- getEdges,
16
- getBaseDimensions,
17
- calculateAspectRatio,
18
- getPlayerDimensions,
19
- getContainerDimensions,
20
- } from "./playerWrapperUtils";
7
+ import { DimensionsT, Configuration, getEdges } from "./playerWrapperUtils";
8
+ import { defaultStyles, useStyle } from "./playerWrapperStyle";
21
9
 
22
10
  type Props = {
23
11
  entry: ZappEntry;
@@ -34,10 +22,6 @@ type Props = {
34
22
  playerContent: (styles: ViewStyle) => React.ReactNode;
35
23
  };
36
24
 
37
- const defaultStyles = StyleSheet.create({
38
- playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
39
- });
40
-
41
25
  const PlayerWrapperComponent = (props: Props) => {
42
26
  const {
43
27
  entry,
@@ -51,51 +35,21 @@ const PlayerWrapperComponent = (props: Props) => {
51
35
  playerContent,
52
36
  } = props;
53
37
 
38
+ const styles = useStyle({
39
+ style,
40
+ inline,
41
+ isModal,
42
+ isTabletPortrait,
43
+ configuration,
44
+ pip,
45
+ });
46
+
54
47
  const isTablet = useIsTablet();
55
48
 
56
49
  const isInlineModal = inline && isModal;
57
50
 
58
- const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
59
-
60
- const tabletWidth = getTabletWidth(
61
- configuration.tablet_landscape_sidebar_width,
62
- style
63
- );
64
-
65
- const baseDimensions: DimensionsT = React.useMemo(
66
- () => getBaseDimensions(isInlineModal, isTabletLandscape, tabletWidth),
67
- [isInlineModal, isTabletLandscape, tabletWidth]
68
- );
69
-
70
- const insets = useSafeAreaInsets();
71
-
72
- const aspectRatio = React.useMemo(
73
- () => calculateAspectRatio(isInlineModal, pip, insets),
74
- // ignoring insets - only initial needed
75
- // eslint-disable-next-line react-hooks/exhaustive-deps
76
- [isInlineModal, pip]
77
- );
78
-
79
- const playerDimensions = React.useMemo(
80
- () => getPlayerDimensions(baseDimensions, aspectRatio),
81
- [baseDimensions, aspectRatio]
82
- );
83
-
84
- const containerDimensions: DimensionsT = React.useMemo(
85
- () => getContainerDimensions(baseDimensions, playerDimensions.aspectRatio),
86
- [baseDimensions, playerDimensions.aspectRatio]
87
- );
88
-
89
51
  const WrapperView = React.useMemo(() => (isTV() ? View : SafeAreaView), []);
90
52
 
91
- const childrenStyles = React.useMemo(
92
- () => ({
93
- ...playerDimensions,
94
- ...playerDimensionsHack,
95
- }),
96
- [playerDimensions]
97
- );
98
-
99
53
  return (
100
54
  <WrapperView
101
55
  edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
@@ -106,11 +60,11 @@ const PlayerWrapperComponent = (props: Props) => {
106
60
  style={[
107
61
  defaultStyles.playerContainer,
108
62
  playerDimensionsHack,
109
- containerDimensions,
63
+ styles.containerDimensions,
110
64
  containerStyle,
111
65
  ]}
112
66
  >
113
- {playerContent(childrenStyles)}
67
+ {playerContent(styles.childrenStyles)}
114
68
  </View>
115
69
  </WrapperView>
116
70
  );
@@ -139,11 +139,7 @@ const VideoModalComponent = () => {
139
139
 
140
140
  {itemIdHooksFinished === item?.id ? (
141
141
  <View pointerEvents="box-none" style={styles.container}>
142
- <HandlePlayable
143
- item={item}
144
- isModal={mode !== "PIP"}
145
- mode={mode}
146
- />
142
+ <HandlePlayable item={item} isModal mode={mode} />
147
143
  </View>
148
144
  ) : (
149
145
  <View style={styles.loaderContainer}>
@@ -33,8 +33,12 @@ const MODAL_SIZE_FOR_LANDSCAPE: Size = {
33
33
  height: "100%",
34
34
  };
35
35
 
36
+ const SAFE_AREA_BREAKING_API_VERSION = 35;
37
+
36
38
  const isOldAndroidDevice =
37
- isAndroidPlatform() && !isAndroidVersionAtLeast(35) && !isAndroidTablet();
39
+ isAndroidPlatform() &&
40
+ !isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION) &&
41
+ !isAndroidTablet();
38
42
 
39
43
  export const useModalSize = (): Size => {
40
44
  const frame = useSafeAreaFrame();
@@ -0,0 +1,70 @@
1
+ import * as React from "react";
2
+ import { StyleSheet, ViewStyle } from "react-native";
3
+ import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
4
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
5
+ import { playerDimensionsHack } from "./utils";
6
+ import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
7
+ import {
8
+ getBaseDimensions,
9
+ calculateAspectRatio,
10
+ getPlayerDimensions,
11
+ getContainerDimensions,
12
+ } from "./playerWrapperUtils";
13
+
14
+ export const defaultStyles = StyleSheet.create({
15
+ playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
16
+ });
17
+
18
+ export const useStyle = ({
19
+ style,
20
+ inline,
21
+ isModal,
22
+ isTabletPortrait,
23
+ configuration,
24
+ pip,
25
+ }) => {
26
+ const isTablet = useIsTablet();
27
+
28
+ const isInlineModal = inline && isModal;
29
+
30
+ const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
31
+
32
+ const tabletWidth = getTabletWidth(
33
+ configuration.tablet_landscape_sidebar_width,
34
+ style
35
+ );
36
+
37
+ const baseDimensions: ViewStyle = React.useMemo(
38
+ () => getBaseDimensions(isInlineModal, isTabletLandscape, tabletWidth),
39
+ [isInlineModal, isTabletLandscape, tabletWidth]
40
+ );
41
+
42
+ const aspectRatio = React.useMemo(
43
+ () => calculateAspectRatio(isInlineModal, pip),
44
+ // ignoring insets - only initial needed
45
+ // eslint-disable-next-line react-hooks/exhaustive-deps
46
+ [isInlineModal, pip]
47
+ );
48
+
49
+ return React.useMemo(() => {
50
+ const playerDimensions: ViewStyle = getPlayerDimensions(
51
+ baseDimensions,
52
+ aspectRatio
53
+ );
54
+
55
+ const containerDimensions: ViewStyle = getContainerDimensions(
56
+ baseDimensions,
57
+ aspectRatio
58
+ );
59
+
60
+ const childrenStyles = {
61
+ ...playerDimensions,
62
+ ...playerDimensionsHack,
63
+ };
64
+
65
+ return StyleSheet.create({
66
+ containerDimensions,
67
+ childrenStyles,
68
+ });
69
+ }, [baseDimensions, aspectRatio]);
70
+ };
@@ -1,16 +1,6 @@
1
- import { Dimensions, Platform } from "react-native";
1
+ import { Dimensions, DimensionValue, Platform, ViewStyle } from "react-native";
2
2
  import { Edge } from "react-native-safe-area-context";
3
3
 
4
- import {
5
- isAndroidPlatform,
6
- isAndroidVersionAtLeast,
7
- } from "@applicaster/zapp-react-native-utils/reactUtils";
8
-
9
- const MIN_SUPPORTED_ANDROID_API = 34;
10
-
11
- export const isOldAndroidDevice =
12
- isAndroidPlatform() && !isAndroidVersionAtLeast(MIN_SUPPORTED_ANDROID_API);
13
-
14
4
  export type DimensionsT = {
15
5
  width: number | string;
16
6
  height: number | string | undefined;
@@ -23,6 +13,10 @@ export type Configuration = {
23
13
  tablet_landscape_player_container_background_color?: string;
24
14
  };
25
15
 
16
+ // This is safe, remembering screen dimensions once as they do not change during runtime
17
+ // TODO: consider sharing screen orientation as a shared function for the app
18
+ const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
19
+
26
20
  export const getWindowDimensions = () => {
27
21
  const { width, height } = Dimensions.get("window");
28
22
 
@@ -41,15 +35,11 @@ export const getMinWindowDimension = () => {
41
35
  return Math.min(width, height);
42
36
  };
43
37
 
44
- export const getScreenAspectRatio = (insets?: {
45
- top: number;
46
- bottom: number;
47
- }) => {
48
- const longEdge = getMaxWindowDimension();
49
- const shortEdge = getMinWindowDimension();
38
+ export const getScreenAspectRatio = () => {
39
+ const longEdge = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
40
+ const shortEdge = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
50
41
 
51
- // subtract insets to get correct aspect ratio on devices with notches
52
- return longEdge / (shortEdge - ((insets?.top ?? 0) + (insets?.bottom ?? 0)));
42
+ return longEdge / shortEdge;
53
43
  };
54
44
 
55
45
  export const getEdges = (
@@ -70,35 +60,32 @@ export const getEdges = (
70
60
  export const getBaseDimensions = (
71
61
  isInlineModal: boolean,
72
62
  isTabletLandscape: boolean,
73
- tabletWidth: number | string
74
- ): DimensionsT => ({
63
+ tabletWidth: DimensionValue
64
+ ): ViewStyle => ({
75
65
  width: isInlineModal && isTabletLandscape ? tabletWidth : "100%",
76
66
  height: undefined,
77
67
  });
78
68
 
79
69
  export const calculateAspectRatio = (
80
70
  isInlineModal: boolean,
81
- pip?: boolean,
82
- insets?: { top: number; bottom: number }
71
+ pip?: boolean
83
72
  ): number => {
84
- return !isInlineModal && !pip
85
- ? getScreenAspectRatio(isOldAndroidDevice ? insets : undefined)
86
- : 16 / 9;
73
+ return !isInlineModal && !pip ? getScreenAspectRatio() : 16 / 9;
87
74
  };
88
75
 
89
76
  export const getPlayerDimensions = (
90
- baseDimensions: DimensionsT,
77
+ baseDimensions: ViewStyle,
91
78
  aspectRatio: number
92
- ): DimensionsT => ({
93
- ...baseDimensions,
79
+ ): ViewStyle => ({
80
+ ...(baseDimensions as any),
94
81
  width: baseDimensions.width,
95
82
  aspectRatio,
96
83
  });
97
84
 
98
85
  export const getContainerDimensions = (
99
- baseDimensions: DimensionsT,
100
- playerAspectRatio?: number
101
- ): DimensionsT => ({
86
+ baseDimensions: ViewStyle,
87
+ aspectRatio?: string | number
88
+ ): ViewStyle => ({
102
89
  ...baseDimensions,
103
- aspectRatio: playerAspectRatio,
90
+ aspectRatio,
104
91
  });
@@ -4,6 +4,7 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
4
4
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
5
5
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device/useIsTablet";
6
6
  import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
7
+ import { create } from "zustand";
7
8
 
8
9
  export const useConfiguration = () => {
9
10
  const {
@@ -52,6 +53,12 @@ export const useConfiguration = () => {
52
53
  };
53
54
  };
54
55
 
56
+ export const useAnimationStateStore = create<{
57
+ isAnimationInProgress: boolean;
58
+ }>(() => ({
59
+ isAnimationInProgress: false,
60
+ }));
61
+
55
62
  const fullSize = {
56
63
  width: "100%",
57
64
  height: "100%",
package/index.d.ts CHANGED
@@ -228,6 +228,12 @@ declare type TabsSelectionContextType = {
228
228
  selectedEntryIndex: number;
229
229
  };
230
230
 
231
+ declare type TabsAccessibility = {
232
+ announcement?: string;
233
+ selectedHint?: string;
234
+ hint?: string;
235
+ };
236
+
231
237
  declare type TabsProps = {
232
238
  entry: ZappEntry[];
233
239
  groupId: string;
@@ -235,6 +241,7 @@ declare type TabsProps = {
235
241
  focused?: boolean;
236
242
  parentFocus?: ParentFocus;
237
243
  style?: ReactViewStyle;
244
+ accessibility?: TabsAccessibility;
238
245
  };
239
246
 
240
247
  declare type TabContentProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "15.0.0-alpha.3441591506",
3
+ "version": "15.0.0-alpha.3512356987",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "15.0.0-alpha.3441591506",
32
- "@applicaster/zapp-react-native-bridge": "15.0.0-alpha.3441591506",
33
- "@applicaster/zapp-react-native-redux": "15.0.0-alpha.3441591506",
34
- "@applicaster/zapp-react-native-utils": "15.0.0-alpha.3441591506",
31
+ "@applicaster/applicaster-types": "15.0.0-alpha.3512356987",
32
+ "@applicaster/zapp-react-native-bridge": "15.0.0-alpha.3512356987",
33
+ "@applicaster/zapp-react-native-redux": "15.0.0-alpha.3512356987",
34
+ "@applicaster/zapp-react-native-utils": "15.0.0-alpha.3512356987",
35
35
  "promise": "^8.3.0",
36
36
  "url": "^0.11.0",
37
37
  "uuid": "^3.3.2"