-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full screen experience - Content scroll underneath transparent status bar #49
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ import { | |
View, | ||
StatusBar, | ||
StyleSheet, | ||
Platform, | ||
AppState, | ||
} from 'react-native'; | ||
|
||
|
@@ -121,7 +120,7 @@ export class App extends Component { | |
<View style={styles.container}> | ||
<StatusBar | ||
translucent={true} | ||
backgroundColor="rgba(0, 0, 0, 0.2)" | ||
backgroundColor="transparent" | ||
barStyle="light-content" | ||
/> | ||
<Navigator | ||
|
@@ -136,9 +135,10 @@ export class App extends Component { | |
renderScene({ id, data }, navigator) { | ||
switch (id) { | ||
case 'item': return <Item itemId={data.itemId} navigator={navigator}/>; | ||
default: | ||
var Component = this.routes[id].component; | ||
default: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the curly brackets needed? I'm just curious. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's to create a new scope to allow the use of |
||
const Component = this.routes[id].component; | ||
return <Component navigator={navigator}/>; | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -155,7 +155,6 @@ const styles = StyleSheet.create({ | |
|
||
scene: { | ||
backgroundColor: '#333', | ||
paddingTop: Platform.OS === 'ios' ? 20 : 24, | ||
}, | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ export class Home extends Component { | |
// never bind functions in render(), it | ||
// messes with react's diffing logic | ||
this.onSettingsPress = this.onSettingsPress.bind(this); | ||
this.renderHeader = this.renderHeader.bind(this); | ||
this.renderRow = this.renderRow.bind(this); | ||
this.onPanEnd = this.onPanEnd.bind(this); | ||
this.onScroll = this.onScroll.bind(this); | ||
|
@@ -46,20 +47,20 @@ export class Home extends Component { | |
// create a clamped property that we can | ||
// use for translating the list view | ||
this.translateY = this.state.listY.interpolate({ | ||
inputRange: [0, Header.HEIGHT], | ||
outputRange: [0, Header.HEIGHT], | ||
inputRange: [0, Header.HEIGHT - Header.STATUS_BAR_HEIGHT], | ||
outputRange: [0, Header.HEIGHT - Header.STATUS_BAR_HEIGHT], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you do this calculation once? const MAX_Y = Header.HEIGHT - Header.STATUS_BAR_HEIGHT; |
||
extrapolate: 'clamp', | ||
}); | ||
|
||
// fades the header in/out in sync with list position | ||
this.opacity = this.translateY.interpolate({ | ||
inputRange: [0, Header.HEIGHT], | ||
inputRange: [0, Header.HEIGHT - Header.STATUS_BAR_HEIGHT], | ||
outputRange: [0, 1], | ||
}); | ||
|
||
// scales the header in/out in sync with list position | ||
this.scale = this.translateY.interpolate({ | ||
inputRange: [0, Header.HEIGHT], | ||
inputRange: [0, Header.HEIGHT - Header.STATUS_BAR_HEIGHT], | ||
outputRange: [0.95, 1], | ||
}); | ||
|
||
|
@@ -364,7 +365,10 @@ export class Home extends Component { | |
* @param {Number} y | ||
*/ | ||
clamp(y) { | ||
if (y > Header.HEIGHT) return { value: Header.HEIGHT, offset: y - Header.HEIGHT }; | ||
if (y > Header.HEIGHT) return { | ||
value: Header.HEIGHT, | ||
offset: y - Header.HEIGHT, | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is really funky syntax, can you find an alternative :-/ |
||
else if (y < 0) return { value: 0, offset: y }; | ||
else return { value: y, offset: 0 }; | ||
} | ||
|
@@ -391,7 +395,8 @@ export class Home extends Component { | |
title="Home" | ||
action="Settings" | ||
navigator={this.navigator} | ||
onActionPress={this.onSettingsPress}/> | ||
onActionPress={this.onSettingsPress} | ||
style={styles.header}/> | ||
</Animated.View> | ||
|
||
<Animated.View | ||
|
@@ -427,6 +432,7 @@ export class Home extends Component { | |
<ListView | ||
ref="list" | ||
dataSource={this.dataSource} | ||
renderHeader={this.renderHeader} | ||
renderRow={this.renderRow} | ||
onScroll={this.onScroll} | ||
scrollEventThrottle={16} | ||
|
@@ -436,6 +442,12 @@ export class Home extends Component { | |
); | ||
} | ||
|
||
renderHeader() { | ||
return ( | ||
<View style={styles.firstRow}/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This element overhangs the header content and blocks the header buttons. 'Settings' button is difficult to press. |
||
); | ||
} | ||
|
||
renderRow({ value: { id, imageUri, createdByUser, timeCreated } }) { | ||
const publisherImageUri = createdByUser.imageUri; | ||
const publisherName = createdByUser.name; | ||
|
@@ -483,6 +495,15 @@ const styles = StyleSheet.create({ | |
flex: 1, | ||
}, | ||
|
||
firstRow: { | ||
height: Header.STATUS_BAR_HEIGHT, | ||
}, | ||
|
||
header: { | ||
height: 54, | ||
marginTop: Header.STATUS_BAR_HEIGHT / 2, | ||
}, | ||
|
||
listContainer: { | ||
flex: 1, | ||
position: 'absolute', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep a bit of background color so that if status-bar icons are over a white background (in our app) they are still visible?