From 19fed8228197dc14e5a7ae92eca42221528c96c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=84=E5=AE=8F=E5=9F=BA?= Date: Wed, 7 Jun 2023 08:27:10 +0800 Subject: [PATCH] ux: add haptic feedback of share dialogue --- src/components/chat/DividerMessageView.tsx | 6 +++++- src/screens/share-chat/ShotScene.tsx | 8 ++++++-- src/screens/share-chat/TextScene.tsx | 2 ++ src/toast/index.ts | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/chat/DividerMessageView.tsx b/src/components/chat/DividerMessageView.tsx index 535af1c..8191d0a 100644 --- a/src/components/chat/DividerMessageView.tsx +++ b/src/components/chat/DividerMessageView.tsx @@ -1,3 +1,4 @@ +import { hapticSoft } from '../../haptic' import { dimensions } from '../../res/dimensions' import { useThemeScheme } from '../../themes/hooks' import { ChatMessage } from '../../types' @@ -53,7 +54,10 @@ export function AppDividerView(props: AppDividerView) { tintTypo="tint2" name="share" disabled={shareDisabled} - onPress={() => onSharePress(message, index)} + onPress={() => { + hapticSoft() + onSharePress(message, index) + }} /> ) diff --git a/src/screens/share-chat/ShotScene.tsx b/src/screens/share-chat/ShotScene.tsx index 31b416c..7c44209 100644 --- a/src/screens/share-chat/ShotScene.tsx +++ b/src/screens/share-chat/ShotScene.tsx @@ -1,7 +1,7 @@ import { SvgIconName } from '../../components/SvgIcon' import { AssistantMessageView } from '../../components/chat/AssistantMessageView' import { UserMessageView } from '../../components/chat/UserMessageView' -import { hapticSuccess } from '../../haptic' +import { hapticSoft, hapticSuccess, hapticWarning } from '../../haptic' import { saveImageToAlbum } from '../../manager/album-manager' import { useShowChatAvatarPref } from '../../preferences/storages' import { print } from '../../printer' @@ -40,13 +40,15 @@ export function ShotScene(props: ShotSceneProps): JSX.Element { if (!viewShotRef.current || !viewShotRef.current.capture) { return } + hapticSoft() const tag = await viewShotRef.current.capture() print('Save to Album', { tag }) const path = await saveImageToAlbum(tag) - hapticSuccess() toast('success', t('Save to album success'), path ?? '') + hapticSuccess() } catch (e) { toast('danger', t('Save to album error'), '') + hapticWarning() } } @@ -68,6 +70,7 @@ export function ShotScene(props: ShotSceneProps): JSX.Element { fontSize={fontSize} message={item} showChatAvatar={showChatAvatar} + colouredContextMessage={false} /> {renderItemSeparator()} @@ -82,6 +85,7 @@ export function ShotScene(props: ShotSceneProps): JSX.Element { fontSize={fontSize} message={item} showChatAvatar={showChatAvatar} + colouredContextMessage={false} /> {renderItemSeparator()} diff --git a/src/screens/share-chat/TextScene.tsx b/src/screens/share-chat/TextScene.tsx index 4691a7d..06e02ce 100644 --- a/src/screens/share-chat/TextScene.tsx +++ b/src/screens/share-chat/TextScene.tsx @@ -1,3 +1,4 @@ +import { hapticSoft } from '../../haptic' import { colors } from '../../res/colors' import { dimensions } from '../../res/dimensions' import { stylez } from '../../res/stylez' @@ -58,6 +59,7 @@ export function TextScene(props: TextSceneProps): JSX.Element { { + hapticSoft() Clipboard.setString(text) toast('success', t('Copied to clipboard'), text) }} diff --git a/src/toast/index.ts b/src/toast/index.ts index 4e13488..00bee81 100644 --- a/src/toast/index.ts +++ b/src/toast/index.ts @@ -15,6 +15,7 @@ export function toast(type: Type, title: string, content: string, onPress?: () = ? content : `${content.substring(0, MAX_LENGTH_OF_CONTENT)}...` Toast.show({ + autoClose: 1800, type: TYPE_MAP[type], title, textBody,