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

feat(wallet-mobile): send feature new tx review #3643

Merged
merged 34 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1ed7023
feature(tx-review): initial commit
banklesss Sep 17, 2024
39f46eb
mere develop
banklesss Sep 17, 2024
22159a8
feat(tx-review): improvements
banklesss Sep 18, 2024
11d8bb0
Merge remote-tracking branch 'origin/develop' into feature/tx-review
banklesss Sep 18, 2024
7c43a30
feat(tx-review): add confirm tx to send funnel
banklesss Sep 20, 2024
cea677e
Merge remote-tracking branch 'origin/develop' into feature/tx-review
banklesss Sep 20, 2024
26eefda
Merge remote-tracking branch 'origin/develop' into feature/tx-review
banklesss Sep 20, 2024
d1c07bc
feat(tx-review): send feature
banklesss Sep 20, 2024
b6f418b
CR: update
banklesss Sep 22, 2024
81d472e
feature(tx-details): remove legacy confirm tx screens for send funnel
banklesss Sep 22, 2024
daecf73
feature(tx-details): remove legacy confirm tx screens for send funnel
banklesss Sep 22, 2024
6f48aa8
Update apps/wallet-mobile/src/features/ReviewTx/common/hooks/useAddre…
banklesss Sep 22, 2024
4b177f5
Update apps/wallet-mobile/src/features/ReviewTx/common/hooks/useForma…
banklesss Sep 22, 2024
a4d6675
Update apps/wallet-mobile/src/features/ReviewTx/common/hooks/useForma…
banklesss Sep 22, 2024
dc4a40e
CR: update
banklesss Sep 22, 2024
fa293e0
Revert "feature(tx-details): remove legacy confirm tx screens for sen…
banklesss Sep 22, 2024
377299e
Revert "feature(tx-details): remove legacy confirm tx screens for sen…
banklesss Sep 22, 2024
e4972ab
CR: update
banklesss Sep 22, 2024
b7abc7a
Merge branch 'develop' into feature/tx-review
banklesss Sep 24, 2024
ba2058d
CR: updates
banklesss Sep 24, 2024
f715a2a
CR: updates
banklesss Sep 24, 2024
9a13ff9
Merge branch 'develop' into feature/tx-review
banklesss Sep 24, 2024
65c1ce4
Merge remote-tracking branch 'origin/develop' into feature/tx-review
banklesss Sep 25, 2024
02d93af
Merge branch 'develop' into feature/tx-review
banklesss Sep 26, 2024
e643e9a
Merge remote-tracking branch 'origin/develop' into feature/tx-review
banklesss Oct 2, 2024
81123b3
Merge remote-tracking branch 'origin/develop' into feature/tx-review
banklesss Oct 4, 2024
e5f1c7f
Merge branch 'develop' into feature/tx-review
banklesss Oct 7, 2024
35ea23e
merge develop
banklesss Oct 8, 2024
6bb8f5e
Merge remote-tracking branch 'origin/develop' into feature/tx-review
banklesss Oct 9, 2024
d4f5c9e
merge develop
banklesss Oct 9, 2024
db95b65
Update apps/wallet-mobile/src/components/Info/Info.tsx
banklesss Oct 10, 2024
0a46902
Update apps/wallet-mobile/src/components/Warning/Warning.tsx
banklesss Oct 10, 2024
0e1844f
Merge branch 'develop' into feature/tx-review
banklesss Oct 10, 2024
37ee230
CR: update
banklesss Oct 10, 2024
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
3 changes: 3 additions & 0 deletions apps/wallet-mobile/src/WalletNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {useLinksShowActionResult} from './features/Links/common/useLinksShowActi
import {MenuNavigator} from './features/Menu/Menu'
import {PortfolioNavigator} from './features/Portfolio/PortfolioNavigator'
import {CatalystNavigator} from './features/RegisterCatalyst/CatalystNavigator'
import {ReviewTxNavigator} from './features/ReviewTx/ReviewTxNavigator'
import {SearchProvider} from './features/Search/SearchContext'
import {SettingsScreenNavigator} from './features/Settings'
import {NetworkTag} from './features/Settings/ChangeNetwork/NetworkTag'
Expand Down Expand Up @@ -260,6 +261,8 @@ export const WalletNavigator = () => {

<Stack.Screen name="settings" options={{headerShown: false}} component={SettingsScreenNavigator} />

<Stack.Screen name="review-tx-routes" options={{headerShown: false}} component={ReviewTxNavigator} />

<Stack.Screen
name="voting-registration"
options={{headerShown: false}}
Expand Down
7 changes: 4 additions & 3 deletions apps/wallet-mobile/src/components/Icon/Direction.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ThemedPalette, useTheme} from '@yoroi/theme'
import React from 'react'
import {StyleSheet, View} from 'react-native'
import {StyleSheet, View, ViewStyle} from 'react-native'

import {TransactionDirection, TransactionInfo} from '../../yoroi-wallets/types/other'
import {Received} from '../Icon/Received'
Expand All @@ -11,17 +11,18 @@ import {MultiParty} from './MultiParty'
type Props = {
transaction: TransactionInfo
size?: number
containerStyle?: ViewStyle
}

export const Direction = ({transaction, size = defaultSize}: Props) => {
export const Direction = ({transaction, size = defaultSize, containerStyle}: Props) => {
const {color} = useTheme()
const {direction} = transaction

const iconStyles = styleMap(color)[direction]
const IconComponent = iconMap[direction]

return (
<View style={[styles.icon, {backgroundColor: iconStyles?.background}]}>
<View style={[styles.icon, {backgroundColor: iconStyles?.background}, containerStyle]}>
<IconComponent color={iconStyles?.icon} size={iconStyles.size ?? size} />
</View>
)
Expand Down
16 changes: 12 additions & 4 deletions apps/wallet-mobile/src/components/Warning/Warning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import {StyleSheet, Text, View} from 'react-native'
import {Icon} from '../Icon'
import {Space} from '../Space/Space'

type Props = {content: ReactNode; iconSize?: number}
type Props = {
content: ReactNode
iconSize?: number
blue?: boolean
banklesss marked this conversation as resolved.
Show resolved Hide resolved
}

export const Warning = ({content, iconSize = 30}: Props) => {
export const Warning = ({content, iconSize = 30, blue = false}: Props) => {
const {styles, colors} = useStyles()

return (
<View style={styles.notice}>
<Icon.Info size={iconSize} color={colors.yellow} />
<View style={[styles.notice, blue && styles.blueNotice]}>
<Icon.Info size={iconSize} color={blue ? colors.blue : colors.yellow} />
banklesss marked this conversation as resolved.
Show resolved Hide resolved

<Space height="sm" />

Expand All @@ -29,6 +33,9 @@ const useStyles = () => {
padding: 12,
banklesss marked this conversation as resolved.
Show resolved Hide resolved
borderRadius: 8,
},
blueNotice: {
backgroundColor: color.sys_cyan_100,
},
text: {
...atoms.body_2_md_regular,
color: color.gray_max,
banklesss marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -37,6 +44,7 @@ const useStyles = () => {

const colors = {
yellow: color.sys_orange_500,
blue: color.primary_500,
}

return {colors, styles}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ const useConnectorPromptRootKey = () => {
}, [promptRootKey])
}

const useSignTxWithHW = () => {
export const useSignTxWithHW = () => {
const {confirmHWConnection, closeModal} = useConfirmHWConnectionModal()
const {wallet, meta} = useSelectedWallet()

Expand Down
36 changes: 36 additions & 0 deletions apps/wallet-mobile/src/features/ReviewTx/ReviewTxNavigator.tsx
banklesss marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {createStackNavigator} from '@react-navigation/stack'
import {Atoms, ThemedPalette, useTheme} from '@yoroi/theme'
import React from 'react'

import {Boundary} from '../../components/Boundary/Boundary'
import {defaultStackNavigationOptions, ReviewTxRoutes} from '../../kernel/navigation'
import {useStrings} from './common/hooks/useStrings'
import {ReviewTxScreen} from './useCases/ReviewTxScreen/ReviewTxScreen'

export const Stack = createStackNavigator<ReviewTxRoutes>()

export const ReviewTxNavigator = () => {
const {atoms, color} = useTheme()
const strings = useStrings()

return (
<Stack.Navigator
screenOptions={{
...screenOptions(atoms, color),
}}
>
<Stack.Screen name="review-tx" options={{title: strings.title}}>
{() => (
<Boundary>
<ReviewTxScreen />
</Boundary>
)}
</Stack.Screen>
</Stack.Navigator>
)
}

const screenOptions = (atoms: Atoms, color: ThemedPalette) => ({
...defaultStackNavigationOptions(atoms, color),
gestureEnabled: true,
})
74 changes: 74 additions & 0 deletions apps/wallet-mobile/src/features/ReviewTx/common/Address.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import {useTheme} from '@yoroi/theme'
import * as React from 'react'
import {StyleSheet, Text, TextStyle, TouchableOpacity, View} from 'react-native'

import {Icon} from '../../../components/Icon'
import {Space} from '../../../components/Space/Space'
import {useCopy} from '../../../hooks/useCopy'

export const Address = ({
address,
index,
textStyle,
multiline = false,
}: {
address: string
index?: number
textStyle?: TextStyle
multiline?: boolean
}) => {
const {styles, colors} = useStyles()
const [, copy] = useCopy()

return (
<View style={styles.address}>
<Text
style={[styles.addressText, textStyle]}
numberOfLines={!multiline ? 1 : undefined}
ellipsizeMode={!multiline ? 'middle' : undefined}
>
{address}
</Text>

{index !== undefined && (
<>
<Space width="sm" />

<Text style={styles.index}>{`#${index}`}</Text>

<Space width="sm" />
</>
)}

<TouchableOpacity onPress={() => copy(address)} activeOpacity={0.5}>
<Icon.Copy size={24} color={colors.copy} />
</TouchableOpacity>
</View>
)
}

const useStyles = () => {
const {atoms, color} = useTheme()
const styles = StyleSheet.create({
address: {
...atoms.flex_row,
...atoms.flex_row,
banklesss marked this conversation as resolved.
Show resolved Hide resolved
...atoms.justify_between,
},
addressText: {
...atoms.flex_1,
...atoms.body_2_md_regular,
color: color.gray_900,
banklesss marked this conversation as resolved.
Show resolved Hide resolved
},
index: {
...atoms.body_2_md_medium,
color: color.text_gray_medium,
},
})

const colors = {
copy: color.gray_900,
}

return {styles, colors} as const
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import {useTheme} from '@yoroi/theme'
import * as React from 'react'
import {Animated, LayoutAnimation, StyleSheet, Text, TouchableOpacity, View} from 'react-native'

import {Icon} from '../../../components/Icon'

export const CollapsibleSection = ({label, children}: {label: string; children: React.ReactNode}) => {
const {styles, colors} = useStyles()
const [isOpen, setIsOpen] = React.useState(false)
const animatedHeight = React.useRef(new Animated.Value(0)).current

const toggleSection = () => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
setIsOpen(!isOpen)
Animated.timing(animatedHeight, {
toValue: isOpen ? 0 : 1,
duration: 300,
useNativeDriver: false,
}).start()
}

return (
<>
<View style={styles.sectionHeader}>
<Text style={styles.sectionHeaderText}>{label}</Text>

<TouchableOpacity activeOpacity={0.5} onPress={toggleSection}>
<Icon.Chevron direction={isOpen ? 'up' : 'down'} size={28} color={colors.chevron} />
</TouchableOpacity>
</View>

<Animated.View
style={[
styles.childrenContainer,
{
maxHeight: animatedHeight.interpolate({
inputRange: [0, 1],
outputRange: [0, 1000],
}),
opacity: animatedHeight,
},
]}
>
{children}
</Animated.View>
</>
)
}

const useStyles = () => {
const {atoms, color} = useTheme()
const styles = StyleSheet.create({
sectionHeader: {
...atoms.flex_row,
...atoms.justify_between,
},
sectionHeaderText: {
...atoms.body_1_lg_medium,
color: color.gray_900,
banklesss marked this conversation as resolved.
Show resolved Hide resolved
},
childrenContainer: {
overflow: 'hidden',
},
})

const colors = {
chevron: color.gray_900,
}

return {styles, colors} as const
}
31 changes: 31 additions & 0 deletions apps/wallet-mobile/src/features/ReviewTx/common/Divider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {SpacingSize, useTheme} from '@yoroi/theme'
import * as React from 'react'
import {StyleSheet, View} from 'react-native'

import {Space} from '../../../components/Space/Space'

export const Divider = ({verticalSpace = 'none'}: {verticalSpace?: SpacingSize}) => {
const {styles} = useStyles()
return (
<>
<Space height={verticalSpace} />

<View style={styles.divider} />

<Space height={verticalSpace} />
</>
)
}

const useStyles = () => {
const {atoms, color} = useTheme()
const styles = StyleSheet.create({
divider: {
height: 1,
...atoms.align_stretch,
backgroundColor: color.gray_200,
},
})

return {styles} as const
}
76 changes: 76 additions & 0 deletions apps/wallet-mobile/src/features/ReviewTx/common/TokenItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import {useTheme} from '@yoroi/theme'
import * as React from 'react'
import {StyleSheet, Text, View} from 'react-native'

export const TokenItem = ({
isPrimaryToken = true,
isSent = true,
label,
}: {
isPrimaryToken?: boolean
isSent?: boolean
label: string
}) => {
const {styles} = useStyles()

if (!isSent)
return (
<View style={[styles.receivedTokenItem, !isPrimaryToken && styles.notPrimaryReceivedTokenItem]}>
<Text style={[styles.tokenReceivedItemText, !isPrimaryToken && styles.notPrimaryReceivedTokenItemText]}>
{label}
</Text>
</View>
)

return (
<View style={[styles.sentTokenItem, !isPrimaryToken && styles.notPrimarySentTokenItem]}>
<Text style={[styles.tokenSentItemText, !isPrimaryToken && styles.notPrimarySentTokenItemText]}>{label}</Text>
</View>
)
}

const useStyles = () => {
const {atoms, color} = useTheme()
const styles = StyleSheet.create({
sentTokenItem: {
...atoms.flex,
...atoms.flex_row,
...atoms.align_center,
...atoms.py_xs,
...atoms.px_md,
borderRadius: 8,
backgroundColor: color.primary_500,
},
receivedTokenItem: {
...atoms.flex,
...atoms.flex_row,
...atoms.align_center,
...atoms.py_xs,
...atoms.px_md,
borderRadius: 8,
backgroundColor: color.secondary_300,
},
tokenSentItemText: {
...atoms.body_2_md_regular,
color: color.white_static,
},
tokenReceivedItemText: {
...atoms.body_2_md_regular,
color: color.text_gray_max,
},
notPrimarySentTokenItem: {
backgroundColor: color.primary_100,
},
notPrimaryReceivedTokenItem: {
backgroundColor: color.secondary_100,
},
notPrimarySentTokenItemText: {
color: color.text_primary_medium,
},
notPrimaryReceivedTokenItemText: {
color: color.secondary_700,
},
})

return {styles} as const
}
Loading
Loading