Skip to content

Commit

Permalink
ux: add haptic feedback of share dialogue
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuanghongji committed Jun 7, 2023
1 parent 354218f commit 19fed82
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/components/chat/DividerMessageView.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { hapticSoft } from '../../haptic'
import { dimensions } from '../../res/dimensions'
import { useThemeScheme } from '../../themes/hooks'
import { ChatMessage } from '../../types'
Expand Down Expand Up @@ -53,7 +54,10 @@ export function AppDividerView(props: AppDividerView) {
tintTypo="tint2"
name="share"
disabled={shareDisabled}
onPress={() => onSharePress(message, index)}
onPress={() => {
hapticSoft()
onSharePress(message, index)
}}
/>
</View>
)
Expand Down
8 changes: 6 additions & 2 deletions src/screens/share-chat/ShotScene.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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()
}
}

Expand All @@ -68,6 +70,7 @@ export function ShotScene(props: ShotSceneProps): JSX.Element {
fontSize={fontSize}
message={item}
showChatAvatar={showChatAvatar}
colouredContextMessage={false}
/>
{renderItemSeparator()}
</Fragment>
Expand All @@ -82,6 +85,7 @@ export function ShotScene(props: ShotSceneProps): JSX.Element {
fontSize={fontSize}
message={item}
showChatAvatar={showChatAvatar}
colouredContextMessage={false}
/>
{renderItemSeparator()}
</Fragment>
Expand Down
2 changes: 2 additions & 0 deletions src/screens/share-chat/TextScene.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { hapticSoft } from '../../haptic'
import { colors } from '../../res/colors'
import { dimensions } from '../../res/dimensions'
import { stylez } from '../../res/stylez'
Expand Down Expand Up @@ -58,6 +59,7 @@ export function TextScene(props: TextSceneProps): JSX.Element {
<ShareButton
text={t('Copy to Clipboard')}
onPress={() => {
hapticSoft()
Clipboard.setString(text)
toast('success', t('Copied to clipboard'), text)
}}
Expand Down
1 change: 1 addition & 0 deletions src/toast/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 19fed82

Please sign in to comment.