@applicaster/quick-brick-player 13.0.0-rc.99 → 13.0.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.
Files changed (34) hide show
  1. package/package.json +6 -7
  2. package/src/Player/AudioLayer/AudioDescription.tsx +109 -68
  3. package/src/Player/AudioLayer/AudioPlayerWrapper.tsx +81 -189
  4. package/src/Player/AudioLayer/Layout/Controls/VerticalGutter.tsx +23 -5
  5. package/src/Player/AudioLayer/Layout/Controls/index.tsx +24 -49
  6. package/src/Player/AudioLayer/Layout/Controls/utils.ts +2 -2
  7. package/src/Player/AudioLayer/Layout/DockedControls/index.tsx +38 -19
  8. package/src/Player/AudioLayer/Layout/MobileLayout.tsx +4 -13
  9. package/src/Player/AudioLayer/Layout/PlayerImage/AnimatedImage.tsx +39 -40
  10. package/src/Player/AudioLayer/Layout/PlayerImage/FlexImage.tsx +6 -22
  11. package/src/Player/AudioLayer/Layout/PlayerImage/hooks/index.ts +1 -0
  12. package/src/Player/AudioLayer/Layout/PlayerImage/hooks/useChangePlayerState.ts +99 -0
  13. package/src/Player/AudioLayer/Layout/PlayerImage/index.tsx +37 -20
  14. package/src/Player/AudioLayer/Layout/PlayerImage/styles.ts +19 -0
  15. package/src/Player/AudioLayer/Layout/TabletLandscapeLayout.tsx +101 -105
  16. package/src/Player/AudioLayer/Layout/TabletPortraitLayout.tsx +2 -11
  17. package/src/Player/AudioLayer/Layout/TransportInfo/index.tsx +19 -5
  18. package/src/Player/AudioLayer/Layout/const.ts +4 -0
  19. package/src/Player/AudioLayer/Layout/hooks/useTransportInfoHeight.ts +1 -1
  20. package/src/Player/AudioLayer/Layout/utils.ts +7 -0
  21. package/src/Player/AudioLayer/SleepTimerManager.ts +22 -11
  22. package/src/Player/AudioLayer/components/SleepTimerModalHeader/SleepTimerModalHeader.tsx +66 -0
  23. package/src/Player/AudioLayer/components/SleepTimerModalHeader/index.ts +1 -0
  24. package/src/Player/AudioLayer/useSleepTimerModal.ts +109 -0
  25. package/src/Player/Const/sleepTimerOptions.ts +7 -5
  26. package/src/Player/Utils/index.tsx +6 -0
  27. package/src/Player/hooks/useIsCasting.tsx +57 -0
  28. package/src/Player/index.tsx +84 -37
  29. package/src/QuickBrickPlayer.tsx +3 -0
  30. package/src/Player/AudioLayer/LinearGradient/LinearGradientProxy.ts +0 -3
  31. package/src/Player/AudioLayer/LinearGradient/LinearGradientProxy.web.ts +0 -3
  32. package/src/Player/AudioLayer/LinearGradient/index.ts +0 -1
  33. package/src/Player/AudioLayer/MagicBG/index.tsx +0 -155
  34. package/src/utils/utils.ts +0 -25
@@ -1,155 +0,0 @@
1
- /* eslint-disable react/prop-types */
2
- import * as React from "react";
3
- import { Animated, StyleSheet, View } from "react-native";
4
- import LinearGradient from "../LinearGradient";
5
- import { getDominantColor, getPalettes } from "../../../utils/utils";
6
- import { useEffect } from "react";
7
-
8
- type MagicBGProps = {
9
- children: React.ReactNode;
10
- image: string;
11
- fallbackUrl?: string;
12
- defaultColor: string;
13
- colors: string[];
14
- };
15
-
16
- const defaultColors = {
17
- overlay: "rgba(0, 0, 0, 0.35)",
18
- defaultGradientStart: "rgba(0, 0, 0, 0.25)",
19
- defaultGradientEnd: "rgba(0, 0, 0, 0)",
20
- };
21
-
22
- const styles = StyleSheet.create({
23
- container: {
24
- flex: 1,
25
- },
26
- fullScreenOverlay: {
27
- ...StyleSheet.absoluteFillObject,
28
- backgroundColor: defaultColors.overlay,
29
- },
30
- gradientOverlay: {
31
- position: "absolute",
32
- bottom: 0,
33
- left: 0,
34
- right: 0,
35
- height: "100%",
36
- },
37
- });
38
-
39
- const fetchPaletteAndDominantColor = async (imageUrl: string) => {
40
- const palette = await getPalettes(imageUrl);
41
-
42
- const colors = palette.map(
43
- (color: { r: number; g: number; b: number }) =>
44
- `rgb(${color.r}, ${color.g}, ${color.b})`
45
- );
46
-
47
- const dominant = await getDominantColor(imageUrl);
48
- const dominantColor = `rgb(${dominant.r}, ${dominant.g}, ${dominant.b})`;
49
-
50
- return { gradientColors: colors.slice(0, 2).reverse(), dominantColor };
51
- };
52
-
53
- export const MagicBG: React.FC<MagicBGProps> = ({
54
- children,
55
- image,
56
- fallbackUrl = "",
57
- colors = [],
58
- defaultColor,
59
- }) => {
60
- const [dominantColor, setDominantColor] =
61
- React.useState<string>(defaultColor);
62
-
63
- const [gradientColors, setGradientColors] = React.useState<string[]>([
64
- defaultColors.defaultGradientStart,
65
- defaultColors.defaultGradientEnd,
66
- ]);
67
-
68
- const [backgroundColorAnim] = React.useState(new Animated.Value(0)); // from 0 to 1
69
- const [gradientOpacityAnim] = React.useState(new Animated.Value(0)); // from 0 to 1
70
-
71
- useEffect(() => {
72
- const animateColors = () => {
73
- Animated.timing(backgroundColorAnim, {
74
- toValue: 1,
75
- duration: 500,
76
- useNativeDriver: false,
77
- }).start();
78
-
79
- Animated.timing(gradientOpacityAnim, {
80
- toValue: 1,
81
- duration: 500,
82
- useNativeDriver: false,
83
- }).start();
84
- };
85
-
86
- const fetchColors = async () => {
87
- if (colors && colors.length > 0) {
88
- setGradientColors(colors.slice(0, 2));
89
- setDominantColor(colors[0]);
90
- animateColors();
91
- } else if (image) {
92
- try {
93
- const { gradientColors, dominantColor } =
94
- await fetchPaletteAndDominantColor(image);
95
-
96
- setGradientColors(gradientColors);
97
- setDominantColor(dominantColor);
98
- animateColors();
99
- } catch (error) {
100
- try {
101
- const { gradientColors, dominantColor } =
102
- await fetchPaletteAndDominantColor(fallbackUrl);
103
-
104
- setGradientColors(gradientColors);
105
- setDominantColor(dominantColor);
106
- animateColors();
107
- } catch {
108
- setGradientColors([
109
- defaultColors.defaultGradientStart,
110
- defaultColors.defaultGradientEnd,
111
- ]);
112
-
113
- setDominantColor(defaultColor);
114
- }
115
- }
116
- } else {
117
- setGradientColors([
118
- defaultColors.defaultGradientStart,
119
- defaultColors.defaultGradientEnd,
120
- ]);
121
-
122
- setDominantColor(defaultColor);
123
- }
124
- };
125
-
126
- fetchColors();
127
- }, []);
128
-
129
- const interpolatedBackgroundColor = backgroundColorAnim.interpolate({
130
- inputRange: [0, 1],
131
- outputRange: ["black", dominantColor],
132
- });
133
-
134
- return (
135
- <Animated.View
136
- style={[
137
- styles.container,
138
- { backgroundColor: interpolatedBackgroundColor },
139
- ]}
140
- >
141
- <View style={styles.fullScreenOverlay} />
142
-
143
- <Animated.View
144
- style={[styles.gradientOverlay, { opacity: gradientOpacityAnim }]}
145
- >
146
- <LinearGradient
147
- colors={gradientColors}
148
- style={StyleSheet.absoluteFill}
149
- />
150
- </Animated.View>
151
-
152
- {children}
153
- </Animated.View>
154
- );
155
- };
@@ -1,25 +0,0 @@
1
- import RNColorThief from "@applicaster/react-native-color-thief";
2
- import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
3
-
4
- const { log_error } = createLogger({
5
- subsystem: "UIComponent",
6
- category: "MagicBackground",
7
- });
8
-
9
- export const getDominantColor = async (imageUrl: string): Promise<any> => {
10
- try {
11
- return await RNColorThief.getColor(imageUrl, 1, false);
12
- } catch (error) {
13
- log_error("Failed to get the dominant color", { error });
14
- throw error;
15
- }
16
- };
17
-
18
- export const getPalettes = async (imageUrl: string): Promise<any> => {
19
- try {
20
- return await RNColorThief.getPalette(imageUrl, 3, 1, true);
21
- } catch (error) {
22
- log_error("Failed to get the palette", { error });
23
- throw error;
24
- }
25
- };