Skip to content

Commit

Permalink
Scrollable fullheight albums
Browse files Browse the repository at this point in the history
  • Loading branch information
Swizec committed Feb 19, 2017
1 parent 44eaca9 commit 47f064d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
10 changes: 9 additions & 1 deletion Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@ class Store {
@observable index = 0;
@observable galleryPage = 0;
@observable albums = new observable.map();
@observable screenSize = {
width: null,
height: null
};

@action changeOrientation(orientation) {
this.orientation = orientation;
}

@action updateScreenSize(width, height) {
this.screenSize.width = width;
this.screenSize.height = height;
}

@action prevImage() {
this.index = this.index - 1;

Expand Down Expand Up @@ -56,7 +65,6 @@ class Store {
.then(fetch.throwErrors)
.then(res => res.json())
.then(json => {
console.log('loaded', json.data.id);
this.albums.set(json.data.id, json.data);
})
.catch(err => console.log('ERROR', err.message, err));
Expand Down
13 changes: 10 additions & 3 deletions components/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TouchableImage extends Component {
}

render() {
const { image, store } = this.props;
const { image, store, height } = this.props;

const uri = image.link.replace('http://', 'https://'),
caption = image.title || image.description;
Expand All @@ -46,7 +46,9 @@ class TouchableImage extends Component {
<TouchableHighlight onPress={this.onPress.bind(this)}
style={styles.fullscreen}>
<Image source={{uri: uri}}
style={[styles.backgroundImage, styles[store.orientation.toLowerCase()]]}
style={[styles.backgroundImage,
styles[store.orientation.toLowerCase()],
{height: height || null}]}
onLayout={this.onImageLayout.bind(this)}>
<Text style={styles.imageLabel}>{caption}</Text>
</Image>
Expand Down Expand Up @@ -77,8 +79,13 @@ class Album extends Component {
}

renderRow(img) {
const { store } = this.props;

console.log(store.screenSize.height);

return (
<TouchableImage image={img} />
<TouchableImage image={img}
height={store.screenSize.height} />
)
}

Expand Down
1 change: 1 addition & 0 deletions index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ImgurApp extends Component {
const orientation = ( width > height ) ? LANDSCAPE : PORTRAIT;

Store.changeOrientation(orientation);
Store.updateScreenSize(width, height);
}

componentWillMount() {
Expand Down

0 comments on commit 47f064d

Please sign in to comment.