A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: add compact-view support in search results
Ammar Ahmedf37869cb5a57
diff --git a/apps/mobile/app/components/list-items/headers/section-header.tsx b/apps/mobile/app/components/list-items/headers/section-header.tsxindex 4ef97c94e..e53f4033e 100644--- a/apps/mobile/app/components/list-items/headers/section-header.tsx+++ b/apps/mobile/app/components/list-items/headers/section-header.tsx@@ -150,7 +150,8 @@ export const SectionHeader = React.memo<hidden={dataType !== "note" &&dataType !== "notebook" &&- screen !== "Notes"+ screen !== "Notes" &&+ screen !== "Search"}style={{width: 25,@@ -163,9 +164,11 @@ export const SectionHeader = React.memo<}onPress={() => {SettingsService.set({- [dataType !== "notebook"- ? "notesListMode"- : "notebooksListMode"]: !isCompactModeEnabled+ [dataType === "notebook"+ ? "notebooksListMode"+ : dataType === "searchResult"+ ? "searchListMode"+ : "noteListMode"]: !isCompactModeEnabled? "compact": "normal"});diff --git a/apps/mobile/app/components/list-items/search-result/index.tsx b/apps/mobile/app/components/list-items/search-result/index.tsxindex d9965a693..ec4934025 100644--- a/apps/mobile/app/components/list-items/search-result/index.tsx+++ b/apps/mobile/app/components/list-items/search-result/index.tsx@@ -31,6 +31,7 @@ import { eSendEvent } from "../../../services/event-manager";import { eOnLoadNote } from "../../../utils/events";import { IconButton } from "../../ui/icon-button";import { fluidTabsRef } from "../../../utils/global-refs";+import { useSettingStore } from "../../../stores/use-setting-store";type SearchResultProps = {item: HighlightedResult;};@@ -38,6 +39,9 @@ type SearchResultProps = {export const SearchResult = (props: SearchResultProps) => {const [expanded, setExpanded] = React.useState(true);const { colors } = useThemeColors();+ const compactMode = useSettingStore(+ (state) => state.settings.searchListMode === "compact"+ );const openNote = async (index?: number) => {const note = await db.notes.note(props.item.id);@@ -87,7 +91,7 @@ export const SearchResult = (props: SearchResultProps) => {flexShrink: 1}}>- {props.item.content?.length ? (+ {props.item.content?.length && !compactMode ? (<IconButtonname={!expanded ? "chevron-right" : "chevron-down"}onPress={() => setExpanded((prev) => !prev)}@@ -130,6 +134,7 @@ export const SearchResult = (props: SearchResultProps) => {</View>{expanded &&+ !compactMode &&props.item.content.map((content, index) => (<Pressablekey={props.item.id + index}diff --git a/apps/mobile/app/components/list/list-item.wrapper.tsx b/apps/mobile/app/components/list/list-item.wrapper.tsxindex f64364bea..e81b15553 100644--- a/apps/mobile/app/components/list/list-item.wrapper.tsx+++ b/apps/mobile/app/components/list/list-item.wrapper.tsx@@ -317,6 +317,7 @@ export function ListItemWrapper(props: ListItemWrapperProps) {}function getDate(item: Notebook | Note, groupType?: GroupingKey): number {+ console.log(groupType);return (getSortValue(groupTypediff --git a/apps/mobile/app/hooks/use-is-compact-mode-enabled.ts b/apps/mobile/app/hooks/use-is-compact-mode-enabled.tsindex 43df6df8d..0367b468b 100644--- a/apps/mobile/app/hooks/use-is-compact-mode-enabled.ts+++ b/apps/mobile/app/hooks/use-is-compact-mode-enabled.ts@@ -20,14 +20,27 @@ import { ItemType } from "@notesnook/core";import { useSettingStore } from "../stores/use-setting-store";export function useIsCompactModeEnabled(dataType: ItemType) {- const [notebooksListMode, notesListMode] = useSettingStore((state) => [- state.settings.notebooksListMode,- state.settings.notesListMode- ]);-- if (dataType !== "note" && dataType !== "notebook") return false;-- const listMode = dataType === "notebook" ? notebooksListMode : notesListMode;+ const [notebooksListMode, notesListMode, searchListMode] = useSettingStore(+ (state) => [+ state.settings.notebooksListMode,+ state.settings.notesListMode,+ state.settings.searchListMode+ ]+ );++ if (+ dataType !== "note" &&+ dataType !== "notebook" &&+ dataType !== "searchResult"+ )+ return false;++ const listMode =+ dataType === "notebook"+ ? notebooksListMode+ : dataType === "searchResult"+ ? searchListMode+ : notesListMode;return listMode === "compact";}diff --git a/apps/mobile/app/stores/use-setting-store.ts b/apps/mobile/app/stores/use-setting-store.tsindex cb50a57b7..9b082cc08 100644--- a/apps/mobile/app/stores/use-setting-store.ts+++ b/apps/mobile/app/stores/use-setting-store.ts@@ -58,6 +58,7 @@ export type Settings = {appLockMode?: "none" | "background" | "launch";notebooksListMode?: "normal" | "compact";notesListMode?: "normal" | "compact";+ searchListMode?: "normal" | "compact";devMode?: boolean;notifNotes?: boolean;pitchBlack?: boolean;@@ -172,6 +173,7 @@ export const defaultSettings: SettingStore["settings"] = {appLockMode: "none",notebooksListMode: "normal",notesListMode: "normal",+ searchListMode: "normal",devMode: false,notifNotes: false,pitchBlack: false,