Skip to content

Commit 2cd3668

Browse files
committed
WIP
1 parent 8352b02 commit 2cd3668

File tree

5 files changed

+356
-68
lines changed

5 files changed

+356
-68
lines changed

src/components/Main.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ import { SweepPrivateKeyProcessingScene as SweepPrivateKeyProcessingSceneCompone
126126
import { SweepPrivateKeySelectCryptoScene as SweepPrivateKeySelectCryptoSceneComponent } from './scenes/SweepPrivateKeySelectCryptoScene'
127127
import { TransactionDetailsScene as TransactionDetailsSceneComponent } from './scenes/TransactionDetailsScene'
128128
import { TransactionList as TransactionListComponent } from './scenes/TransactionListScene'
129+
import { TransactionList2 as TransactionList2Component } from './scenes/TransactionListScene2'
129130
import { TransactionsExportScene as TransactionsExportSceneComponent } from './scenes/TransactionsExportScene'
130131
import { UpgradeUsernameScene as UpgradeUsernameSceneComponent } from './scenes/UpgradeUsernameScreen'
131132
import { WalletListScene as WalletListSceneComponent } from './scenes/WalletListScene'
@@ -218,6 +219,7 @@ const SwapSettingsScene = ifLoggedIn(SwapSettingsSceneComponent)
218219
const SwapSuccessScene = ifLoggedIn(SwapSuccessSceneComponent)
219220
const TransactionDetailsScene = ifLoggedIn(TransactionDetailsSceneComponent)
220221
const TransactionList = ifLoggedIn(TransactionListComponent)
222+
const TransactionList2 = ifLoggedIn(TransactionList2Component)
221223
const TransactionsExportScene = ifLoggedIn(TransactionsExportSceneComponent)
222224
const WalletListScene = ifLoggedIn(WalletListSceneComponent)
223225
const WalletRestoreScene = ifLoggedIn(WalletRestoreSceneComponent)
@@ -276,6 +278,13 @@ const EdgeWalletsTabScreen = () => {
276278
headerTitle: () => <ParamHeaderTitle<'transactionList'> fromParams={params => params.walletName} />
277279
}}
278280
/>
281+
<WalletsStack.Screen
282+
name="transactionList2"
283+
component={TransactionList2}
284+
options={{
285+
headerTitle: () => <ParamHeaderTitle<'transactionList2'> fromParams={params => params.walletName} />
286+
}}
287+
/>
279288
</WalletsStack.Navigator>
280289
)
281290
}
@@ -781,6 +790,13 @@ const EdgeAppStack = () => {
781790
headerTitle: () => <TransactionDetailsTitle />
782791
}}
783792
/>
793+
<WalletsStack.Screen
794+
name="transactionList2"
795+
component={TransactionList2}
796+
options={{
797+
headerTitle: () => <ParamHeaderTitle<'transactionList2'> fromParams={params => params.walletName} />
798+
}}
799+
/>
784800
<AppStack.Screen
785801
name="transactionsExport"
786802
component={TransactionsExportScene}

src/components/scenes/TransactionListScene.tsx

Lines changed: 26 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import { useSceneScrollHandler } from '../../state/SceneScrollState'
2121
import { useDispatch, useSelector } from '../../types/reactRedux'
2222
import { NavigationBase, WalletsTabSceneProps } from '../../types/routerTypes'
2323
import { coinrankListData, infoServerData } from '../../util/network'
24-
import { calculateSpamThreshold, convertNativeToDenomination, darkenHexColor, unixToLocaleDateTime, zeroString } from '../../util/utils'
24+
import { calculateSpamThreshold, convertNativeToDenomination, darkenHexColor, zeroString } from '../../util/utils'
2525
import { EdgeCard } from '../cards/EdgeCard'
2626
import { InfoCardCarousel } from '../cards/InfoCardCarousel'
2727
import { SwipeChart } from '../charts/SwipeChart'
2828
import { AccentColors } from '../common/DotsBackground'
29-
import { EdgeAnim, fadeInDown10, MAX_LIST_ITEMS_ANIM } from '../common/EdgeAnim'
29+
import { fadeInDown10 } from '../common/EdgeAnim'
3030
import { SceneWrapper } from '../common/SceneWrapper'
3131
import { SectionHeader as SectionHeaderUi4 } from '../common/SectionHeader'
3232
import { withWallet } from '../hoc/withWallet'
@@ -35,7 +35,7 @@ import { BuyCrypto } from '../themed/BuyCrypto'
3535
import { EdgeText, Paragraph } from '../themed/EdgeText'
3636
import { ExplorerCard } from '../themed/ExplorerCard'
3737
import { SearchFooter } from '../themed/SearchFooter'
38-
import { EmptyLoader, SectionHeader, SectionHeaderCentered } from '../themed/TransactionListComponents'
38+
import { EmptyLoader, SectionHeaderCentered } from '../themed/TransactionListComponents'
3939
import { TransactionListRow } from '../themed/TransactionListRow'
4040
import { TransactionListTop } from '../themed/TransactionListTop'
4141

@@ -101,11 +101,7 @@ function TransactionListComponent(props: Props) {
101101
}, [exchangeDenom, exchangeRate, spamFilterOn])
102102

103103
// Transaction list state machine:
104-
const {
105-
transactions,
106-
atEnd,
107-
requestMore: handleScrollEnd
108-
} = useTransactionList(wallet, tokenId, {
104+
const { transactions, requestMore: handleScrollEnd } = useTransactionList(wallet, tokenId, {
109105
searchString: isSearching ? searchText : undefined,
110106
spamThreshold
111107
})
@@ -116,36 +112,10 @@ function TransactionListComponent(props: Props) {
116112
const listItems = React.useMemo(() => {
117113
if (isTransactionListUnsupported) return []
118114

119-
let lastSection = ''
120-
const out: ListItem[] = []
121-
for (const tx of transactions) {
122-
// Create a new section header if we need one:
123-
const { date } = unixToLocaleDateTime(tx.date)
124-
if (date !== lastSection) {
125-
out.push(date)
126-
lastSection = date
127-
}
128-
129-
// Add the transaction to the list:
130-
out.push(tx)
131-
}
132-
133-
// If we are still loading, add a spinner at the end:
134-
if (!atEnd) out.push(null)
135-
136-
return out
137-
}, [atEnd, isTransactionListUnsupported, transactions])
138-
139-
// TODO: Comment out sticky header indices until we figure out how to
140-
// give the headers a background only when they're sticking.
141-
// Figure out where the section headers are located:
142-
// const stickyHeaderIndices = React.useMemo<number[]>(() => {
143-
// const out: number[] = []
144-
// for (let i = 0; i < listItems.length; ++i) {
145-
// if (typeof listItems[i] === 'string') out.push(i)
146-
// }
147-
// return out
148-
// }, [listItems])
115+
// Take only the 5 most recent transactions
116+
const recentTransactions = transactions.slice(0, 5)
117+
return recentTransactions.length > 0 ? recentTransactions : []
118+
}, [isTransactionListUnsupported, transactions])
149119

150120
// ---------------------------------------------------------------------------
151121
// Side-Effects
@@ -254,27 +224,35 @@ function TransactionListComponent(props: Props) {
254224
)}
255225
<SectionHeaderUi4
256226
leftTitle={lstrings.transaction_list_recent_transactions}
257-
rightNode={lstrings.coin_rank_see_more}
258-
onRightPress={handlePressCoinRanking}
227+
rightNode={lstrings.see_all}
228+
onRightPress={() => navigation.navigate('transactionList2', route.params)}
259229
/>
230+
<EdgeCard sections>
231+
{listItems.map((tx: EdgeTransaction) => (
232+
<View key={tx.txid} style={styles.txRow}>
233+
<TransactionListRow navigation={navigation as NavigationBase} transaction={tx} wallet={wallet} noCard />
234+
</View>
235+
))}
236+
</EdgeCard>
260237
</>
261238
)
262239
}, [
263-
listItems.length,
240+
listItems,
264241
navigation,
265242
isSearching,
266243
tokenId,
267244
wallet,
268245
isLightAccount,
269246
pluginId,
270-
route.params.countryCode,
247+
route.params,
271248
screenWidth,
272249
assetId,
273250
displayName,
274251
handlePressCoinRanking,
275252
fiatRateFormat,
276253
currencyCode,
277-
fiatCurrencyCode
254+
fiatCurrencyCode,
255+
styles.txRow
278256
])
279257

280258
const emptyComponent = React.useMemo(() => {
@@ -292,19 +270,7 @@ function TransactionListComponent(props: Props) {
292270
return <EmptyLoader />
293271
}
294272

295-
const disableAnimation = index >= MAX_LIST_ITEMS_ANIM
296-
if (typeof item === 'string') {
297-
return (
298-
<EdgeAnim disableAnimation={disableAnimation} enter={{ type: 'fadeInDown', distance: 30 * (index + 1) }}>
299-
<SectionHeader title={item} />
300-
</EdgeAnim>
301-
)
302-
}
303-
return (
304-
<EdgeAnim disableAnimation={disableAnimation} enter={{ type: 'fadeInDown', distance: 30 * (index + 1) }}>
305-
<TransactionListRow navigation={navigation as NavigationBase} transaction={item} wallet={wallet} />
306-
</EdgeAnim>
307-
)
273+
return null // We're not using the FlatList rendering anymore
308274
})
309275

310276
const keyExtractor = useHandler((item: ListItem) => {
@@ -376,9 +342,6 @@ function TransactionListComponent(props: Props) {
376342
ListHeaderComponent={topArea}
377343
onEndReachedThreshold={0.5}
378344
renderItem={renderItem}
379-
// TODO: Comment out sticky header indices until we figure out how to
380-
// give the headers a background only when they're sticking.
381-
// stickyHeaderIndices={stickyHeaderIndices}
382345
onEndReached={handleScrollEnd}
383346
onScroll={handleScroll}
384347
scrollIndicatorInsets={SCROLL_INDICATOR_INSET_FIX}
@@ -406,7 +369,9 @@ export const TransactionList = withWallet(TransactionListComponent)
406369

407370
const getStyles = cacheStyles(() => ({
408371
flatList: {
409-
overflow: 'visible',
410-
flexShrink: 0
372+
flex: 1
373+
},
374+
txRow: {
375+
paddingVertical: 0
411376
}
412377
}))

0 commit comments

Comments
 (0)