loading animated
This commit is contained in:
parent
55afcafd22
commit
7e65c9fd71
|
@ -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 (
|
||||||
|
<Animated.View style={[animatedStyle]}>
|
||||||
|
<CustomIcon name={'loading'} size={24} color={colors.buttonText} />
|
||||||
|
</Animated.View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Loading;
|
|
@ -9,7 +9,6 @@ import Markdown from '../../../markdown';
|
||||||
import { CustomIcon } from '../../../CustomIcon';
|
import { CustomIcon } from '../../../CustomIcon';
|
||||||
import { themes } from '../../../../lib/constants';
|
import { themes } from '../../../../lib/constants';
|
||||||
import MessageContext from '../../Context';
|
import MessageContext from '../../Context';
|
||||||
// import ActivityIndicator from '../../../ActivityIndicator';
|
|
||||||
import { TGetCustomEmoji } from '../../../../definitions/IEmoji';
|
import { TGetCustomEmoji } from '../../../../definitions/IEmoji';
|
||||||
import { IAttachment, IUserMessage } from '../../../../definitions';
|
import { IAttachment, IUserMessage } from '../../../../definitions';
|
||||||
import { useTheme } from '../../../../theme';
|
import { useTheme } from '../../../../theme';
|
||||||
|
@ -19,6 +18,7 @@ import { PAUSE_AUDIO } from '../../constants';
|
||||||
import { fetchAutoDownloadEnabled } from '../../../../lib/methods/autoDownloadPreference';
|
import { fetchAutoDownloadEnabled } from '../../../../lib/methods/autoDownloadPreference';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import Slider from './Slider';
|
import Slider from './Slider';
|
||||||
|
import Loading from './Loading';
|
||||||
|
|
||||||
interface IButton {
|
interface IButton {
|
||||||
loading: boolean;
|
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 Button = React.memo(({ loading, paused, onPress, disabled, cached }: IButton) => {
|
||||||
const { colors } = useTheme();
|
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) {
|
if (cached) {
|
||||||
customIconName = paused ? 'play-shape-filled' : 'pause-shape-filled';
|
customIconName = paused ? 'play-shape-filled' : 'pause-shape-filled';
|
||||||
}
|
}
|
||||||
if (loading) {
|
|
||||||
customIconName = 'loading';
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<Touchable
|
<Touchable
|
||||||
style={[styles.playPauseButton, { backgroundColor: colors.audioPlayerPrimary }]}
|
style={[styles.playPauseButton, { backgroundColor: colors.audioPlayerPrimary }]}
|
||||||
|
@ -66,11 +63,11 @@ const Button = React.memo(({ loading, paused, onPress, disabled, cached }: IButt
|
||||||
hitSlop={BUTTON_HIT_SLOP}
|
hitSlop={BUTTON_HIT_SLOP}
|
||||||
background={Touchable.SelectableBackgroundBorderless()}
|
background={Touchable.SelectableBackgroundBorderless()}
|
||||||
>
|
>
|
||||||
<CustomIcon name={customIconName} size={24} color={disabled ? colors.tintDisabled : colors.buttonText} />
|
{loading ? (
|
||||||
{/* {loading ? (
|
<Loading />
|
||||||
<ActivityIndicator style={[styles.playPauseButton, styles.audioLoading]} />
|
|
||||||
) : (
|
) : (
|
||||||
)} */}
|
<CustomIcon name={customIconName} size={24} color={disabled ? colors.tintDisabled : colors.buttonText} />
|
||||||
|
)}
|
||||||
</Touchable>
|
</Touchable>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,9 +20,6 @@ const styles = StyleSheet.create({
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
},
|
},
|
||||||
audioLoading: {
|
|
||||||
marginHorizontal: 8
|
|
||||||
},
|
|
||||||
sliderContainer: {
|
sliderContainer: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|
Loading…
Reference in New Issue