@@ -21,12 +21,12 @@ import { useSceneScrollHandler } from '../../state/SceneScrollState'
2121import { useDispatch , useSelector } from '../../types/reactRedux'
2222import { NavigationBase , WalletsTabSceneProps } from '../../types/routerTypes'
2323import { coinrankListData , infoServerData } from '../../util/network'
24- import { calculateSpamThreshold , convertNativeToDenomination , darkenHexColor , unixToLocaleDateTime , zeroString } from '../../util/utils'
24+ import { calculateSpamThreshold , convertNativeToDenomination , darkenHexColor , zeroString } from '../../util/utils'
2525import { EdgeCard } from '../cards/EdgeCard'
2626import { InfoCardCarousel } from '../cards/InfoCardCarousel'
2727import { SwipeChart } from '../charts/SwipeChart'
2828import { AccentColors } from '../common/DotsBackground'
29- import { EdgeAnim , fadeInDown10 , MAX_LIST_ITEMS_ANIM } from '../common/EdgeAnim'
29+ import { fadeInDown10 } from '../common/EdgeAnim'
3030import { SceneWrapper } from '../common/SceneWrapper'
3131import { SectionHeader as SectionHeaderUi4 } from '../common/SectionHeader'
3232import { withWallet } from '../hoc/withWallet'
@@ -35,7 +35,7 @@ import { BuyCrypto } from '../themed/BuyCrypto'
3535import { EdgeText , Paragraph } from '../themed/EdgeText'
3636import { ExplorerCard } from '../themed/ExplorerCard'
3737import { SearchFooter } from '../themed/SearchFooter'
38- import { EmptyLoader , SectionHeader , SectionHeaderCentered } from '../themed/TransactionListComponents'
38+ import { EmptyLoader , SectionHeaderCentered } from '../themed/TransactionListComponents'
3939import { TransactionListRow } from '../themed/TransactionListRow'
4040import { 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 = { listItems . length === 0 ? null : 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
407370const getStyles = cacheStyles ( ( ) => ( {
408371 flatList : {
409- overflow : 'visible' ,
410- flexShrink : 0
372+ flex : 1
373+ } ,
374+ txRow : {
375+ paddingVertical : 0
411376 }
412377} ) )
0 commit comments