商城頁面-MerchandiseGrid
使用
numColumns
為 2 欄
再來用flex 0.5
的方式把list item 做平分
壓上折扣UI
Image 上 疊加Text
對Text 設定背景色與字體顏色
自製TabBar
利用ScrollView 做水平捲移動,並關掉ScrollIndictator...
在裡面包裹
TouhableHighlight
做選中處理 ,可以是更改背景色或是加上框線根據儲存的state 來得知有無被按下,並設定框線
使用`contentContanierStyle 教item 排列設為flexDirection:'row'
Styles v.s ContentContainerStyle
ScrollView 與 FlatList 都利用 contentContainer. height > style.height 來判斷是否需要scrollBar
所以不能把
contentContainerStyle
設為{flex: 1}
,否則失去scroll 效果e.g 畫面高長的width 為 640,但contentContainer 因item 超過範圍而變成 1024,這時把contentContainerStyle 設為 {flex: 1},則contentContainer 的width 變為 640 ,導致無法進行scroll
偵測程式是在背景(background)還是前景(foreground)
在商品總覽中,利用此項機制,當使用者切回App時,重新刷新一次list,讓使用者看到最新的商品。
在componentDidMount 進行註冊
由於該listener 是從Native 曾回呼的,所以當該listener 發生錯誤後,在開發時會導致App Crash 而非 JS 層 的unhandled error
加入PullToRefresh 的機制
新增
refreshing
與onRefresh
屬性在即將開始刷新之前,變更
this.state.refreshing
再刷新之後,再變更
this.state.refreshing
為false因為是測試資料,利用shuffle的方式改變測試資料的順序,模擬資料不同的情況
使用onEndReached 實現Pagination
API (pageNum: 1, numberOfItems: 20)
nextPageToken, maxResult
使用
onEndReachThreshold
(0 ~ 1, 0.5 )
NetInfo 偵測網路狀態 與 ListEmptyView
ListEmptyView的三種狀態
Wifi/3G 未連上
連上了,但獲取不到資料
本來就是空的
設置NetInfo 偵測網路狀態並在
ListEmptyComponent
加入自製EmptyView
但是emptyView 的文字居然沒有垂直置中...
Center EmptyView's PR which intend to release react-native 0.56
自己來
當data 是空的時候,隱藏FlatList,然後切換至EmptyView
Last updated
Was this helpful?