xref: /MusicFree/src/components/base/loading.tsx (revision 095287552b9baf2f2ceeb9397c563c292a4f7934)
1import React from 'react';
2import {StyleSheet, View} from 'react-native';
3import rpx from '@/utils/rpx';
4import {ActivityIndicator} from 'react-native';
5import ThemeText from './themeText';
6import useColors from '@/hooks/useColors';
7
8interface ILoadingProps {
9    text?: string;
10    showText?: boolean;
11    height?: number;
12    color?: string;
13}
14export default function Loading(props: ILoadingProps) {
15    const colors = useColors();
16    const {showText = true, height, text, color} = props;
17
18    return (
19        <View style={[style.wrapper, {height}]}>
20            <ActivityIndicator animating color={color ?? colors.text} />
21            {showText ? (
22                <ThemeText
23                    color={color}
24                    fontSize="title"
25                    fontWeight="semibold"
26                    style={style.text}>
27                    {text ?? '加载中...'}
28                </ThemeText>
29            ) : null}
30        </View>
31    );
32}
33
34const style = StyleSheet.create({
35    wrapper: {
36        width: '100%',
37        flex: 1,
38        justifyContent: 'center',
39        alignItems: 'center',
40    },
41    text: {
42        marginTop: rpx(48),
43    },
44});
45