Skip to content

Commit

Permalink
fix: rn全局enablePullDownRresh兼容
Browse files Browse the repository at this point in the history
  • Loading branch information
yechunxi authored and Pines-Cheng committed Dec 28, 2020
1 parent bdd0a4a commit 6ae2f67
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/taro-runtime-rn/src/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,20 @@ export function createPageConfig (Page: any, pageConfig: PageConfig): any {
return result
}

isEnablePullDown(){
const windowOptions = globalAny.__taroAppConfig?.appConfig?.window || {}
const { enablePullDownRefresh = false } = windowOptions
return pageConfig?.enablePullDownRefresh || enablePullDownRefresh
}

refreshPullDown () {
const { refreshing, textColor, backgroundColor } = this.state
return React.createElement(RefreshControl, {
refreshing: refreshing,
enabled: true,
titleColor: textColor,
tintColor: textColor,
progressBackgroundColor: backgroundColor,
colors: [backgroundColor],
onRefresh: () => this.onPullDownRefresh()
}, null)
}
Expand All @@ -383,8 +389,7 @@ export function createPageConfig (Page: any, pageConfig: PageConfig): any {
}

createScrollPage () {
const { enablePullDownRefresh = false } = pageConfig
const refresh = enablePullDownRefresh ? { refreshControl: this.refreshPullDown() } : {}
const refresh = this.isEnablePullDown() ? { refreshControl: this.refreshPullDown() } : {}
return h(ScrollView, {
style: { flex: 1 },
contentContainerStyle: { minHeight: '100%' },
Expand Down

0 comments on commit 6ae2f67

Please sign in to comment.