feat: add haptics feedback when entering select mode (#428)

This commit is contained in:
Huang Xin
2025-02-22 00:18:06 +01:00
committed by GitHub
parent 48ef2d634f
commit 2bb6ed2602
10 changed files with 46 additions and 5 deletions
@@ -219,7 +219,7 @@ const BookshelfItem: React.FC<BookshelfItemProps> = ({
};
const { pressing, handlers } = useLongPress({
onLongPress: () => {
onLongPress: async () => {
if (!isSelectMode) {
handleSetSelectMode(true);
}
@@ -91,7 +91,7 @@ const LibraryHeader: React.FC<LibraryHeaderProps> = ({
/>
</div>
<div className='absolute right-4 flex items-center space-x-2 text-gray-500 sm:space-x-4'>
<span className='mx-2 h-6 w-[1px] bg-gray-400'></span>
<span className='bg-base-content/50 mx-2 h-4 w-[0.5px]'></span>
<Dropdown
className='exclude-title-bar-mousedown dropdown-bottom flex h-6 cursor-pointer justify-center'
buttonClassName='p-0 h-6 min-h-6 w-6 flex items-center justify-center'
@@ -16,6 +16,7 @@ import { parseOpenWithFiles } from '@/helpers/cli';
import { isTauriAppPlatform, hasUpdater } from '@/services/environment';
import { checkForAppUpdates } from '@/helpers/updater';
import { FILE_ACCEPT_FORMATS, SUPPORTED_FILE_EXTS } from '@/services/constants';
import { impactFeedback } from '@tauri-apps/plugin-haptics';
import { useEnv } from '@/context/EnvContext';
import { useAuth } from '@/context/AuthContext';
@@ -335,10 +336,16 @@ const LibraryPage = () => {
};
const handleToggleSelectMode = () => {
if (!isSelectMode && appService?.isMobile) {
impactFeedback('medium');
}
setIsSelectMode(!isSelectMode);
};
const handleSetSelectMode = (selectMode: boolean) => {
if (selectMode && appService?.isMobile) {
impactFeedback('medium');
}
setIsSelectMode(selectMode);
};