Skip to content

Commit

Permalink
fix viewPager
Browse files Browse the repository at this point in the history
  • Loading branch information
horizon0514 authored and horizon0514 committed Dec 13, 2015
1 parent 63f8813 commit 02276bf
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 22 deletions.
18 changes: 6 additions & 12 deletions MainScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class MainScreen extends Component {
var spinner = <ActivityIndicatorIOS style={styles.centering} hidden='false' size='large'/>;
var slider = this.state.sliderDataSource?
(<View style={styles.sliderContainer}>
<Slider style={styles.slider} dataSource={this.state.sliderDataSource}/>
<Slider dataSource={this.state.sliderDataSource}/>
</View>)
:(<View></View>);
if(!this.state.loaded){
Expand All @@ -169,7 +169,7 @@ class MainScreen extends Component {
<View style={styles.container}>
<View style={styles.header}></View>
{slider}
<ListView style={styles.listview}
<ListView
dataSource={this.state.dataSource}
renderSectionHeader={this.renderSectionHeader.bind(this)}
renderFooter={this.renderFooter.bind(this)}
Expand Down Expand Up @@ -236,17 +236,11 @@ var styles = StyleSheet.create({

},
sliderContainer:{
height: 700,
flex: 1,
//flexDirection: 'column',

},
slider:{
height: 700,
height: 200,

},
listview:{
marginTop: -150,
}


});

module.exports = MainScreen;
38 changes: 32 additions & 6 deletions Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,23 @@ class Slider extends Component{
_renderPage(data,pageId){
console.log(data);
return (
<Image
source={{uri: data.image}}
style={styles.page} />
<View style={styles.container}>
<Image
source={{uri: data.image}}
style={styles.page}>
<View style={styles.titleContainer}>
<Text style={styles.title}>{data.title}</Text>
</View>

</Image>
</View>
);
}

render(){
console.log('render slider');
console.log(this.props);
return (
<ViewPager
style={{flex:1,height: 200}}
style={this.props.style}
dataSource={this.state.dataSource}
renderPage={this._renderPage}
isLoop={true}
Expand All @@ -58,11 +63,32 @@ class Slider extends Component{
}

var styles = StyleSheet.create({
container: {

},
page: {
height: 200,
width: deviceWidth,


},
titleContainer: {
flex: 1,
padding: 20,


},

title: {
color: '#ffffff',
fontSize: 20,
fontWeight : 'bold',
position: 'absolute',
bottom: 20,

//backgroundColor: 'transparent',
}


});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -62,15 +62,18 @@
ReferencedContainer = "container:RNZhihuDaily.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand All @@ -86,10 +89,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down

0 comments on commit 02276bf

Please sign in to comment.