Skip to content

Commit

Permalink
- [ ] [我的] 支持跟首页一样的页内搜索
Browse files Browse the repository at this point in the history
  • Loading branch information
czy0729 committed Nov 29, 2021
1 parent 00fe77a commit f32360e
Show file tree
Hide file tree
Showing 25 changed files with 530 additions and 230 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-03-13 05:15:36
* @Last Modified by: czy0729
* @Last Modified time: 2021-11-27 07:52:22
* @Last Modified time: 2021-11-29 09:45:15
*/
module.exports = {
root: true,
Expand All @@ -29,7 +29,7 @@ module.exports = {
eqeqeq: 0,
'no-unused-vars': ['error', { ignoreRestSiblings: true }],
'react/no-did-mount-set-state': 0,
'prefer-const': 1
'prefer-const': ['error', { ignoreReadBeforeAssign: true }]
}
}

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
auth/
dist/
gradle.properties
ios/
# ios/
node_modules/
src/constants/json/user.json
src/screens/user/zone/user.js
Expand Down
6 changes: 2 additions & 4 deletions App.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-03-30 19:25:19
* @Last Modified by: czy0729
* @Last Modified time: 2021-11-24 07:56:41
* @Last Modified time: 2021-11-28 13:34:10
*/
import React, { useEffect } from 'react'
import { SafeAreaProvider } from 'react-native-safe-area-context'
Expand All @@ -19,9 +19,7 @@ import Navigations from './src/navigations/index'

export default function App() {
const isLoadingComplete = useCachedResources()
if (!isLoadingComplete) {
return null
}
if (!isLoadingComplete) return null

return (
<SafeAreaProvider style={_.container.flex}>
Expand Down
4 changes: 2 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* @Author: czy0729
* @Date: 2019-06-02 14:42:28
* @Last Modified by: czy0729
* @Last Modified time: 2021-11-27 11:48:55
* @Last Modified time: 2021-11-28 08:04:41
*/
export const INIT_DEV_DARK = '' // '' 不控制 | true 强制黑暗 | false 强制白天
export const INIT_ROUTE = 'Home'
export const RERENDER_SHOW = /ZZZ/
// export const RERENDER_SHOW = /Rakuen\.(.+?)\.Main/

export default {
initialRouteName: 'HomeTab', // HomeTab Discovery Subject Tinygrail
initialRouteName: 'User', // HomeTab Discovery Subject Tinygrail
initialRouteParams: {
// subjectId: 296870 // anime: 296870, music: 302514, book: 267358, game: 137458
// topicId: 'group/366048', // group/360353, ep/938136
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"scripts": {
"38": "mv ./node_modules ../SDK && mv ../SDK/38/node_modules ./ && mv ../SDK/node_modules ../SDK/39",
"39": "mv ./node_modules ../SDK && mv ../SDK/39/node_modules ./ && mv ../SDK/node_modules ../SDK/38",
"38": "mv ./node_modules ../SDK && mv ../SDK/38/node_modules ./ && mv ../SDK/node_modules ../SDK/39 && cp ./package.json ./web/ios/package.json && cp ./web/android/package.json ./package.json",
"39": "mv ./node_modules ../SDK && mv ../SDK/39/node_modules ./ && mv ../SDK/node_modules ../SDK/38 && cp ./package.json ./web/android/package.json && cp ./web/ios/package.json ./package.json",
"umeng": "mv ../SDK/Umeng/MainActivity.java ./android/app/src/main/java/com/czy0729/bangumi/MainActivity.java",
"google": "mv ../SDK/Google/MainActivity.java ./android/app/src/main/java/com/czy0729/bangumi/MainActivity.java",
"start": "expo start",
Expand All @@ -25,27 +25,27 @@
"crypto-js": "3.1.9-1",
"dayjs": "^1.10.7",
"deepmerge": "^4.0.0",
"expo": "^40.0.0",
"expo-asset": "~8.2.1",
"expo-blur": "~8.2.2",
"expo-constants": "~9.3.3",
"expo-file-system": "~9.3.0",
"expo-font": "~8.4.0",
"expo-linear-gradient": "~8.4.0",
"expo": "^38.0.0",
"expo-asset": "~8.1.7",
"expo-blur": "~8.1.2",
"expo-constants": "~9.1.1",
"expo-file-system": "~9.0.1",
"expo-font": "~8.2.1",
"expo-linear-gradient": "~8.2.1",
"expo-linking": "^1.0.1",
"expo-splash-screen": "~0.8.1",
"expo-splash-screen": "^0.5.0",
"expo-status-bar": "^1.0.0",
"expo-web-browser": "~8.6.0",
"expo-web-browser": "~8.3.1",
"hoist-non-react-statics": "2.5.0",
"lazy-aho-corasick": "^1.2.2",
"lodash.isequal": "^4.5.0",
"mobx": "4.9.2",
"mobx-react": "5.4.3",
"mobx-react-lite": "2.0.7",
"prop-types": "^15.7.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "0.63.4",
"react": "~16.11.0",
"react-dom": "16.11.0",
"react-native": "~0.62.2",
"react-native-actions-shortcuts": "^1.0.1",
"react-native-android-keyboard-adjust": "1.2.0",
"react-native-draggable-grid": "^2.1.4",
Expand Down
6 changes: 5 additions & 1 deletion src/components/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author: czy0729
* @Date: 2019-03-19 01:43:43
* @Last Modified by: czy0729
* @Last Modified time: 2021-11-15 20:46:27
* @Last Modified time: 2021-11-28 09:41:16
*/
import React from 'react'
import { View, TextInput, TouchableWithoutFeedback } from 'react-native'
Expand Down Expand Up @@ -44,6 +44,10 @@ export const Input = observer(
const { autoFocus } = this.props
if (autoFocus) {
this.inputRef.focus()

setTimeout(() => {
this.inputRef.focus()
}, 0)
}
}

Expand Down
104 changes: 51 additions & 53 deletions src/components/list-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author: czy0729
* @Date: 2019-04-11 00:46:28
* @Last Modified by: czy0729
* @Last Modified time: 2021-11-21 02:28:28
* @Last Modified time: 2021-11-29 10:04:14
*/
import React from 'react'
import {
Expand All @@ -17,7 +17,7 @@ import {
import { observer } from 'mobx-react'
import ActivityIndicator from '@ant-design/react-native/lib/activity-indicator'
import { _, systemStore } from '@stores'
import { runAfter, sleep, date, simpleTime } from '@utils'
import { runAfter, omit, sleep, date, simpleTime } from '@utils'
import { LIST_EMPTY } from '@constants'
import { TEXT_REFRESHING, TEXT_FAIL, TEXT_NO_MORE, TEXT_EMPTY } from '@constants/text'
import { randomSpeech } from '@constants/speech'
Expand Down Expand Up @@ -66,6 +66,8 @@ export const ListView = observer(
scrollIndicatorInsets: {
right: 1
},
loading: false, // 受控Loading提示
loadingText: undefined,
onHeaderRefresh: undefined,
onFooterRefresh: undefined
}
Expand Down Expand Up @@ -176,13 +178,10 @@ export const ListView = observer(

shouldStartHeaderRefreshing = () => {
const { refreshState } = this.state
if (
refreshState == RefreshState.HeaderRefreshing ||
refreshState == RefreshState.FooterRefreshing
) {
return false
}
return true
return !(
refreshState === RefreshState.HeaderRefreshing ||
refreshState === RefreshState.FooterRefreshing
)
}

shouldStartFooterRefreshing = () => {
Expand All @@ -201,10 +200,6 @@ export const ListView = observer(
return {
ref: this.connectRef,
style: this.style,

// 安卓默认为true, iOS为false, false时列表的Text才能自由选择复制
// removeClippedSubviews: false,

refreshing: refreshState === RefreshState.HeaderRefreshing,
refreshControl: this.renderRefreshControl(),
ListFooterComponent: showFooter
Expand All @@ -214,13 +209,13 @@ export const ListView = observer(
onEndReached: this.onEndReached,
onEndReachedThreshold: 0.5,

// optimize
// 常用优化参数
initialNumToRender: 48,
windowSize: optimize ? 12 : undefined,
maxToRenderPerBatch: optimize ? 48 : undefined,
updateCellsBatchingPeriod: optimize ? 48 : undefined,

// 都不显示滚动条
// 强制不显示滚动条
showsHorizontalScrollIndicator: false,
showsVerticalScrollIndicator: false
}
Expand Down Expand Up @@ -253,10 +248,7 @@ export const ListView = observer(
get data() {
const { data, lazy } = this.props
const { rendered } = this.state
if (lazy && !rendered) {
return data.list.slice(0, lazy)
}

if (lazy && !rendered) return data.list.slice(0, lazy)
return Array.isArray(data.list) ? data.list : data.list.slice()
}

Expand All @@ -275,16 +267,20 @@ export const ListView = observer(
footerEmptyDataComponent,
footerTextType,
showMesume,
loading,
onHeaderRefresh,
onFooterRefresh
} = this.props
const { rendered } = this.state
if (lazy && !rendered) return footer

switch (refreshState) {
// 受控loading强制把RefreshState复写成加载中
const _refreshState = loading ? RefreshState.FooterRefreshing : refreshState
switch (_refreshState) {
case RefreshState.Idle:
footer = <View style={this.styles.footerContainer} />
break

case RefreshState.Failure:
footer = (
<TouchableOpacity
Expand Down Expand Up @@ -314,6 +310,7 @@ export const ListView = observer(
</TouchableOpacity>
)
break

case RefreshState.EmptyData:
footer = (
<TouchableOpacity
Expand Down Expand Up @@ -344,6 +341,7 @@ export const ListView = observer(
</TouchableOpacity>
)
break

case RefreshState.FooterRefreshing:
footer = footerRefreshingComponent || (
<Flex style={this.styles.footerNoMore} justify='center' direction='column'>
Expand All @@ -360,6 +358,7 @@ export const ListView = observer(
</Flex>
)
break

case RefreshState.NoMoreData:
footer =
footerNoMoreDataComponent ||
Expand All @@ -384,9 +383,11 @@ export const ListView = observer(
</Flex>
) : null)
break

default:
break
}

return footer
}

Expand Down Expand Up @@ -422,46 +423,43 @@ export const ListView = observer(
}

render() {
const {
style,
data,
sectionKey,
sections,
progressViewOffset,
refreshControlProps,
optimize,
showFooter,
animated,
scrollToTop,
showsHorizontalScrollIndicator,
showsVerticalScrollIndicator,
lazy,
const { sectionKey, sections, animated, ...other } = omit(this.props, [
'style',
'data',
'lazy',
'loading',
'loadingText',
'optimize',
'progressViewOffset',
'refreshControlProps',
'scrollToTop',
'showFooter',
'showsHorizontalScrollIndicator',
'showsVerticalScrollIndicator'
])

const props = {
...this.commonProps,
...other
} = this.props
let $list
}
let list
if (sectionKey || sections) {
if (animated) {
$list = (
<AnimatedSectionList
sections={this.section}
{...this.commonProps}
{...other}
/>
)
} else {
$list = (
<SectionList sections={this.section} {...this.commonProps} {...other} />
)
}
} else if (animated) {
$list = <AnimatedFlatList data={this.data} {...this.commonProps} {...other} />
list = animated ? (
<AnimatedSectionList sections={this.sections} {...props} />
) : (
<SectionList sections={this.sections} {...props} />
)
} else {
$list = <FlatList data={this.data} {...this.commonProps} {...other} />
list = animated ? (
<AnimatedFlatList data={this.data} {...props} />
) : (
<FlatList data={this.data} {...props} />
)
}

return (
<>
{$list}
{list}
{this.renderScrollToTop()}
</>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/tool-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2021-01-25 11:50:57
* @Last Modified by: czy0729
* @Last Modified time: 2021-11-15 20:49:10
* @Last Modified time: 2021-11-28 08:45:40
*/
import React from 'react'
import { observer } from 'mobx-react'
Expand Down
6 changes: 3 additions & 3 deletions src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @Author: czy0729
* @Date: 2019-02-22 01:25:31
* @Last Modified by: czy0729
* @Last Modified time: 2021-11-24 07:26:18
* @Last Modified time: 2021-11-29 09:57:02
*/
import { Platform, Dimensions } from 'react-native'
import PropTypes from 'prop-types'
Expand All @@ -15,10 +15,10 @@ const appJson = require('@/app.json')
/* ==================== CUSTOM ==================== */
// 是否开发模式
export const DEV = global.__DEV__
export const TEXT_ONLY = !DEV
export const TEXT_ONLY = DEV

// 日志级别 2 所有, 1 只输出错误和警告, 0 不输出
export const LOG_LEVEL = 0
export const LOG_LEVEL = 1

/* ==================== BASE ==================== */

Expand Down
Loading

0 comments on commit f32360e

Please sign in to comment.