Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions js/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
View,
StatusBar,
StyleSheet,
Platform,
AppState,
} from 'react-native';

Expand Down Expand Up @@ -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"
Copy link
Collaborator

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?

barStyle="light-content"
/>
<Navigator
Expand All @@ -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: {
Copy link
Member

@arcturus arcturus Jan 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the curly brackets needed? I'm just curious.

Copy link
Contributor Author

@gmarty gmarty Feb 1, 2017

Choose a reason for hiding this comment

The 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.

const Component = this.routes[id].component;
return <Component navigator={navigator}/>;
}
}
}
}
Expand All @@ -155,7 +155,6 @@ const styles = StyleSheet.create({

scene: {
backgroundColor: '#333',
paddingTop: Platform.OS === 'ios' ? 20 : 24,
},
});

Expand Down
6 changes: 5 additions & 1 deletion js/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
Text,
StyleSheet,
TouchableOpacity,
Platform,
StatusBar,
} from 'react-native';

export default class Header extends Component {
Expand Down Expand Up @@ -81,11 +83,13 @@ Header.propTypes = {
navigator: PropTypes.object,
};

Header.HEIGHT = 54;
const STATUS_BAR_HEIGHT = Platform.OS === 'ios' ? 20 : StatusBar.currentHeight;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the values 20 and 54 constants with self explained name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20 is the height of the status bar on iOS. In Android, we can just use StatusBar.currentHeight.
54 is the height we want the header to have. This should be pretty self explanatory already.

Header.HEIGHT = 54 + STATUS_BAR_HEIGHT;

const styles = StyleSheet.create({
header: {
backgroundColor: '#333',
paddingTop: STATUS_BAR_HEIGHT,
height: Header.HEIGHT,
flexDirection: 'row',
alignItems: 'center',
Expand Down
3 changes: 1 addition & 2 deletions js/components/ListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ const styles = StyleSheet.create({

image: {
flex: 1,
paddingVertical: 10,
paddingHorizontal: 12,
padding: 12,
width: null,
height: null,
resizeMode: 'cover',
Expand Down