Skip to content

Commit

Permalink
Support pull down refreshing
Browse files Browse the repository at this point in the history
  • Loading branch information
miuchan committed Nov 17, 2018
1 parent 64f7cf9 commit 1df8b0c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 47 deletions.
1 change: 1 addition & 0 deletions app/pages/HotPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class HotPage extends Component<Props> {
title={{ title: '热门' }}
/>
<SubjectList
refreshing={this.props.subjectStore.isFetching}
subjects={this.props.subjectStore.hotSubjectList}
onRefresh={this.props.subjectStore.getHotSubjectList}/>
</View>
Expand Down
3 changes: 2 additions & 1 deletion app/pages/LatestPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ export default class LatestPage extends Component<Props> {
title={{ title: '最新' }}
/>
<SubjectList
refreshing={this.props.subjectStore.isFetching}
subjects={this.props.subjectStore.latestSubjectList}
onRefresh={this.props.subjectStore.getHotSubjectList}/>
onRefresh={this.props.subjectStore.getLatestSubjectList}/>
</View>
)
}
Expand Down
7 changes: 4 additions & 3 deletions app/stores/subjectStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ export interface subjectList {
}

class SubjectStore {
@observable isFetching = false
@observable isFetching: boolean = false
@observable hotSubjectList: subjectList = []
@observable latestSubjectList: subjectList = []

@action
async getHotSubjectList() {
if(this.isFetching) return
this.isFetching = true
const { data } = await api.getHotSubjectList()
this.hotSubjectList = data
console.log(data)
this.isFetching = false
}

@action
async getLatestSubjectList() {
if(this.isFetching) return
const { data } = await api.getLatestSubjectList()
this.latestSubjectList = data
console.log(data)
this.isFetching = false
}

}
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"react-native-linear-gradient": "^2.4.4",
"react-native-navbar": "^2.1.0",
"react-native-paper": "^2.2.4",
"react-native-photo-view": "^1.5.2",
"react-native-refresher": "^0.1.1",
"react-native-photo-view": "^1.5.2"
},
"devDependencies": {
"@babel/plugin-proposal-decorators": "^7.1.6",
Expand Down
42 changes: 1 addition & 41 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3405,11 +3405,6 @@ is-promise@^2.1.0:
resolved "http://registry.npm.taobao.org/is-promise/download/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa"
integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=

is-promise@~2.0.0:
version "2.0.0"
resolved "http://registry.npm.taobao.org/is-promise/download/is-promise-2.0.0.tgz#058b6404ba57c4df03c92ed987c000bda58753a6"
integrity sha1-BYtkBLpXxN8DyS7Zh8AAvaWHU6Y=

is-regex@^1.0.4:
version "1.0.4"
resolved "http://registry.npm.taobao.org/is-regex/download/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
Expand Down Expand Up @@ -4186,7 +4181,7 @@ lodash.throttle@^4.1.1:
resolved "http://registry.npm.taobao.org/lodash.throttle/download/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ=

lodash@^4.0.0, lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.6.1:
lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.6.1:
version "4.17.11"
resolved "http://registry.npm.taobao.org/lodash/download/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
integrity sha1-s56mIp72B+zYniyN8SU2iRysm40=
Expand Down Expand Up @@ -5422,13 +5417,6 @@ react-native-photo-view@^1.5.2:
dependencies:
prop-types "^15.5.10"

react-native-refresher@^0.1.1:
version "0.1.1"
resolved "http://registry.npm.taobao.org/react-native-refresher/download/react-native-refresher-0.1.1.tgz#865be133328bc7eaa5983898cafd0ed750b14b73"
integrity sha1-hlvhMzKLx+qlmDiYyv0O11CxS3M=
dependencies:
is-promise "~2.0.0"

react-native-swipeout@^2.2.2:
version "2.3.6"
resolved "http://registry.npm.taobao.org/react-native-swipeout/download/react-native-swipeout-2.3.6.tgz#47dac8a835825cf3f2eef9e495574a3d9ab6d3fa"
Expand All @@ -5449,15 +5437,6 @@ react-native-typescript-transformer@^1.2.10:
semver "^5.4.1"
source-map "^0.5.6"

react-native-vector-icons@^6.0.2:
version "6.0.2"
resolved "http://registry.npm.taobao.org/react-native-vector-icons/download/react-native-vector-icons-6.0.2.tgz#826252a72d648cf957d46ada8df890318dac53e1"
integrity sha1-gmJSpy1kjPlX1GrajfiQMY2sU+E=
dependencies:
lodash "^4.0.0"
prop-types "^15.6.2"
yargs "^8.0.2"

[email protected]:
version "0.57.4"
resolved "http://registry.npm.taobao.org/react-native/download/react-native-0.57.4.tgz#cb7ba78e8be420737868fa9a97caa897a534c893"
Expand Down Expand Up @@ -6957,25 +6936,6 @@ yargs@^11.0.0:
y18n "^3.2.1"
yargs-parser "^9.0.2"

yargs@^8.0.2:
version "8.0.2"
resolved "http://registry.npm.taobao.org/yargs/download/yargs-8.0.2.tgz#6299a9055b1cefc969ff7e79c1d918dceb22c360"
integrity sha1-YpmpBVsc78lp/355wdkY3Osiw2A=
dependencies:
camelcase "^4.1.0"
cliui "^3.2.0"
decamelize "^1.1.1"
get-caller-file "^1.0.1"
os-locale "^2.0.0"
read-pkg-up "^2.0.0"
require-directory "^2.1.1"
require-main-filename "^1.0.1"
set-blocking "^2.0.0"
string-width "^2.0.0"
which-module "^2.0.0"
y18n "^3.2.1"
yargs-parser "^7.0.0"

yargs@^9.0.0:
version "9.0.1"
resolved "http://registry.npm.taobao.org/yargs/download/yargs-9.0.1.tgz#52acc23feecac34042078ee78c0c007f5085db4c"
Expand Down

0 comments on commit 1df8b0c

Please sign in to comment.