@@ -50,53 +50,45 @@ export interface LoaderProps extends ViewProps {
5050 tip ?: React . ReactNode ;
5151}
5252
53- export default class Loader extends Component < LoaderProps > {
54- static defaultProps : LoaderProps = {
55- maskColor : 'rgba(255, 255, 255, 0.85)' ,
56- loading : true ,
57- color : 'gray' ,
58- size : 'small' ,
59- } ;
60- render ( ) {
61- const {
62- children,
63- color : loaderColor ,
64- maskColor,
65- rounded,
66- loading,
67- tip,
68- size,
69- vertical,
70- ...otherProps
71- } = this . props ;
72- let styleProps : ActivityIndicatorProps [ 'style' ] = { } ;
73- if ( maskColor ) {
74- styleProps . backgroundColor = maskColor ;
75- }
76- if ( rounded ) {
77- styleProps . borderRadius = rounded ;
78- }
79- if ( vertical ) {
80- styleProps . flexDirection = 'column' ;
81- }
82- if ( ! children && ! tip ) {
83- return < ActivityIndicator animating = { loading } size = { size } color = { loaderColor } /> ;
84- }
85- const tips =
86- tip || loading ? (
87- < View style = { [ styles [ loading ? 'defalut' : 'stopActivity' ] , styleProps ] } >
88- < ActivityIndicator animating = { loading } size = { size } color = { loaderColor } />
89- { tip && ( typeof tip === 'string' ? < Text style = { { color : loaderColor } } > { tip } </ Text > : < View > { tip } </ View > ) }
90- </ View >
91- ) : null ;
92- if ( ! children && tip ) {
93- return tips ;
94- }
95- return (
96- < View { ...otherProps } >
97- { tips }
98- { children }
53+ export default function Loader ( props : LoaderProps ) {
54+ const {
55+ children,
56+ color : loaderColor = 'gray' ,
57+ maskColor = 'rgba(255, 255, 255, 0.85)' ,
58+ rounded,
59+ loading = true ,
60+ tip,
61+ size = 'small' ,
62+ vertical,
63+ ...otherProps
64+ } = props ;
65+ let styleProps : ActivityIndicatorProps [ 'style' ] = { } ;
66+ if ( maskColor ) {
67+ styleProps . backgroundColor = maskColor ;
68+ }
69+ if ( rounded ) {
70+ styleProps . borderRadius = rounded ;
71+ }
72+ if ( vertical ) {
73+ styleProps . flexDirection = 'column' ;
74+ }
75+ if ( ! children && ! tip ) {
76+ return < ActivityIndicator animating = { loading } size = { size } color = { loaderColor } /> ;
77+ }
78+ const tips =
79+ tip || loading ? (
80+ < View style = { [ styles [ loading ? 'defalut' : 'stopActivity' ] , styleProps ] } >
81+ < ActivityIndicator animating = { loading } size = { size } color = { loaderColor } />
82+ { tip && ( typeof tip === 'string' ? < Text style = { { color : loaderColor } } > { tip } </ Text > : < View > { tip } </ View > ) }
9983 </ View >
100- ) ;
84+ ) : null ;
85+ if ( ! children && tip ) {
86+ return tips ;
10187 }
88+ return (
89+ < View { ...otherProps } >
90+ { tips }
91+ { children }
92+ </ View >
93+ ) ;
10294}
0 commit comments