Skip to content

Commit 94ebc42

Browse files
committed
code style use standard
1 parent efd3804 commit 94ebc42

28 files changed

+1434
-1442
lines changed

AsyncStorageTest.js

+44-44
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React ,{Component} from 'react';
1+
import React, {Component} from 'react'
22
import {
33
View,
44
StyleSheet,
@@ -7,72 +7,72 @@ import {
77
TextInput
88
} from 'react-native'
99
import NavigationBar from './js/common/NavigationBar'
10-
import Toast,{DURATION} from 'react-native-easy-toast'
10+
import Toast, {DURATION} from 'react-native-easy-toast'
1111

12-
const KEY ='text';
12+
const KEY = 'text'
1313
export default class AsyncStorageTest extends Component {
14-
constructor(props){
15-
super(props);
14+
constructor (props) {
15+
super(props)
1616
}
1717
// 存储
18-
onSave(){
19-
AsyncStorage.setItem(KEY,this.text,(error)=>{
20-
if(!error){
21-
this.toast.show('成功↑',DURATION.LENGTH_LONG)
22-
}else{
23-
this.toast.show('失败咯~',DURATION.LENGTH_LONG)
18+
onSave () {
19+
AsyncStorage.setItem(KEY, this.text, (error) => {
20+
if (!error) {
21+
this.toast.show('成功↑', DURATION.LENGTH_LONG)
22+
} else {
23+
this.toast.show('失败咯~', DURATION.LENGTH_LONG)
2424
}
2525
})
2626
}
2727
// 取出
28-
onFetch() {
29-
AsyncStorage.getItem(KEY,(error,result)=>{
30-
if(!error){
31-
if(result!==''&&result!==null){
32-
this.toast.show('取出了'+result,DURATION.LENGTH_LONG);
33-
}else{
34-
this.toast.show('取出内容不存在',DURATION.LENGTH_LONG);
28+
onFetch () {
29+
AsyncStorage.getItem(KEY, (error, result) => {
30+
if (!error) {
31+
if (result !== '' && result !== null) {
32+
this.toast.show('取出了' + result, DURATION.LENGTH_LONG)
33+
} else {
34+
this.toast.show('取出内容不存在', DURATION.LENGTH_LONG)
3535
}
36-
}else{
37-
this.toast.show('取出失败~=。=',DURATION.LENGTH_LONG)
36+
} else {
37+
this.toast.show('取出失败~=。=', DURATION.LENGTH_LONG)
3838
}
3939
})
4040
}
4141
// 移除
42-
onRemove() {
43-
AsyncStorage.removeItem(KEY,(error)=>{
44-
if(!error){
45-
this.toast.show('移除成功↑',DURATION.LENGTH_LONG)
46-
}else{
47-
this.toast.show('移除失败',DURATION.LENGTH_LONG)
42+
onRemove () {
43+
AsyncStorage.removeItem(KEY, (error) => {
44+
if (!error) {
45+
this.toast.show('移除成功↑', DURATION.LENGTH_LONG)
46+
} else {
47+
this.toast.show('移除失败', DURATION.LENGTH_LONG)
4848
}
4949
})
5050
}
51-
render(){
51+
render () {
5252
return <View>
5353
<NavigationBar
54-
title={'AsyncStorageTest'}
55-
></NavigationBar>
54+
title={'AsyncStorageTest'}
55+
/>
5656
<TextInput
57-
style={{borderWidth:1,
58-
height:40,
59-
margin:6
57+
style={{borderWidth: 1,
58+
height: 40,
59+
margin: 6
6060
}}
61-
onChangeText={text=>this.text=text}
62-
></TextInput>
61+
onChangeText={text => this.text = text}
62+
/>
6363

64-
<View style={{flexDirection:'row'}}>
65-
<Text style={{fontSize:20,margin:5}}
66-
onPress={()=>this.onSave()}
64+
<View style={{flexDirection: 'row'}}>
65+
<Text style={{fontSize: 20, margin: 5}}
66+
onPress={() => this.onSave()}
6767
>保存</Text>
68-
<Text style={{fontSize:20,margin:5}}
69-
onPress={()=>this.onRemove()}
68+
<Text style={{fontSize: 20, margin: 5}}
69+
onPress={() => this.onRemove()}
7070
>移除</Text>
71-
<Text style={{fontSize:20,margin:5}}
72-
onPress={()=>this.onFetch()}
71+
<Text style={{fontSize: 20, margin: 5}}
72+
onPress={() => this.onFetch()}
7373
>取出</Text>
74-
</View>
75-
<Toast ref={toast=>this.toast=toast}></Toast>
7674
</View>
75+
<Toast ref={toast => this.toast = toast} />
76+
</View>
7777
}
78-
}
78+
}

HttpUtils.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
export default class HttpUtils {
2-
static get(url) {
2+
static get (url) {
33
return new Promise((resolve, reject) => {
44
fetch(url)
55
.then(response => response.json())
66
.then(result => {
7-
resolve(result);
7+
resolve(result)
88
})
99
.catch(error => {
10-
reject(error);
10+
reject(error)
1111
})
1212
})
1313
}
14-
static post(url, data) {
14+
static post (url, data) {
1515
return new Promise((resolve, reject) => {
1616
fetch(url, {
1717
method: 'post',
1818
header: {
1919
'Accept': 'application/json',
2020
'Content-Type': 'application/json'
2121
},
22-
body: JSON.stringify(data)
23-
})
22+
body: JSON.stringify(data)
23+
})
2424
.then(response => response.json())
2525
.then(result => {
26-
resolve(result);
26+
resolve(result)
2727
})
2828
.catch(error => {
29-
reject(error);
29+
reject(error)
3030
})
3131
})
3232
}
33-
}
33+
}

ListViewTest.js

+64-64
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {Component} from 'react';
1+
import React, {Component} from 'react'
22
import {
33
View,
44
Text,
@@ -7,117 +7,117 @@ import {
77
Image,
88
ListView,
99
RefreshControl
10-
} from 'react-native';
10+
} from 'react-native'
1111
import NavigationBar from './NavigationBar'
12-
import Toast,{DURATION} from 'react-native-easy-toast'
12+
import Toast, {DURATION} from 'react-native-easy-toast'
1313

1414
var data = {
15-
"result": [
15+
'result': [
1616
{
17-
"email": "laclys@126.com",
18-
"fullName": "Lac"
17+
'email': 'laclys@126.com',
18+
'fullName': 'Lac'
1919
}, {
20-
"email": "sylcal@126.com",
21-
"fullName": "Cal"
20+
'email': 'sylcal@126.com',
21+
'fullName': 'Cal'
2222
}, {
23-
"email": "zyy@126.com",
24-
"fullName": "Zyy"
23+
'email': 'zyy@126.com',
24+
'fullName': 'Zyy'
2525
}, {
26-
"email": "421084802@126.com",
27-
"fullName": "Zhang"
26+
'email': '421084802@126.com',
27+
'fullName': 'Zhang'
2828
}, {
29-
"email": "yoyo@126.com",
30-
"fullName": "Yoyo"
29+
'email': 'yoyo@126.com',
30+
'fullName': 'Yoyo'
3131
}, {
32-
"email": "123321@126.com",
33-
"fullName": "Bill"
32+
'email': '123321@126.com',
33+
'fullName': 'Bill'
3434
}, {
35-
"email": "swonwhite@126.com",
36-
"fullName": "Swon"
35+
'email': 'swonwhite@126.com',
36+
'fullName': 'Swon'
3737
}, {
38-
"email": "Mac@126.com",
39-
"fullName": "Mac"
38+
'email': 'Mac@126.com',
39+
'fullName': 'Mac'
4040
}, {
41-
"email": "laclys1@126.com",
42-
"fullName": "Lac"
41+
'email': 'laclys1@126.com',
42+
'fullName': 'Lac'
4343
}, {
44-
"email": "sylcal1@126.com",
45-
"fullName": "Cal"
44+
'email': 'sylcal1@126.com',
45+
'fullName': 'Cal'
4646
}, {
47-
"email": "zyy1@126.com",
48-
"fullName": "Zyy"
47+
'email': 'zyy1@126.com',
48+
'fullName': 'Zyy'
4949
}, {
50-
"email": "4210848021@126.com",
51-
"fullName": "Zhang"
50+
'email': '4210848021@126.com',
51+
'fullName': 'Zhang'
5252
}, {
53-
"email": "yoyo1@126.com",
54-
"fullName": "Yoyo"
53+
'email': 'yoyo1@126.com',
54+
'fullName': 'Yoyo'
5555
}, {
56-
"email": "1233211@126.com",
57-
"fullName": "Bill"
56+
'email': '1233211@126.com',
57+
'fullName': 'Bill'
5858
}, {
59-
"email": "swonwhite1@126.com",
60-
"fullName": "Swon"
59+
'email': 'swonwhite1@126.com',
60+
'fullName': 'Swon'
6161
}, {
62-
"email": "Mac1@126.com",
63-
"fullName": "Mac"
62+
'email': 'Mac1@126.com',
63+
'fullName': 'Mac'
6464
}
6565
],
66-
"statusCode": 0
67-
};
66+
'statusCode': 0
67+
}
6868

6969
export default class ListViewTest extends Component {
70-
constructor(props) {
71-
super(props);
70+
constructor (props) {
71+
super(props)
7272
const ds = new ListView.DataSource({
7373
rowHasChanged: (r1, r2) => r1 !== r2
7474
})
7575
this.state = {
7676
dataScource: ds.cloneWithRows(data.result),
77-
isLoading:true,
77+
isLoading: true
7878
}
79-
this.onLoad();
79+
this.onLoad()
8080
}
81-
renderRow(item,sectionID, rowID, highlightRow) {
81+
renderRow (item, sectionID, rowID, highlightRow) {
8282
return <View key={rowID} style={styles.row}>
8383
<TouchableOpacity
84-
onPress={()=>{
85-
this.toast.show('clicked!'+item.fullName,DURATION.LENGTH_LONG)
84+
onPress={() => {
85+
this.toast.show('clicked!' + item.fullName, DURATION.LENGTH_LONG)
8686
}}
8787
>
8888
<Text style={styles.text}>{item.fullName}</Text>
8989
<Text style={styles.text}>{item.email}</Text>
9090
</TouchableOpacity>
9191
</View>
9292
}
93-
renderSeparator(sectionID, rowID, adjacentRowHighlighted){
94-
return <View key={rowID} style={styles.line}></View>
93+
renderSeparator (sectionID, rowID, adjacentRowHighlighted) {
94+
return <View key={rowID} style={styles.line} />
9595
}
96-
renderFooter(){
97-
return <Image style={{width:50,height:50}} source={{uri:'https://avatars1.githubusercontent.com/u/22010181?v=3&s=460'}}/>
96+
renderFooter () {
97+
return <Image style={{width: 50, height: 50}} source={{uri: 'https://avatars1.githubusercontent.com/u/22010181?v=3&s=460'}} />
9898
}
99-
onLoad() {
100-
setTimeout(()=>{
99+
onLoad () {
100+
setTimeout(() => {
101101
this.setState({
102-
isLoading:false
102+
isLoading: false
103103
})
104-
},2000);
104+
}, 2000)
105105
}
106-
render() {
106+
render () {
107107
return (
108108
<View style={styles.container}>
109-
<NavigationBar title={'ListViewTest'}/>
109+
<NavigationBar title={'ListViewTest'} />
110110
<ListView
111111
dataSource={this.state.dataScource}
112-
renderRow={(item,sectionID, rowID, highlightRow) => this.renderRow(item,sectionID, rowID, highlightRow)}
113-
renderSeparator={(sectionID, rowID, adjacentRowHighlighted)=>this.renderSeparator(sectionID, rowID, adjacentRowHighlighted)}
114-
renderFooter={()=>this.renderFooter()}
112+
renderRow={(item, sectionID, rowID, highlightRow) => this.renderRow(item, sectionID, rowID, highlightRow)}
113+
renderSeparator={(sectionID, rowID, adjacentRowHighlighted) => this.renderSeparator(sectionID, rowID, adjacentRowHighlighted)}
114+
renderFooter={() => this.renderFooter()}
115115
refreshControl={<RefreshControl
116116
refreshing={this.state.isLoading}
117-
onRefresh={()=>this.onLoad()}
117+
onRefresh={() => this.onLoad()}
118118
/>}
119119
/>
120-
<Toast ref={toast=>{this.toast=toast}} />
120+
<Toast ref={toast => { this.toast = toast }} />
121121
</View>
122122
)
123123
}
@@ -134,8 +134,8 @@ const styles = StyleSheet.create({
134134
row: {
135135
height: 50
136136
},
137-
line:{
138-
height:1,
139-
backgroundColor:'black'
137+
line: {
138+
height: 1,
139+
backgroundColor: 'black'
140140
}
141-
})
141+
})

0 commit comments

Comments
 (0)