xref: /MusicFree/src/components/base/loading.tsx (revision 8d82ecd9ebd88f4516b7a450e82025018c9ae12d)
119dc08ecS猫头猫import React from 'react';
219dc08ecS猫头猫import {StyleSheet, View} from 'react-native';
319dc08ecS猫头猫import rpx from '@/utils/rpx';
4e650bfb3S猫头猫import {ActivityIndicator} from 'react-native';
519dc08ecS猫头猫import ThemeText from './themeText';
6e650bfb3S猫头猫import useColors from '@/hooks/useColors';
719dc08ecS猫头猫
8806b2764S猫头猫interface ILoadingProps {
9806b2764S猫头猫    text?: string;
10f9afcc0dS猫头猫    showText?: boolean;
11f9afcc0dS猫头猫    height?: number;
12*8d82ecd9S猫头猫    color?: string;
13806b2764S猫头猫}
14806b2764S猫头猫export default function Loading(props: ILoadingProps) {
15e650bfb3S猫头猫    const colors = useColors();
16*8d82ecd9S猫头猫    const {showText = true, height, text, color} = props;
1719dc08ecS猫头猫
1819dc08ecS猫头猫    return (
19f9afcc0dS猫头猫        <View style={[style.wrapper, {height}]}>
20*8d82ecd9S猫头猫            <ActivityIndicator animating color={color ?? colors.text} />
21f9afcc0dS猫头猫            {showText ? (
224060c00aS猫头猫                <ThemeText
23*8d82ecd9S猫头猫                    color={color}
244060c00aS猫头猫                    fontSize="title"
254060c00aS猫头猫                    fontWeight="semibold"
264060c00aS猫头猫                    style={style.text}>
27f9afcc0dS猫头猫                    {text ?? '加载中...'}
284060c00aS猫头猫                </ThemeText>
29f9afcc0dS猫头猫            ) : null}
3019dc08ecS猫头猫        </View>
3119dc08ecS猫头猫    );
3219dc08ecS猫头猫}
3319dc08ecS猫头猫
3419dc08ecS猫头猫const style = StyleSheet.create({
3519dc08ecS猫头猫    wrapper: {
3619dc08ecS猫头猫        width: '100%',
3719dc08ecS猫头猫        flex: 1,
3819dc08ecS猫头猫        justifyContent: 'center',
3919dc08ecS猫头猫        alignItems: 'center',
4019dc08ecS猫头猫    },
4119dc08ecS猫头猫    text: {
4219dc08ecS猫头猫        marginTop: rpx(48),
4319dc08ecS猫头猫    },
4419dc08ecS猫头猫});
45