@@ -54,15 +54,17 @@ function SearchPage() {
5454 const keyword = useRef ( '' ) ;
5555
5656 const dispatch = useDispatch ( ) ;
57- const {
58- showLoading,
59- showKeyWorkContainer,
60- keyWordList,
61- dataList,
62- refreshState,
63- nextPageUrl,
64- total,
65- } = useSelector ( mapStateToProps , shallowEqual ) ;
57+
58+ const { showLoading} = useSelector ( mapStateToProps , shallowEqual ) ;
59+
60+ const { showKeyWorkContainer} = useSelector ( mapStateToProps , shallowEqual ) ;
61+
62+ const { keyWordList} = useSelector ( mapStateToProps , shallowEqual ) ;
63+
64+ const { dataList, refreshState, nextPageUrl, total} = useSelector (
65+ mapStateToProps ,
66+ shallowEqual ,
67+ ) ;
6668
6769 useEffect ( ( ) => {
6870 dispatch ( {
@@ -141,42 +143,6 @@ function SearchPage() {
141143 return < SearchVideoComponent item = { item } /> ;
142144 } ;
143145
144- const ContentContainer = ( ) => {
145- if ( showLoading ) {
146- return (
147- < Spinner
148- visible = { showLoading }
149- textContent = { 'Loading...' }
150- textStyle = { styles . spinnerTextStyle }
151- />
152- ) ;
153- }
154- if ( dataList == null || dataList . length === 0 ) {
155- return < KeyWordContainerOrEmpty /> ;
156- }
157- return (
158- < View style = { styles . searchVideoContainer } >
159- < Text style = { styles . searchKey } >
160- — 「{ keyword . current } 」搜索结果共{ total } 个 —
161- </ Text >
162- < RefreshListView
163- data = { dataList }
164- keyExtractor = { keyExtractor }
165- renderItem = { renderItem }
166- refreshState = { refreshState }
167- onHeaderRefresh = { onHeaderRefresh }
168- onFooterRefresh = { onFooterRefresh }
169- showsVerticalScrollIndicator = { false }
170- getItemLayout = { ( _data : Item , index : number ) => ( {
171- length : FeedHeight ,
172- offset : FeedHeight * index ,
173- index,
174- } ) }
175- />
176- </ View >
177- ) ;
178- } ;
179-
180146 const KeyWordContainerOrEmpty = ( ) => {
181147 if ( showKeyWorkContainer ) {
182148 return (
@@ -247,7 +213,44 @@ function SearchPage() {
247213 </ View >
248214 < SearchView />
249215 </ View >
250- < ContentContainer />
216+ { showLoading && (
217+ < >
218+ < Spinner
219+ visible = { showLoading }
220+ textContent = { 'Loading...' }
221+ textStyle = { styles . spinnerTextStyle }
222+ />
223+ </ >
224+ ) }
225+ { dataList == null ||
226+ ( dataList . length === 0 && (
227+ < >
228+ < KeyWordContainerOrEmpty />
229+ </ >
230+ ) ) }
231+ { total > 0 && (
232+ < >
233+ < View style = { styles . searchVideoContainer } >
234+ < Text style = { styles . searchKey } >
235+ — 「{ keyword . current } 」搜索结果共{ total } 个 —
236+ </ Text >
237+ < RefreshListView
238+ data = { dataList }
239+ keyExtractor = { keyExtractor }
240+ renderItem = { renderItem }
241+ refreshState = { refreshState }
242+ onHeaderRefresh = { onHeaderRefresh }
243+ onFooterRefresh = { onFooterRefresh }
244+ showsVerticalScrollIndicator = { false }
245+ getItemLayout = { ( _data : Item , index : number ) => ( {
246+ length : FeedHeight ,
247+ offset : FeedHeight * index ,
248+ index,
249+ } ) }
250+ />
251+ </ View >
252+ </ >
253+ ) }
251254 </ SafeAreaView >
252255 ) ;
253256}
0 commit comments