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