Merge branch '53-loading-simple' into 'main'

Resolve "loading simple"

Closes #53

See merge request thschleicher/interaktive-systeme!40
This commit is contained in:
jastornig 2024-01-05 16:46:33 +00:00
commit 8ff3435c2b

View file

@ -1,23 +1,49 @@
import { StyleSheet, View } from "react-native"; import React, { useEffect, useRef } from "react";
import { StyleSheet, View, Animated, Easing, ActivityIndicator } from "react-native";
const LoadingSymbol = () => { const LoadingSymbol = () => {
const color = ["blue", "red", "purple", "green", "yellow", "orange"]; const color = ["blue", "red", "purple", "green", "yellow", "orange"];
const random = Math.floor(Math.random() * color.length); const random = Math.floor(Math.random() * color.length);
const spinValue = useRef(new Animated.Value(0)).current;
const spin = spinValue.interpolate({
inputRange: [0, 1],
outputRange: ["0deg", "360deg"],
});
useEffect(() => {
Animated.loop(
Animated.timing(spinValue, {
toValue: 1,
duration: 2000,
easing: Easing.linear,
useNativeDriver: true,
})
).start();
}, [spinValue]);
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
backgroundColor: color[random], backgroundColor: color[random],
width: "100%", width: "100%",
height: "100%", height: "100%",
position: "absolute", position: "absolute",
} justifyContent: "center",
alignItems: "center",
},
loader: {
width: 100,
height: 100,
transform: [{ rotate: spin }],
},
}); });
return ( return (
<View style={styles.container}></View> <View style={styles.container}>
<ActivityIndicator size="large" color="black" style={styles.loader} />
</View>
); );
} };
export default LoadingSymbol; export default LoadingSymbol;