2022-08-26 16:19:39 +05:00
|
|
|
import { ActivityIndicator, StyleSheet, View } from "react-native";
|
|
|
|
|
import { useThemeStore } from "../../stores/use-theme-store";
|
|
|
|
|
import { SIZE } from "../../utils/size";
|
|
|
|
|
import { Button } from "../ui/button";
|
|
|
|
|
import Paragraph from "../ui/typography/paragraph";
|
|
|
|
|
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
|
|
|
|
|
import { notesnook } from "../../../e2e/test.ids";
|
2020-09-27 13:05:26 +05:00
|
|
|
|
|
|
|
|
const DialogButtons = ({
|
|
|
|
|
onPressPositive,
|
|
|
|
|
onPressNegative,
|
|
|
|
|
positiveTitle,
|
2022-08-26 16:19:39 +05:00
|
|
|
negativeTitle = "Cancel",
|
2020-11-25 11:46:44 +05:00
|
|
|
loading,
|
2020-11-25 12:54:20 +05:00
|
|
|
doneText,
|
2021-05-25 22:14:06 +05:00
|
|
|
positiveType
|
2020-09-27 13:05:26 +05:00
|
|
|
}) => {
|
2022-08-26 16:19:39 +05:00
|
|
|
const colors = useThemeStore((state) => state.colors);
|
2020-11-25 11:46:44 +05:00
|
|
|
|
2020-09-27 13:05:26 +05:00
|
|
|
return (
|
2022-01-22 12:57:05 +05:00
|
|
|
<View
|
|
|
|
|
style={[
|
|
|
|
|
styles.container,
|
|
|
|
|
{
|
|
|
|
|
backgroundColor: colors.nav,
|
|
|
|
|
height: 60,
|
|
|
|
|
borderBottomRightRadius: 10,
|
|
|
|
|
borderBottomLeftRadius: 10,
|
|
|
|
|
paddingHorizontal: 12
|
|
|
|
|
}
|
|
|
|
|
]}
|
|
|
|
|
>
|
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={{
|
2022-08-26 16:19:39 +05:00
|
|
|
flexDirection: "row",
|
|
|
|
|
alignItems: "center"
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-08-26 16:19:39 +05:00
|
|
|
<Icon
|
|
|
|
|
color={colors.accent}
|
|
|
|
|
name="check-circle-outline"
|
|
|
|
|
size={SIZE.md}
|
|
|
|
|
/>
|
|
|
|
|
<Paragraph color={colors.accent}>{" " + doneText}</Paragraph>
|
2020-11-25 12:54:20 +05:00
|
|
|
</View>
|
|
|
|
|
) : (
|
|
|
|
|
<View />
|
|
|
|
|
)}
|
2020-11-25 11:46:44 +05:00
|
|
|
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
2022-08-26 16:19:39 +05:00
|
|
|
flexDirection: "row",
|
|
|
|
|
alignItems: "center"
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
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"
|
2021-11-08 15:06:46 +05:00
|
|
|
bold
|
2020-11-25 11:46:44 +05:00
|
|
|
title={negativeTitle}
|
2020-11-14 16:00:49 +05:00
|
|
|
/>
|
2021-09-13 08:53:16 +05:00
|
|
|
{onPressPositive ? (
|
2020-11-25 11:46:44 +05:00
|
|
|
<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={{
|
2022-01-22 12:57:05 +05:00
|
|
|
marginLeft: 10
|
2020-11-25 11:46:44 +05:00
|
|
|
}}
|
2021-11-08 15:06:46 +05:00
|
|
|
bold
|
2022-08-26 16:19:39 +05:00
|
|
|
type={positiveType || "transparent"}
|
2020-11-25 11:46:44 +05:00
|
|
|
title={positiveTitle}
|
|
|
|
|
/>
|
2021-09-13 08:53:16 +05:00
|
|
|
) : null}
|
2020-11-25 11:46:44 +05:00
|
|
|
</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: {
|
2022-08-26 16:19:39 +05:00
|
|
|
justifyContent: "space-between",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
flexDirection: "row",
|
2022-01-22 12:57:05 +05:00
|
|
|
marginTop: 10
|
|
|
|
|
}
|
2020-11-14 10:02:56 +05:00
|
|
|
});
|