From effbc08561fcbaee3ba222024cdec0568bcc8980 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Sun, 9 Feb 2025 18:35:24 +0100 Subject: [PATCH] mobile: use sticky position for action bars for mobile compatibility (#335) --- README.md | 6 ++ .../src/app/library/components/Bookshelf.tsx | 60 ++++++++++------ apps/readest-app/src/app/library/page.tsx | 24 +++---- apps/readest-app/src/components/Alert.tsx | 70 ++++++++++--------- .../readest-app/src/hooks/usePullToRefresh.ts | 2 + 5 files changed, 92 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 3bc9b8b7..ec736b65 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,8 @@ For Android: pnpm tauri android init pnpm tauri android dev +# or if you want to dev on a real device +pnpm tauri android dev --host ``` For iOS: @@ -168,12 +170,16 @@ For iOS: pnpm tauri ios init pnpm tauri ios dev +# or if you want to dev on a real device +pnpm tauri ios dev --host ``` ### 5. Build for Production ```bash pnpm tauri build +pnpm tauri android build +pnpm tauri ios build ``` ### 6. Setup dev environment with Nix diff --git a/apps/readest-app/src/app/library/components/Bookshelf.tsx b/apps/readest-app/src/app/library/components/Bookshelf.tsx index 26067467..21db8ec3 100644 --- a/apps/readest-app/src/app/library/components/Bookshelf.tsx +++ b/apps/readest-app/src/app/library/components/Bookshelf.tsx @@ -253,35 +253,49 @@ const Bookshelf: React.FC = ({ )} - {selectedBooks.length > 0 && ( -
- - -
- )} {loading && (
)} +
+ {selectedBooks.length > 0 && ( +
+ + +
+ )} +
{showDeleteAlert && ( - setShowDeleteAlert(false)} - onClickConfirm={confirmDelete} - /> +
+ setShowDeleteAlert(false)} + onClickConfirm={confirmDelete} + /> +
)} ); diff --git a/apps/readest-app/src/app/library/page.tsx b/apps/readest-app/src/app/library/page.tsx index b3ab93b2..eb33526f 100644 --- a/apps/readest-app/src/app/library/page.tsx +++ b/apps/readest-app/src/app/library/page.tsx @@ -2,7 +2,7 @@ import clsx from 'clsx'; import * as React from 'react'; -import { useState, useRef, useEffect, Suspense } from 'react'; +import { useState, useRef, useEffect } from 'react'; import { useRouter } from 'next/navigation'; import { Book } from '@/types/book'; @@ -384,18 +384,16 @@ const LibraryPage = () => { appService?.hasSafeAreaInset && 'mt-[calc(48px+env(safe-area-inset-top))]', )} > - - - + ) : (
diff --git a/apps/readest-app/src/components/Alert.tsx b/apps/readest-app/src/components/Alert.tsx index cd67f64b..a23ae92d 100644 --- a/apps/readest-app/src/components/Alert.tsx +++ b/apps/readest-app/src/components/Alert.tsx @@ -1,5 +1,5 @@ -import React from 'react'; import clsx from 'clsx'; +import React from 'react'; import { useTranslation } from '@/hooks/useTranslation'; const Alert: React.FC<{ @@ -10,40 +10,42 @@ const Alert: React.FC<{ }> = ({ title, message, onClickCancel, onClickConfirm }) => { const _ = useTranslation(); return ( -
-
- - - -
-

{title}

-
{message}
+
+
+
+ + + +
+

{title}

+
{message}
+
+
+
+ +
-
-
- -
); diff --git a/apps/readest-app/src/hooks/usePullToRefresh.ts b/apps/readest-app/src/hooks/usePullToRefresh.ts index 3a564459..ef6581d8 100644 --- a/apps/readest-app/src/hooks/usePullToRefresh.ts +++ b/apps/readest-app/src/hooks/usePullToRefresh.ts @@ -20,6 +20,8 @@ export const usePullToRefresh = (ref: React.RefObject, onTrigger const el = ref.current; if (!el) return; + if (el.scrollTop > 0) return; + const initialY = startEvent.touches[0]!.clientY; el.addEventListener('touchmove', handleTouchMove, { passive: false });