Skip to content

Commit

Permalink
Merge branch 'develop' into YV-47-alt
Browse files Browse the repository at this point in the history
  • Loading branch information
jorbuedo committed Dec 5, 2024
2 parents 65a17fb + 918273d commit 64fb1f9
Show file tree
Hide file tree
Showing 48 changed files with 3,180 additions and 1,295 deletions.
19 changes: 17 additions & 2 deletions apps/wallet-mobile/src/components/Warning/Warning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ import {Space} from '../Space/Space'
type Props = {
content: ReactNode
iconSize?: number
title?: string
}

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

return (
<View style={styles.notice}>
<Icon.Info size={iconSize} color={colors.yellow} />
<View style={styles.titleContainer}>
<Icon.Info size={iconSize} color={colors.yellow} />

<Space width="sm" />

<Text style={styles.title}>{title}</Text>
</View>

<Space height="sm" />

Expand All @@ -36,6 +43,14 @@ const useStyles = () => {
...atoms.body_2_md_regular,
color: color.gray_max,
},
titleContainer: {
...atoms.flex_row,
...atoms.align_center,
},
title: {
color: color.text_gray_max,
...atoms.body_2_md_medium,
},
})

const colors = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ const getTimestamps = (timeInterval: TokenChartInterval) => {
}[timeInterval ?? TokenChartInterval.DAY]

const step = (now - from) / resolution
return Array.from({length: resolution}, (_, i) => from + Math.round(step * i))
const spread = Array.from({length: resolution}, (_, i) => from + Math.round(step * i))
spread.push(now)
return spread
}

const ptTicker = networkConfigs[Chain.Network.Mainnet].primaryTokenInfo.ticker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {useFocusEffect} from '@react-navigation/native'
import {FlashList} from '@shopify/flash-list'
import {infoExtractName, isPrimaryToken} from '@yoroi/portfolio'
import {useTheme} from '@yoroi/theme'
import {Chain, Portfolio} from '@yoroi/types'
import * as React from 'react'
import {FlatList, StyleSheet, Text, View} from 'react-native'
import {StyleSheet, Text, View} from 'react-native'

import {Spacer} from '../../../../../components/Spacer/Spacer'
import {useMetrics} from '../../../../../kernel/metrics/metricsManager'
Expand Down Expand Up @@ -90,6 +91,22 @@ export const PortfolioWalletTokenList = () => {

const isPreprod = network === Chain.Network.Preprod

const [loadedTokens, setLoadedTokens] = React.useState(getListTokens.slice(0, batchSize))
const [currentIndex, setCurrentIndex] = React.useState(batchSize)

React.useEffect(() => {
setLoadedTokens(getListTokens.slice(0, currentIndex + batchSize))
setCurrentIndex(currentIndex + batchSize)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tokensList]) // must be tokensList

const handleOnEndReached = React.useCallback(() => {
if (currentIndex >= getListTokens.length) return
const nextBatch = getListTokens.slice(currentIndex, currentIndex + batchSize)
setLoadedTokens([...loadedTokens, ...nextBatch])
setCurrentIndex(currentIndex + batchSize)
}, [currentIndex, getListTokens, loadedTokens])

const renderFooterList = () => {
if (isSearching) return null
if (isLoading) {
Expand Down Expand Up @@ -126,8 +143,8 @@ export const PortfolioWalletTokenList = () => {

return (
<View style={styles.root}>
<FlatList
data={getListTokens}
<FlashList
data={loadedTokens}
ListHeaderComponent={
<HeadingList
isShowBalanceCard={!isSearching}
Expand All @@ -141,6 +158,9 @@ export const PortfolioWalletTokenList = () => {
renderItem={({item}) => <TokenBalanceItem amount={item} />}
contentContainerStyle={styles.container}
ListEmptyComponent={() => <TokenEmptyList />}
onEndReached={handleOnEndReached}
onEndReachedThreshold={0.5}
estimatedItemSize={72}
/>
</View>
)
Expand Down Expand Up @@ -185,6 +205,8 @@ const SkeletonItem = () => {
)
}

const batchSize = 50

const useStyles = () => {
const {atoms, color} = useTheme()
const styles = StyleSheet.create({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ export const useOnConfirm = ({
const navigateTo = useNavigateTo()

const handleOnSuccess = (signedTx: YoroiSignedTx) => {
onSuccess?.(signedTx)
if (onSuccess) {
onSuccess(signedTx)
return
}
navigateTo.showSubmittedTxScreen()
}
const handleOnError = () => {
onError?.()
if (onError) {
onError()
return
}
navigateTo.showFailedTxScreen()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ export const useStrings = () => {
operationsLabel: intl.formatMessage(messages.operationsLabel),
policyIdLabel: intl.formatMessage(messages.policyIdLabel),
createdBy: intl.formatMessage(messages.createdBy),
operationsLogTitle: intl.formatMessage(messages.operationsLogTitle),
operationsLogWarningText: intl.formatMessage(messages.operationsLogWarningText),
operationsLogWarningTitle: intl.formatMessage(messages.operationsLogWarningTitle),
}
}

Expand Down Expand Up @@ -309,6 +312,18 @@ const messages = defineMessages({
id: 'txReview.operations.selectAbstain',
defaultMessage: '!!!Select abstain',
},
operationsLogTitle: {
id: 'txReview.operations.log.title',
defaultMessage: '!!!Operations log',
},
operationsLogWarningTitle: {
id: 'txReview.operations.warning.title',
defaultMessage: '!!!Unusual operations detected',
},
operationsLogWarningText: {
id: 'txReview.operations.warning.text',
defaultMessage: '!!!Please check the operations log before confirming this transaction.',
},
selectNoConfidence: {
id: 'txReview.operations.selectNoConfidence',
defaultMessage: '!!!Select no confidence',
Expand Down
Loading

0 comments on commit 64fb1f9

Please sign in to comment.