[IMPROVE] migrate the ActivityIndicator and the Button component
This commit is contained in:
parent
eadbb59e09
commit
99b6c3d073
|
@ -1,8 +1,13 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ActivityIndicator, StyleSheet } from 'react-native';
|
import { ActivityIndicator, ActivityIndicatorProps, StyleSheet } from 'react-native';
|
||||||
import { PropTypes } from 'prop-types';
|
|
||||||
import { themes } from '../constants/colors';
|
import { themes } from '../constants/colors';
|
||||||
|
|
||||||
|
interface IActivityIndicator extends ActivityIndicatorProps{
|
||||||
|
theme?: 'light' | 'dark' | 'black',
|
||||||
|
absolute?: boolean,
|
||||||
|
props?: object
|
||||||
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
indicator: {
|
indicator: {
|
||||||
padding: 16,
|
padding: 16,
|
||||||
|
@ -19,7 +24,7 @@ const styles = StyleSheet.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const RCActivityIndicator = ({ theme, absolute, ...props }) => (
|
const RCActivityIndicator = ({ theme = 'light', absolute, ...props }: IActivityIndicator) => (
|
||||||
<ActivityIndicator
|
<ActivityIndicator
|
||||||
style={[styles.indicator, absolute && styles.absolute]}
|
style={[styles.indicator, absolute && styles.absolute]}
|
||||||
color={themes[theme].auxiliaryText}
|
color={themes[theme].auxiliaryText}
|
||||||
|
@ -27,14 +32,10 @@ const RCActivityIndicator = ({ theme, absolute, ...props }) => (
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
RCActivityIndicator.propTypes = {
|
|
||||||
theme: PropTypes.string,
|
|
||||||
absolute: PropTypes.bool,
|
|
||||||
props: PropTypes.object
|
|
||||||
};
|
|
||||||
|
|
||||||
RCActivityIndicator.defaultProps = {
|
// TODO - test the app without the theme default
|
||||||
theme: 'light'
|
// RCActivityIndicator.defaultProps = {
|
||||||
};
|
// theme: 'light'
|
||||||
|
// };
|
||||||
|
|
||||||
export default RCActivityIndicator;
|
export default RCActivityIndicator;
|
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { StyleSheet, Text } from 'react-native';
|
import { StyleSheet, Text } from 'react-native';
|
||||||
import Touchable from 'react-native-platform-touchable';
|
import Touchable from 'react-native-platform-touchable';
|
||||||
|
|
||||||
|
@ -7,6 +6,19 @@ import { themes } from '../../constants/colors';
|
||||||
import sharedStyles from '../../views/Styles';
|
import sharedStyles from '../../views/Styles';
|
||||||
import ActivityIndicator from '../ActivityIndicator';
|
import ActivityIndicator from '../ActivityIndicator';
|
||||||
|
|
||||||
|
interface IButton {
|
||||||
|
title: string;
|
||||||
|
type: string
|
||||||
|
onPress(): void;
|
||||||
|
disabled: boolean;
|
||||||
|
backgroundColor: string
|
||||||
|
loading: boolean;
|
||||||
|
theme: string
|
||||||
|
color: string
|
||||||
|
fontSize: any
|
||||||
|
style: any
|
||||||
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
paddingHorizontal: 14,
|
paddingHorizontal: 14,
|
||||||
|
@ -25,27 +37,7 @@ const styles = StyleSheet.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default class Button extends React.PureComponent {
|
export default class Button extends React.PureComponent<IButton, any> {
|
||||||
static propTypes = {
|
|
||||||
title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
||||||
type: PropTypes.string,
|
|
||||||
onPress: PropTypes.func,
|
|
||||||
disabled: PropTypes.bool,
|
|
||||||
backgroundColor: PropTypes.string,
|
|
||||||
loading: PropTypes.bool,
|
|
||||||
theme: PropTypes.string,
|
|
||||||
color: PropTypes.string,
|
|
||||||
fontSize: PropTypes.string,
|
|
||||||
style: PropTypes.any
|
|
||||||
}
|
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
title: 'Press me!',
|
|
||||||
type: 'primary',
|
|
||||||
onPress: () => alert('It works!'),
|
|
||||||
disabled: false,
|
|
||||||
loading: false
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
Loading…
Reference in New Issue