Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wallet-mobile): address details styling #3759

Merged
merged 6 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ export const ClipboardProvider = ({children}: Props) => {
const [copied, setCopied] = React.useState<CopiedState | null>(null)
const {height, width} = useWindowDimensions()
const copy: ClipboardContext['copy'] = ({text, feedback = 'Copied', event}) => {
const baseLocationX = (event?.nativeEvent.pageX ?? width * 0.5) - feedback.length * 4
const maxX = width - 20 - feedback.length * 8
const minX = 20 + feedback.length * 8
const locationX = Math.min(Math.max(baseLocationX, minX), maxX)

Clipboard.setString(text)
setCopied({
feedback,
locationY: event ? event.nativeEvent.pageY - 50 : height * 0.85,
locationX: (event?.nativeEvent.pageX ?? width * 0.5) - feedback.length * 4,
locationX,
})
setTimeout(() => setCopied(null), FEEDBACK_TIMEOUT)
}
Expand Down
30 changes: 16 additions & 14 deletions apps/wallet-mobile/src/components/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useTheme} from '@yoroi/theme'
import React from 'react'
import {StyleProp, ViewStyle} from 'react-native'
import {StyleProp, View, ViewStyle} from 'react-native'

import {Icon} from '../components/Icon'
import {Button, ButtonType} from './Button/Button'
Expand All @@ -15,22 +15,24 @@ type CopyButtonProps = {
message?: string
}

export const CopyButton = ({title, value, onCopy, message}: CopyButtonProps) => {
export const CopyButton = ({title, value, onCopy, message, style}: CopyButtonProps) => {
const {isCopying, copy} = useCopy()
const {atoms} = useTheme()

return (
<Button
type={ButtonType.SecondaryText}
fontOverride={atoms.body_1_lg_regular}
style={{...atoms.p_0, ...atoms.justify_between}}
title={title}
icon={isCopying ? Icon.CopySuccess : Icon.Copy}
rightIcon
onPress={(event) => {
copy({text: value, feedback: message, event})
onCopy?.()
}}
/>
<View style={style}>
<Button
type={ButtonType.SecondaryText}
fontOverride={atoms.body_1_lg_regular}
style={{...atoms.p_0, ...atoms.justify_between, flexGrow: 0}}
title={title}
icon={isCopying ? Icon.CopySuccess : Icon.Copy}
rightIcon
onPress={(event) => {
copy({text: value, feedback: message, event})
onCopy?.()
}}
/>
</View>
)
}
Loading