Files
notesnook/apps/mobile/src/components/Dialog/DialogButtons.js

81 lines
1.9 KiB
JavaScript
Raw Normal View History

2020-09-27 13:05:26 +05:00
import React from 'react';
2020-11-25 11:46:44 +05:00
import {ActivityIndicator, StyleSheet, View} from 'react-native';
import {useTracked} from '../../provider';
2020-11-14 10:02:56 +05:00
import {SIZE} from '../../utils/SizeUtils';
2020-09-27 13:05:26 +05:00
import {Button} from '../Button';
2020-11-25 12:54:20 +05:00
import Paragraph from '../Typography/Paragraph';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
2020-11-30 16:16:03 +05:00
import {notesnook} from '../../../e2e/test.ids';
2020-09-27 13:05:26 +05:00
const DialogButtons = ({
onPressPositive,
onPressNegative,
positiveTitle,
negativeTitle = 'Cancel',
2020-11-25 11:46:44 +05:00
loading,
2020-11-25 12:54:20 +05:00
doneText,
2020-09-27 13:05:26 +05:00
}) => {
2020-11-25 11:46:44 +05:00
const [state] = useTracked();
const {colors} = state;
2020-09-27 13:05:26 +05:00
return (
2020-11-14 10:02:56 +05:00
<View style={styles.container}>
2020-11-25 11:46:44 +05:00
{loading ? (
<ActivityIndicator color={colors.accent} size={SIZE.lg} />
2020-11-25 12:54:20 +05:00
) : doneText ? (
<View
style={{
flexDirection: 'row',
alignItems: 'center',
}}>
<Icon
color={colors.accent}
name="check-circle-outline"
size={SIZE.md}
/>
<Paragraph color={colors.accent}>{' ' + doneText}</Paragraph>
</View>
) : (
<View />
)}
2020-11-25 11:46:44 +05:00
<View
style={{
flexDirection: 'row',
alignItems: 'center',
}}>
2020-11-14 16:00:49 +05:00
<Button
2020-11-25 11:46:44 +05:00
onPress={onPressNegative}
2020-11-14 16:00:49 +05:00
fontSize={SIZE.md}
2020-11-30 16:16:03 +05:00
testID={notesnook.ids.default.dialog.no}
2020-11-25 11:46:44 +05:00
type="gray"
title={negativeTitle}
2020-11-14 16:00:49 +05:00
/>
2020-11-25 11:46:44 +05:00
{onPressPositive && (
<Button
onPress={onPressPositive}
fontSize={SIZE.md}
2020-11-30 16:16:03 +05:00
testID={notesnook.ids.default.dialog.yes}
2020-11-25 11:46:44 +05:00
style={{
marginLeft: 10,
}}
type="transparent"
title={positiveTitle}
/>
)}
</View>
2020-09-27 13:05:26 +05:00
</View>
);
};
export default DialogButtons;
const styles = StyleSheet.create({
2020-11-14 10:02:56 +05:00
container: {
2020-11-25 11:46:44 +05:00
justifyContent: 'space-between',
2020-09-27 13:05:26 +05:00
alignItems: 'center',
flexDirection: 'row',
marginTop: 20,
2020-11-14 10:02:56 +05:00
},
});