xref: /MusicFree/src/components/base/loading.tsx (revision f9afcc0d02c058f568e43dc501a8b0e6dbce15c6)
119dc08ecS猫头猫import React from 'react';
219dc08ecS猫头猫import {StyleSheet, View} from 'react-native';
319dc08ecS猫头猫import rpx from '@/utils/rpx';
419dc08ecS猫头猫import {ActivityIndicator, useTheme} from 'react-native-paper';
519dc08ecS猫头猫import ThemeText from './themeText';
619dc08ecS猫头猫
7806b2764S猫头猫interface ILoadingProps {
8806b2764S猫头猫    text?: string;
9*f9afcc0dS猫头猫    showText?: boolean;
10*f9afcc0dS猫头猫    height?: number;
11806b2764S猫头猫}
12806b2764S猫头猫export default function Loading(props: ILoadingProps) {
1319dc08ecS猫头猫    const {colors} = useTheme();
14*f9afcc0dS猫头猫    const {showText = true, height, text} = props;
1519dc08ecS猫头猫
1619dc08ecS猫头猫    return (
17*f9afcc0dS猫头猫        <View style={[style.wrapper, {height}]}>
184060c00aS猫头猫            <ActivityIndicator animating color={colors.text} />
19*f9afcc0dS猫头猫            {showText ? (
204060c00aS猫头猫                <ThemeText
214060c00aS猫头猫                    fontSize="title"
224060c00aS猫头猫                    fontWeight="semibold"
234060c00aS猫头猫                    style={style.text}>
24*f9afcc0dS猫头猫                    {text ?? '加载中...'}
254060c00aS猫头猫                </ThemeText>
26*f9afcc0dS猫头猫            ) : null}
2719dc08ecS猫头猫        </View>
2819dc08ecS猫头猫    );
2919dc08ecS猫头猫}
3019dc08ecS猫头猫
3119dc08ecS猫头猫const style = StyleSheet.create({
3219dc08ecS猫头猫    wrapper: {
3319dc08ecS猫头猫        width: '100%',
3419dc08ecS猫头猫        flex: 1,
3519dc08ecS猫头猫        justifyContent: 'center',
3619dc08ecS猫头猫        alignItems: 'center',
3719dc08ecS猫头猫    },
3819dc08ecS猫头猫    text: {
3919dc08ecS猫头猫        marginTop: rpx(48),
4019dc08ecS猫头猫    },
4119dc08ecS猫头猫});
42