From b2f17823110012dd313969220d13f55b1a480f14 Mon Sep 17 00:00:00 2001 From: Jorrin Date: Sat, 6 Apr 2024 17:30:22 +0200 Subject: [PATCH] flash text while its in progress --- apps/expo/src/app/(tabs)/downloads.tsx | 9 ++++-- apps/expo/src/components/DownloadItem.tsx | 17 ++++++++-- apps/expo/src/components/player/Header.tsx | 4 +-- apps/expo/src/components/ui/Text.tsx | 36 ++++++++++++++++++++++ 4 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 apps/expo/src/components/ui/Text.tsx diff --git a/apps/expo/src/app/(tabs)/downloads.tsx b/apps/expo/src/app/(tabs)/downloads.tsx index ff20153..7a28f32 100644 --- a/apps/expo/src/app/(tabs)/downloads.tsx +++ b/apps/expo/src/app/(tabs)/downloads.tsx @@ -1,10 +1,9 @@ import React from "react"; import { Alert, Platform } from "react-native"; -import { ScrollView } from "react-native-gesture-handler"; import { useFocusEffect, useRouter } from "expo-router"; import { MaterialCommunityIcons } from "@expo/vector-icons"; import { isDevelopmentProvisioningProfile } from "modules/check-ios-certificate"; -import { useTheme, YStack } from "tamagui"; +import { ScrollView, useTheme, YStack } from "tamagui"; import type { ScrapeMedia } from "@movie-web/provider-utils"; @@ -114,7 +113,11 @@ const DownloadsScreen: React.FC = () => { test download (hls) - + {downloads.map((item) => ( - + {statusToTextMap[props.item.status]} - + diff --git a/apps/expo/src/components/player/Header.tsx b/apps/expo/src/components/player/Header.tsx index 3d163de..7d91695 100644 --- a/apps/expo/src/components/player/Header.tsx +++ b/apps/expo/src/components/player/Header.tsx @@ -23,7 +23,7 @@ export const Header = () => { height={64} paddingHorizontal="$8" > - + @@ -39,7 +39,7 @@ export const Header = () => { : ""} )} - + diff --git a/apps/expo/src/components/ui/Text.tsx b/apps/expo/src/components/ui/Text.tsx new file mode 100644 index 0000000..470395c --- /dev/null +++ b/apps/expo/src/components/ui/Text.tsx @@ -0,0 +1,36 @@ +import type { TextProps } from "react-native"; +import type { AnimatedProps } from "react-native-reanimated"; +import { useEffect } from "react"; +import Animated, { + Easing, + useAnimatedStyle, + useSharedValue, + withRepeat, + withTiming, +} from "react-native-reanimated"; + +export const FlashingText = ( + props: AnimatedProps & { + isInProgress: boolean; + }, +) => { + const opacity = useSharedValue(0); + + useEffect(() => { + if (props.isInProgress) { + opacity.value = withRepeat( + withTiming(1, { duration: 1000, easing: Easing.ease }), + -1, + true, + ); + } else { + opacity.value = 1; + } + }, [props.isInProgress, opacity]); + + const style = useAnimatedStyle(() => ({ + opacity: opacity.value, + })); + + return ; +};