This repository has been archived on 2026-04-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
interaktive-systeme/components/common/loadingSymbol.tsx
2024-01-05 19:56:55 +00:00

49 lines
1.1 KiB
TypeScript

import React, { useEffect, useRef } from "react";
import { ActivityIndicator, Animated, Easing, StyleSheet, View } from "react-native";
import { useTheme } from "../../app/contexts/ThemeContext";
const LoadingSymbol = () => {
const {colors} = useTheme();
const spinValue = useRef(new Animated.Value(0)).current;
const spin = spinValue.interpolate({
inputRange: [0, 1],
outputRange: [0, 360],
});
useEffect(() => {
Animated.loop(
Animated.timing(spinValue, {
toValue: 1,
duration: 2000,
easing: Easing.linear,
useNativeDriver: true,
})
).start();
}, [spinValue]);
const styles = StyleSheet.create({
container: {
width: "100%",
height: "100%",
position: "absolute",
justifyContent: "center",
alignItems: "center",
},
loader: {
width: 100,
height: 100,
transform: [{ rotate: spin + "deg"}],
zIndex: 999,
},
});
return (
<View style={styles.container}>
<ActivityIndicator size="large" color={colors.accentColor} style={styles.loader} />
</View>
);
};
export default LoadingSymbol;