2018-04-24 19:34:03 +00:00
|
|
|
import React from 'react';
|
2021-07-15 19:47:30 +00:00
|
|
|
import { ActivityIndicator, ActivityIndicatorProps, StyleSheet } from 'react-native';
|
2019-12-04 16:39:53 +00:00
|
|
|
import { themes } from '../constants/colors';
|
2018-04-24 19:34:03 +00:00
|
|
|
|
2021-07-15 19:47:30 +00:00
|
|
|
interface IActivityIndicator extends ActivityIndicatorProps{
|
|
|
|
theme?: 'light' | 'dark' | 'black',
|
|
|
|
absolute?: boolean,
|
|
|
|
props?: object
|
|
|
|
}
|
|
|
|
|
2018-04-24 19:34:03 +00:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
indicator: {
|
2019-12-04 16:39:53 +00:00
|
|
|
padding: 16,
|
|
|
|
flex: 1
|
|
|
|
},
|
|
|
|
absolute: {
|
|
|
|
position: 'absolute',
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
top: 0,
|
|
|
|
bottom: 0,
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center'
|
2018-04-24 19:34:03 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-07-15 19:47:30 +00:00
|
|
|
const RCActivityIndicator = ({ theme = 'light', absolute, ...props }: IActivityIndicator) => (
|
2019-12-04 16:39:53 +00:00
|
|
|
<ActivityIndicator
|
|
|
|
style={[styles.indicator, absolute && styles.absolute]}
|
|
|
|
color={themes[theme].auxiliaryText}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2021-07-15 19:47:30 +00:00
|
|
|
// TODO - test the app without the theme default
|
|
|
|
// RCActivityIndicator.defaultProps = {
|
|
|
|
// theme: 'light'
|
|
|
|
// };
|
2018-04-24 19:34:03 +00:00
|
|
|
|
|
|
|
export default RCActivityIndicator;
|