Files
notesnook/apps/mobile/src/components/Loading/index.js

78 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-09-07 12:33:35 +05:00
import React from 'react';
import {
ActivityIndicator,
StyleSheet,
Text,
2020-09-09 11:10:35 +05:00
View
2020-09-07 12:33:35 +05:00
} from 'react-native';
2020-09-09 11:10:35 +05:00
import { ph, pv, SIZE, WEIGHT } from '../../common/common';
import { useTracked } from '../../provider';
import { Button } from '../Button';
2020-09-07 12:33:35 +05:00
export const Loading = ({
height = 150,
tagline = 'Loading....',
done = false,
doneText = 'Action completed successfully!',
onDone = () => {},
}) => {
const [state, dispatch] = useTracked();
const {colors, tags, premiumUser} = state;
return (
<View style={[{height: height}, styles.activityContainer]}>
{done ? (
<>
<Text
style={[
{color: colors.icon},
styles.activityText,
{fontSize: SIZE.xs},
]}>
{doneText}
</Text>
2020-09-09 11:10:35 +05:00
<Button
2020-09-07 12:33:35 +05:00
onPress={onDone}
2020-09-09 11:10:35 +05:00
title="Done"
/>
2020-09-07 12:33:35 +05:00
</>
) : (
<>
<ActivityIndicator color={colors.accent} />
<Text style={[{color: colors.pri}, styles.activityText]}>
{tagline}
</Text>
</>
)}
</View>
);
};
const styles = StyleSheet.create({
activityText: {
fontSize: SIZE.sm,
textAlign: 'center',
},
activityContainer: {
alignItems: 'center',
justifyContent: 'center',
},
button: {
paddingVertical: pv,
paddingHorizontal: ph,
marginTop: 10,
borderRadius: 5,
alignSelf: 'center',
width: '48%',
justifyContent: 'center',
alignItems: 'center',
borderWidth: 1,
flexDirection: 'row',
},
buttonText: {
fontFamily: WEIGHT.medium,
color: 'white',
fontSize: SIZE.sm,
},
});