Skip to content

Commit 55696aa

Browse files
committed
完成首页
1 parent 41290c2 commit 55696aa

File tree

7 files changed

+369
-8
lines changed

7 files changed

+369
-8
lines changed

meiTuan/ios/meiTuan/Info.plist

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
<key>NSLocationWhenInUseUsageDescription</key>
4242
<string></string>
4343
<key>NSAppTransportSecurity</key>
44-
<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
4544
<dict>
45+
<key>NSAllowsArbitraryLoads</key>
46+
<true/>
4647
<key>NSExceptionDomains</key>
4748
<dict>
4849
<key>localhost</key>

meiTuan/src/RootScene.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,21 @@ export default class RootScene extends PureComponent {
125125

126126
render(){
127127
return(
128-
<Navigator />
128+
<Navigator
129+
onNavigationStateChange={
130+
(prevState, currentState) => {
131+
const currentScene = getCurrentRouteName(currentState)
132+
const previousScene = getCurrentRouteName(prevState)
133+
if (previousScene !== currentScene) {
134+
if (lightContentScenes.indexOf(currentScene) >= 0) {
135+
StatusBar.setBarStyle('light-content')
136+
} else {
137+
StatusBar.setBarStyle('dark-content')
138+
}
139+
}
140+
}
141+
}
142+
/>
129143
)
130144
}
131145

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React, {PureComponent} from 'react'
2+
import {
3+
View,
4+
Text,
5+
StyleSheet,
6+
TouchableOpacity,
7+
Image,
8+
} from 'react-native'
9+
import {Heading1, Heading2, Heading3, Paragraph} from '../../widget/Text'
10+
import screen from '../../common/screen'
11+
import system from '../../common/system'
12+
import color from '../../widget/color'
13+
14+
export default class GroupPurchaseCell extends PureComponent {
15+
render(){
16+
let {info} = this.props
17+
let imageUrl = info.imageUrl.replace('w.h', '160.0')
18+
return (
19+
<TouchableOpacity style={styles.container} onPress={() => this.props.onPress(info)}>
20+
<Image source={{uri: imageUrl}} style={styles.icon} />
21+
22+
<View style={styles.rightContainer}>
23+
<Heading2>{info.title}</Heading2>
24+
<Paragraph numberOfLine={0} style={{marginTop: 8}}>{info.subtitle}</Paragraph>
25+
<View style={{flex:1, justifyContent:'flex-end'}}>
26+
<Heading2 style={styles.price}>{info.price}</Heading2>
27+
</View>
28+
</View>
29+
30+
</TouchableOpacity>
31+
)
32+
}
33+
}
34+
35+
const styles = StyleSheet.create({
36+
container: {
37+
flexDirection: 'row',
38+
padding: 10,
39+
borderBottomWidth: screen.onePixel,
40+
borderColor: color.border,
41+
backgroundColor: 'white',
42+
},
43+
icon: {
44+
width: 80,
45+
height: 80,
46+
borderRadius: 5,
47+
},
48+
rightContainer: {
49+
flex: 1,
50+
paddingLeft: 20,
51+
paddingRight: 10,
52+
},
53+
price: {
54+
color: color.primary
55+
}
56+
})
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React, {PureComponent} from 'react'
2+
import {
3+
View,
4+
Text,
5+
StyleSheet,
6+
TouchableOpacity,
7+
Image,
8+
} from 'react-native'
9+
import {Heading2, Heading3} from '../../widget/Text'
10+
import screen from '../../common/screen'
11+
import system from '../../common/system'
12+
import color from '../../widget/color'
13+
14+
export default class HomeGridItem extends PureComponent {
15+
render(){
16+
let info = this.props.info
17+
18+
let title = info.maintitle
19+
let color = info.typeface_color
20+
let subtitle = info.deputytitle
21+
let imageUrl = info.imageUrl.replace('w.h', '120.0')
22+
23+
return(
24+
<TouchableOpacity style={styles.container} onPress={this.props.onPress}>
25+
<View>
26+
<Heading2 style={{color:color, marginBottom: 10}}>{title}</Heading2>
27+
<Heading3>{subtitle}</Heading3>
28+
</View>
29+
30+
<Image style={styles.icon} source={{uri: imageUrl}} />
31+
</TouchableOpacity>
32+
)
33+
}
34+
}
35+
36+
const styles = StyleSheet.create({
37+
container: {
38+
flexDirection: 'row',
39+
justifyContent: 'center',
40+
alignItems: 'center',
41+
width: screen.width / 2 - screen.onePixel,
42+
height: screen.width / 4,
43+
backgroundColor: 'white',
44+
borderBottomWidth: screen.onePixel,
45+
borderRightWidth: screen.onePixel,
46+
borderColor: color.border
47+
},
48+
icon: {
49+
width: screen.width / 5,
50+
height: screen.width / 5,
51+
}
52+
})
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React, {PureComponent} from 'react'
2+
import {
3+
View,
4+
Text,
5+
StyleSheet,
6+
} from 'react-native'
7+
import screen from '../../common/screen'
8+
import system from '../../common/system'
9+
import color from '../../widget/color'
10+
import HomeGridItem from './HomeGridItem'
11+
12+
export default class HomeGridView extends PureComponent {
13+
static defaultProps = {
14+
infos: []
15+
}
16+
17+
render(){
18+
return(
19+
<View style={styles.container}>
20+
{
21+
this.props.infos.map((info, index) => {
22+
return(
23+
<HomeGridItem
24+
info={info}
25+
key={index}
26+
onPress={() => this.props.onGridSelected(index)}
27+
/>
28+
)
29+
})
30+
}
31+
</View>
32+
)
33+
}
34+
}
35+
36+
const styles = StyleSheet.create({
37+
container: {
38+
flexDirection: 'row',
39+
flexWrap: 'wrap',
40+
justifyContent: 'space-between',
41+
borderTopWidth: screen.onePixel,
42+
borderLeftWidth: screen.onePixel,
43+
borderColor: color.border,
44+
}
45+
})

meiTuan/src/scene/Home/HomeMenuView.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import screen from '../../common/screen'
1010
import system from '../../common/system'
1111
import color from '../../widget/color'
1212
import HomeMenuItem from './HomeMenuItem'
13-
import { ECHILD } from 'constants';
1413

1514
export default class HomeMenuView extends PureComponent {
1615

@@ -61,8 +60,10 @@ export default class HomeMenuView extends PureComponent {
6160
return(
6261
<View style={styles.container}>
6362
<ScrollView
63+
pagingEnabled
64+
horizontal
6465
showsHorizontalScrollIndicator={false}
65-
onScroll={e => this.onScroll(e)}
66+
onScroll={(e) => this.onScroll(e)}
6667
>
6768
<View style={styles.menuContainer}>
6869
{menuViews}
@@ -72,6 +73,7 @@ export default class HomeMenuView extends PureComponent {
7273
<PageControl
7374
style={styles.PageControl}
7475
numberOfPages={pageCount}
76+
hidesForSinglePage
7577
currentPage={this.state.currentPage}
7678
pageIndicatorTintColor='gray'
7779
currentPageIndicatorTintColor={color.primary}

0 commit comments

Comments
 (0)