2022-06-23 19:14:55 +05:00
|
|
|
import ArrowBackIcon from "mdi-react/ArrowBackIcon";
|
|
|
|
|
import CloudUploadOutlineIcon from "mdi-react/CloudUploadOutlineIcon";
|
|
|
|
|
import CrownIcon from "mdi-react/CrownIcon";
|
|
|
|
|
import DotsHorizontalIcon from "mdi-react/DotsHorizontalIcon";
|
2022-07-07 18:40:05 +05:00
|
|
|
import ArrowULeftTopIcon from "mdi-react/ArrowULeftTopIcon";
|
|
|
|
|
import ArrowURightTopIcon from "mdi-react/ArrowURightTopIcon";
|
2022-06-23 19:14:55 +05:00
|
|
|
import MagnifyIcon from "mdi-react/MagnifyIcon";
|
2022-07-01 16:06:53 +05:00
|
|
|
import React from "react";
|
2022-06-23 19:14:55 +05:00
|
|
|
import { useSafeArea } from "../hooks/useSafeArea";
|
2022-07-01 16:06:53 +05:00
|
|
|
import { EventTypes, Settings } from "../utils";
|
2022-06-23 19:14:55 +05:00
|
|
|
import styles from "./styles.module.css";
|
|
|
|
|
|
|
|
|
|
const Button = ({
|
|
|
|
|
onPress,
|
|
|
|
|
children,
|
2022-07-08 14:45:23 +05:00
|
|
|
style,
|
2022-07-09 15:51:25 +05:00
|
|
|
preventDefault = true
|
2022-06-23 19:14:55 +05:00
|
|
|
}: {
|
|
|
|
|
onPress: () => void;
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
style: React.CSSProperties;
|
2022-07-08 14:45:23 +05:00
|
|
|
preventDefault?: boolean;
|
2022-06-23 19:14:55 +05:00
|
|
|
}) => {
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
className={styles.btn_header}
|
|
|
|
|
style={style}
|
2022-07-07 18:40:05 +05:00
|
|
|
onMouseDown={(e) => {
|
2022-07-08 14:45:23 +05:00
|
|
|
if (preventDefault) e.preventDefault();
|
2022-06-23 19:14:55 +05:00
|
|
|
onPress();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2022-06-30 09:47:04 +05:00
|
|
|
export default React.memo(
|
2022-07-01 16:06:53 +05:00
|
|
|
function Header({
|
|
|
|
|
noHeader,
|
|
|
|
|
settings,
|
2022-07-07 18:40:05 +05:00
|
|
|
hasUndo,
|
2022-07-09 15:51:25 +05:00
|
|
|
hasRedo
|
2022-07-01 16:06:53 +05:00
|
|
|
}: {
|
|
|
|
|
noHeader: boolean;
|
|
|
|
|
settings: Settings;
|
2022-07-07 18:40:05 +05:00
|
|
|
hasUndo: boolean;
|
|
|
|
|
hasRedo: boolean;
|
2022-07-01 16:06:53 +05:00
|
|
|
}) {
|
2022-06-30 09:47:04 +05:00
|
|
|
const insets = useSafeArea();
|
|
|
|
|
return (
|
2022-06-23 19:14:55 +05:00
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
display: "flex",
|
2022-06-30 09:47:04 +05:00
|
|
|
alignItems: "center",
|
|
|
|
|
height: noHeader ? `${insets.top}px` : `${50 + insets.top}px`,
|
|
|
|
|
backgroundColor: "var(--nn_bg)",
|
|
|
|
|
position: "sticky",
|
2022-07-09 15:51:25 +05:00
|
|
|
width: "100vw"
|
2022-06-23 19:14:55 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-06-30 09:47:04 +05:00
|
|
|
{noHeader ? null : (
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
width: "100%",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
flexDirection: "row",
|
2022-07-08 14:45:23 +05:00
|
|
|
paddingTop: insets.top,
|
2022-07-08 14:54:09 +05:00
|
|
|
height: 50,
|
2022-07-09 15:51:25 +05:00
|
|
|
alignItems: "center"
|
2022-06-30 09:47:04 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-06-23 19:14:55 +05:00
|
|
|
<Button
|
|
|
|
|
onPress={() => {
|
2022-06-30 09:47:04 +05:00
|
|
|
post(EventTypes.back);
|
2022-06-23 19:14:55 +05:00
|
|
|
}}
|
2022-07-08 14:45:23 +05:00
|
|
|
preventDefault={false}
|
2022-06-23 19:14:55 +05:00
|
|
|
style={{
|
|
|
|
|
borderWidth: 0,
|
|
|
|
|
borderRadius: 100,
|
|
|
|
|
color: "var(--nn_icon)",
|
2022-06-30 09:47:04 +05:00
|
|
|
marginLeft: 6,
|
|
|
|
|
width: 40,
|
|
|
|
|
height: 40,
|
2022-06-23 19:14:55 +05:00
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
2022-07-09 15:51:25 +05:00
|
|
|
alignItems: "center",
|
2022-07-08 14:45:23 +05:00
|
|
|
flexDirection: "column",
|
2022-07-09 15:51:25 +05:00
|
|
|
position: "relative"
|
2022-06-23 19:14:55 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-07-09 15:51:25 +05:00
|
|
|
<ArrowBackIcon
|
|
|
|
|
size={27}
|
|
|
|
|
style={{
|
|
|
|
|
position: "absolute"
|
|
|
|
|
}}
|
|
|
|
|
color="var(--nn_pri)"
|
|
|
|
|
/>
|
2022-06-23 19:14:55 +05:00
|
|
|
</Button>
|
|
|
|
|
|
2022-06-30 09:47:04 +05:00
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
2022-07-09 15:51:25 +05:00
|
|
|
flexDirection: "row"
|
2022-06-30 09:47:04 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-07-07 18:40:05 +05:00
|
|
|
<Button
|
|
|
|
|
onPress={() => {
|
|
|
|
|
editor?.commands.undo();
|
|
|
|
|
}}
|
|
|
|
|
style={{
|
|
|
|
|
borderWidth: 0,
|
|
|
|
|
borderRadius: 100,
|
|
|
|
|
color: "var(--nn_icon)",
|
|
|
|
|
marginRight: 10,
|
|
|
|
|
width: 39,
|
|
|
|
|
height: 39,
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
2022-07-08 14:45:23 +05:00
|
|
|
alignItems: "center",
|
2022-07-09 15:51:25 +05:00
|
|
|
position: "relative"
|
2022-07-07 18:40:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-07-08 18:33:54 +05:00
|
|
|
<ArrowULeftTopIcon
|
|
|
|
|
color={!hasUndo ? "var(--nn_nav)" : "var(--nn_pri)"}
|
2022-07-09 15:51:25 +05:00
|
|
|
size={25}
|
|
|
|
|
style={{
|
|
|
|
|
position: "absolute"
|
|
|
|
|
}}
|
2022-07-08 18:33:54 +05:00
|
|
|
/>
|
2022-07-07 18:40:05 +05:00
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
onPress={() => {
|
|
|
|
|
editor?.commands.redo();
|
|
|
|
|
}}
|
|
|
|
|
style={{
|
|
|
|
|
borderWidth: 0,
|
|
|
|
|
borderRadius: 100,
|
|
|
|
|
color: "var(--nn_icon)",
|
|
|
|
|
marginRight: 10,
|
|
|
|
|
width: 39,
|
|
|
|
|
height: 39,
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
2022-07-08 14:45:23 +05:00
|
|
|
alignItems: "center",
|
2022-07-09 15:51:25 +05:00
|
|
|
position: "relative"
|
2022-07-07 18:40:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-07-08 18:33:54 +05:00
|
|
|
<ArrowURightTopIcon
|
|
|
|
|
color={!hasRedo ? "var(--nn_nav)" : "var(--nn_pri)"}
|
2022-07-09 15:51:25 +05:00
|
|
|
size={25}
|
|
|
|
|
style={{
|
|
|
|
|
position: "absolute"
|
|
|
|
|
}}
|
2022-07-08 18:33:54 +05:00
|
|
|
/>
|
2022-07-07 18:40:05 +05:00
|
|
|
</Button>
|
2022-06-30 09:47:04 +05:00
|
|
|
{!settings.premium && (
|
|
|
|
|
<Button
|
|
|
|
|
onPress={() => {
|
|
|
|
|
post(EventTypes.pro);
|
|
|
|
|
}}
|
2022-07-08 14:45:23 +05:00
|
|
|
preventDefault={false}
|
2022-06-30 09:47:04 +05:00
|
|
|
style={{
|
|
|
|
|
borderWidth: 0,
|
|
|
|
|
borderRadius: 100,
|
|
|
|
|
color: "var(--nn_icon)",
|
|
|
|
|
marginRight: 10,
|
|
|
|
|
width: 39,
|
|
|
|
|
height: 39,
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
2022-07-08 14:45:23 +05:00
|
|
|
alignItems: "center",
|
2022-07-09 15:51:25 +05:00
|
|
|
position: "relative"
|
2022-06-30 09:47:04 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-07-09 15:51:25 +05:00
|
|
|
<CrownIcon
|
|
|
|
|
size={25}
|
|
|
|
|
style={{
|
|
|
|
|
position: "absolute"
|
|
|
|
|
}}
|
|
|
|
|
color="orange"
|
|
|
|
|
/>
|
2022-06-30 09:47:04 +05:00
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
<Button
|
|
|
|
|
onPress={() => {
|
2022-07-07 14:34:39 +05:00
|
|
|
editor?.commands.startSearch();
|
2022-06-30 09:47:04 +05:00
|
|
|
}}
|
|
|
|
|
style={{
|
|
|
|
|
borderWidth: 0,
|
|
|
|
|
borderRadius: 100,
|
|
|
|
|
color: "var(--nn_icon)",
|
|
|
|
|
marginRight: 10,
|
|
|
|
|
width: 39,
|
|
|
|
|
height: 39,
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
2022-07-08 14:45:23 +05:00
|
|
|
alignItems: "center",
|
2022-07-09 15:51:25 +05:00
|
|
|
position: "relative"
|
2022-06-30 09:47:04 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-07-09 15:51:25 +05:00
|
|
|
<MagnifyIcon
|
|
|
|
|
size={25}
|
|
|
|
|
style={{
|
|
|
|
|
position: "absolute"
|
|
|
|
|
}}
|
|
|
|
|
color="var(--nn_pri)"
|
|
|
|
|
/>
|
2022-06-30 09:47:04 +05:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
onPress={() => {
|
|
|
|
|
post(EventTypes.monograph);
|
|
|
|
|
}}
|
2022-07-08 14:45:23 +05:00
|
|
|
preventDefault={false}
|
2022-06-30 09:47:04 +05:00
|
|
|
style={{
|
|
|
|
|
borderWidth: 0,
|
|
|
|
|
borderRadius: 100,
|
|
|
|
|
color: "var(--nn_icon)",
|
|
|
|
|
marginRight: 10,
|
|
|
|
|
width: 39,
|
|
|
|
|
height: 39,
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
2022-07-08 14:45:23 +05:00
|
|
|
alignItems: "center",
|
2022-07-09 15:51:25 +05:00
|
|
|
position: "relative"
|
2022-06-30 09:47:04 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-07-09 15:51:25 +05:00
|
|
|
<CloudUploadOutlineIcon
|
|
|
|
|
size={25}
|
|
|
|
|
style={{
|
|
|
|
|
position: "absolute"
|
|
|
|
|
}}
|
|
|
|
|
color="var(--nn_pri)"
|
|
|
|
|
/>
|
2022-06-30 09:47:04 +05:00
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
onPress={() => {
|
|
|
|
|
post(EventTypes.properties);
|
|
|
|
|
}}
|
2022-07-08 14:45:23 +05:00
|
|
|
preventDefault={false}
|
2022-06-30 09:47:04 +05:00
|
|
|
style={{
|
|
|
|
|
borderWidth: 0,
|
|
|
|
|
borderRadius: 100,
|
|
|
|
|
color: "var(--nn_icon)",
|
|
|
|
|
marginRight: 12,
|
|
|
|
|
width: 39,
|
|
|
|
|
height: 39,
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
2022-07-08 14:45:23 +05:00
|
|
|
alignItems: "center",
|
2022-07-09 15:51:25 +05:00
|
|
|
position: "relative"
|
2022-06-30 09:47:04 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-07-09 15:51:25 +05:00
|
|
|
<DotsHorizontalIcon
|
|
|
|
|
size={25}
|
|
|
|
|
style={{
|
|
|
|
|
position: "absolute"
|
|
|
|
|
}}
|
|
|
|
|
color="var(--nn_pri)"
|
|
|
|
|
/>
|
2022-06-30 09:47:04 +05:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2022-06-23 19:14:55 +05:00
|
|
|
</div>
|
2022-06-30 09:47:04 +05:00
|
|
|
);
|
|
|
|
|
},
|
2022-07-08 18:33:54 +05:00
|
|
|
(prev, next) => {
|
|
|
|
|
if (
|
|
|
|
|
prev.noHeader !== next.noHeader ||
|
|
|
|
|
prev.settings.premium !== next.settings.premium ||
|
|
|
|
|
prev.hasRedo !== next.hasRedo ||
|
|
|
|
|
prev.hasUndo !== next.hasUndo
|
|
|
|
|
)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-06-30 09:47:04 +05:00
|
|
|
);
|