From 7e65c9fd71bef480fbf1b2521001b685d38c967b Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Thu, 10 Aug 2023 13:10:03 -0300 Subject: [PATCH] loading animated --- .../message/Components/Audio/Loading.tsx | 32 +++++++++++++++++++ .../message/Components/Audio/index.tsx | 15 ++++----- .../message/Components/Audio/styles.ts | 3 -- 3 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 app/containers/message/Components/Audio/Loading.tsx diff --git a/app/containers/message/Components/Audio/Loading.tsx b/app/containers/message/Components/Audio/Loading.tsx new file mode 100644 index 000000000..34baf68f2 --- /dev/null +++ b/app/containers/message/Components/Audio/Loading.tsx @@ -0,0 +1,32 @@ +import React, { useEffect } from 'react'; +import Animated, { Easing, useAnimatedStyle, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated'; + +import { CustomIcon } from '../../../CustomIcon'; +import { useTheme } from '../../../../theme'; + +const Loading = () => { + const rotation = useSharedValue(0); + const { colors } = useTheme(); + + useEffect(() => { + rotation.value = withRepeat( + withTiming(360, { + duration: 1000, + easing: Easing.inOut(Easing.linear) + }), + -1 + ); + }, []); + + const animatedStyle = useAnimatedStyle(() => ({ + transform: [{ rotate: `${rotation.value}deg` }] + })); + + return ( + + + + ); +}; + +export default Loading; diff --git a/app/containers/message/Components/Audio/index.tsx b/app/containers/message/Components/Audio/index.tsx index 716427338..220a67303 100644 --- a/app/containers/message/Components/Audio/index.tsx +++ b/app/containers/message/Components/Audio/index.tsx @@ -9,7 +9,6 @@ import Markdown from '../../../markdown'; import { CustomIcon } from '../../../CustomIcon'; import { themes } from '../../../../lib/constants'; import MessageContext from '../../Context'; -// import ActivityIndicator from '../../../ActivityIndicator'; import { TGetCustomEmoji } from '../../../../definitions/IEmoji'; import { IAttachment, IUserMessage } from '../../../../definitions'; import { useTheme } from '../../../../theme'; @@ -19,6 +18,7 @@ import { PAUSE_AUDIO } from '../../constants'; import { fetchAutoDownloadEnabled } from '../../../../lib/methods/autoDownloadPreference'; import styles from './styles'; import Slider from './Slider'; +import Loading from './Loading'; interface IButton { loading: boolean; @@ -51,13 +51,10 @@ const BUTTON_HIT_SLOP = { top: 12, right: 12, bottom: 12, left: 12 }; const Button = React.memo(({ loading, paused, onPress, disabled, cached }: IButton) => { const { colors } = useTheme(); - let customIconName: 'arrow-down' | 'play-shape-filled' | 'pause-shape-filled' | 'loading' = 'arrow-down'; + let customIconName: 'arrow-down' | 'play-shape-filled' | 'pause-shape-filled' = 'arrow-down'; if (cached) { customIconName = paused ? 'play-shape-filled' : 'pause-shape-filled'; } - if (loading) { - customIconName = 'loading'; - } return ( - - {/* {loading ? ( - + {loading ? ( + ) : ( - )} */} + + )} ); }); diff --git a/app/containers/message/Components/Audio/styles.ts b/app/containers/message/Components/Audio/styles.ts index ea9a537de..4d8ff7782 100644 --- a/app/containers/message/Components/Audio/styles.ts +++ b/app/containers/message/Components/Audio/styles.ts @@ -20,9 +20,6 @@ const styles = StyleSheet.create({ borderRadius: 4, justifyContent: 'center' }, - audioLoading: { - marginHorizontal: 8 - }, sliderContainer: { flexDirection: 'row', flex: 1,