Files
notesnook/apps/mobile/app/components/dialog/dialog-header.tsx

123 lines
3.3 KiB
TypeScript
Raw Normal View History

2022-08-30 16:13:11 +05:00
/* This file is part of the Notesnook project (https://notesnook.com/)
*
* Copyright (C) 2022 Streetwriters (Private) Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2022-08-29 16:19:17 +05:00
import React from "react";
import { Text, View } from "react-native";
import { useThemeStore } from "../../stores/use-theme-store";
import { SIZE } from "../../utils/size";
import { Button } from "../ui/button";
import { PressableButtonProps } from "../ui/pressable";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
2020-09-27 13:05:26 +05:00
2022-03-18 14:40:15 +05:00
type DialogHeaderProps = {
icon?: string;
title?: string;
paragraph?: string;
button?: {
onPress?: () => void;
loading?: boolean;
title?: string;
type?: PressableButtonProps["type"];
2022-03-18 14:40:15 +05:00
};
paragraphColor?: string;
padding?: number;
centered?: boolean;
titlePart?: string;
};
2021-11-15 15:25:36 +05:00
const DialogHeader = ({
title,
paragraph,
button,
paragraphColor,
padding,
centered,
titlePart
2022-03-18 14:40:15 +05:00
}: DialogHeaderProps) => {
const colors = useThemeStore((state) => state.colors);
2020-09-27 13:05:26 +05:00
return (
2020-09-27 13:14:24 +05:00
<>
<View
2020-09-27 13:05:26 +05:00
style={{
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
minHeight: 50,
2021-11-15 15:25:36 +05:00
paddingHorizontal: padding
2022-01-22 12:57:05 +05:00
}}
>
2020-12-19 13:15:34 +05:00
<View
style={{
width: "100%"
2022-01-22 12:57:05 +05:00
}}
>
2020-12-17 11:13:04 +05:00
<View
style={{
flexDirection: "row",
justifyContent: centered ? "center" : "space-between",
alignItems: "center"
2022-01-22 12:57:05 +05:00
}}
>
<Heading
style={{ textAlign: centered ? "center" : "left" }}
size={SIZE.lg}
>
{title}{" "}
{titlePart ? (
<Text style={{ color: colors.accent }}>{titlePart}</Text>
) : null}
2021-11-15 15:25:36 +05:00
</Heading>
2020-12-17 11:13:04 +05:00
2021-09-13 08:53:16 +05:00
{button ? (
2020-12-17 11:13:04 +05:00
<Button
onPress={button.onPress}
style={{
borderRadius: 100,
paddingHorizontal: 12
2020-12-17 11:13:04 +05:00
}}
2022-03-09 16:35:35 +05:00
loading={button.loading}
2021-06-02 17:34:39 +05:00
fontSize={13}
2020-12-17 11:13:04 +05:00
title={button.title}
type={button.type || "grayBg"}
2021-06-02 17:34:39 +05:00
height={25}
2020-12-17 11:13:04 +05:00
/>
2021-09-13 08:53:16 +05:00
) : null}
2020-12-17 11:13:04 +05:00
</View>
2020-11-23 15:57:31 +05:00
{paragraph ? (
2021-11-15 15:25:36 +05:00
<Paragraph
style={{
textAlign: centered ? "center" : "left",
maxWidth: centered ? "90%" : "100%",
alignSelf: centered ? "center" : "flex-start"
2021-11-15 15:25:36 +05:00
}}
2022-01-22 12:57:05 +05:00
color={paragraphColor || colors.icon}
>
{paragraph}
</Paragraph>
2020-11-23 15:57:31 +05:00
) : null}
</View>
</View>
2020-09-27 13:14:24 +05:00
</>
2020-09-27 13:05:26 +05:00
);
};
2020-09-27 13:14:24 +05:00
export default DialogHeader;