diff --git a/apps/mobile/app/common/database/sqlite.kysely.ts b/apps/mobile/app/common/database/sqlite.kysely.ts
index 6c19f2144..1ac2fb407 100644
--- a/apps/mobile/app/common/database/sqlite.kysely.ts
+++ b/apps/mobile/app/common/database/sqlite.kysely.ts
@@ -108,7 +108,7 @@ class RNSqliteConnection implements DatabaseConnection {
: "exec";
const result = await this.db.executeAsync(sql, parameters as any[]);
- console.log("SQLITE result:", result?.rows?._array);
+ // console.log("SQLITE result:", result?.rows?._array);
if (mode === "query" || !result.insertId)
return {
rows: result.rows?._array || []
diff --git a/apps/mobile/app/components/container/index.tsx b/apps/mobile/app/components/container/index.tsx
index e15361aa9..1ca6c6f29 100644
--- a/apps/mobile/app/components/container/index.tsx
+++ b/apps/mobile/app/components/container/index.tsx
@@ -22,7 +22,6 @@ import { KeyboardAvoidingView, Platform } from "react-native";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
import useIsFloatingKeyboard from "../../hooks/use-is-floating-keyboard";
import { useSettingStore } from "../../stores/use-setting-store";
-import { Header } from "../header";
import SelectionHeader from "../selection-header";
export const Container = ({ children }: PropsWithChildren) => {
@@ -46,7 +45,6 @@ export const Container = ({ children }: PropsWithChildren) => {
{!introCompleted ? null : (
<>
-
>
)}
diff --git a/apps/mobile/app/components/header/index.tsx b/apps/mobile/app/components/header/index.tsx
index 99e981a78..3c811a366 100644
--- a/apps/mobile/app/components/header/index.tsx
+++ b/apps/mobile/app/components/header/index.tsx
@@ -20,39 +20,70 @@ along with this program. If not, see .
import React, { useCallback, useEffect, useState } from "react";
import { Platform, StyleSheet, View } from "react-native";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
-import { SearchBar } from "../../screens/search/search-bar";
import {
eSubscribeEvent,
eUnSubscribeEvent
} from "../../services/event-manager";
-import useNavigationStore from "../../stores/use-navigation-store";
import { useSelectionStore } from "../../stores/use-selection-store";
import { useThemeColors } from "@notesnook/theme";
import { eScrollEvent } from "../../utils/events";
import { LeftMenus } from "./left-menus";
import { RightMenus } from "./right-menus";
import { Title } from "./title";
+import useNavigationStore, {
+ RouteName
+} from "../../stores/use-navigation-store";
-const _Header = () => {
+type HeaderRightButton = {
+ title: string;
+ onPress: () => void;
+};
+
+export const Header = ({
+ renderedInRoute,
+ onLeftMenuButtonPress,
+ title,
+ titleHiddenOnRender,
+ headerRightButtons,
+ id,
+ accentColor,
+ isBeta,
+ canGoBack,
+ onPressDefaultRightButton,
+ hasSearch,
+ onSearch
+}: {
+ onLeftMenuButtonPress?: () => void;
+ renderedInRoute: RouteName;
+ id?: string;
+ title: string;
+ headerRightButtons?: HeaderRightButton[];
+ titleHiddenOnRender?: boolean;
+ accentColor?: string;
+ isBeta?: boolean;
+ canGoBack?: boolean;
+ onPressDefaultRightButton?: () => void;
+ hasSearch?: boolean;
+ onSearch?: () => void;
+}) => {
const { colors } = useThemeColors();
const insets = useGlobalSafeAreaInsets();
- const [hide, setHide] = useState(true);
+ const [borderHidden, setBorderHidden] = useState(true);
const selectionMode = useSelectionStore((state) => state.selectionMode);
- const currentScreen = useNavigationStore(
- (state) => state.currentScreen?.name
- );
+ const isFocused = useNavigationStore((state) => state.focusedRouteId === id);
const onScroll = useCallback(
- (data: { x: number; y: number }) => {
+ (data: { x: number; y: number; id?: string; route: string }) => {
+ if (data.route !== renderedInRoute || data.id !== id) return;
if (data.y > 150) {
- if (!hide) return;
- setHide(false);
+ if (!borderHidden) return;
+ setBorderHidden(false);
} else {
- if (hide) return;
- setHide(true);
+ if (borderHidden) return;
+ setBorderHidden(true);
}
},
- [hide]
+ [borderHidden, id, renderedInRoute]
);
useEffect(() => {
@@ -60,9 +91,9 @@ const _Header = () => {
return () => {
eUnSubscribeEvent(eScrollEvent, onScroll);
};
- }, [hide, onScroll]);
+ }, [borderHidden, onScroll]);
- return selectionMode ? null : (
+ return selectionMode && isFocused ? null : (
<>
{
backgroundColor: colors.primary.background,
overflow: "hidden",
borderBottomWidth: 1,
- borderBottomColor: hide
+ borderBottomColor: borderHidden
? "transparent"
: colors.secondary.background,
justifyContent: "space-between"
}
]}
>
- {currentScreen === "Search" ? (
-
- ) : (
- <>
-
-
-
-
-
- >
- )}
+ <>
+
+
+
+
+
+
+ >
>
);
};
-export const Header = React.memo(_Header, () => true);
const styles = StyleSheet.create({
container: {
diff --git a/apps/mobile/app/components/header/left-menus.tsx b/apps/mobile/app/components/header/left-menus.tsx
index 5da228b8c..58d95ecf9 100644
--- a/apps/mobile/app/components/header/left-menus.tsx
+++ b/apps/mobile/app/components/header/left-menus.tsx
@@ -17,23 +17,29 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
+import { useThemeColors } from "@notesnook/theme";
import React from "react";
import { notesnook } from "../../../e2e/test.ids";
import { DDS } from "../../services/device-detection";
import Navigation from "../../services/navigation";
-import useNavigationStore from "../../stores/use-navigation-store";
import { useSettingStore } from "../../stores/use-setting-store";
-import { useThemeColors } from "@notesnook/theme";
import { tabBarRef } from "../../utils/global-refs";
import { IconButton } from "../ui/icon-button";
-export const LeftMenus = () => {
+export const LeftMenus = ({
+ canGoBack,
+ onLeftButtonPress
+}: {
+ canGoBack?: boolean;
+ onLeftButtonPress?: () => void;
+}) => {
const { colors } = useThemeColors();
const deviceMode = useSettingStore((state) => state.deviceMode);
- const canGoBack = useNavigationStore((state) => state.canGoBack);
const isTablet = deviceMode === "tablet";
- const onLeftButtonPress = () => {
+ const _onLeftButtonPress = () => {
+ if (onLeftButtonPress) return onLeftButtonPress();
+
if (!canGoBack) {
if (tabBarRef.current?.isDrawerOpen()) {
Navigation.closeDrawer();
@@ -60,7 +66,7 @@ export const LeftMenus = () => {
left={40}
top={40}
right={DDS.isLargeTablet() ? 10 : 10}
- onPress={onLeftButtonPress}
+ onPress={_onLeftButtonPress}
onLongPress={() => {
Navigation.popToTop();
}}
diff --git a/apps/mobile/app/components/header/right-menus.tsx b/apps/mobile/app/components/header/right-menus.tsx
index a379a515b..afc6fb8dd 100644
--- a/apps/mobile/app/components/header/right-menus.tsx
+++ b/apps/mobile/app/components/header/right-menus.tsx
@@ -20,40 +20,46 @@ along with this program. If not, see .
import React, { useRef } from "react";
import { Platform, StyleSheet, View } from "react-native";
//@ts-ignore
+import { useThemeColors } from "@notesnook/theme";
import Menu from "react-native-reanimated-material-menu";
import { notesnook } from "../../../e2e/test.ids";
import Navigation from "../../services/navigation";
import SearchService from "../../services/search";
-import useNavigationStore from "../../stores/use-navigation-store";
+import {
+ HeaderRightButton,
+ RouteName
+} from "../../stores/use-navigation-store";
import { useSettingStore } from "../../stores/use-setting-store";
-import { useThemeColors } from "@notesnook/theme";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
import { Button } from "../ui/button";
import { IconButton } from "../ui/icon-button";
-export const RightMenus = () => {
+export const RightMenus = ({
+ headerRightButtons,
+ renderedInRoute,
+ id,
+ onPressDefaultRightButton,
+ search,
+ onSearch
+}: {
+ headerRightButtons?: HeaderRightButton[];
+ renderedInRoute: RouteName;
+ id?: string;
+ onPressDefaultRightButton?: () => void;
+ search?: boolean;
+ onSearch?: () => void;
+}) => {
const { colors } = useThemeColors();
const { colors: contextMenuColors } = useThemeColors("contextMenu");
const deviceMode = useSettingStore((state) => state.deviceMode);
- const buttons = useNavigationStore((state) => state.headerRightButtons);
- const currentScreen = useNavigationStore((state) => state.currentScreen.name);
- const buttonAction = useNavigationStore((state) => state.buttonAction);
const menuRef = useRef