From 13922e37643873b36ee91aee151acfe7355f7e10 Mon Sep 17 00:00:00 2001 From: enahum Date: Mon, 2 Oct 2017 12:22:14 -0300 Subject: [PATCH] Fix drawer according to number of teams (#974) --- .../channel_drawer/channel_drawer.js | 38 ++++++++++++------- .../drawer_swipper/drawer_swiper.js | 4 +- app/components/swiper.js | 4 +- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/app/components/channel_drawer/channel_drawer.js b/app/components/channel_drawer/channel_drawer.js index b2c71c2a5..dedf258ef 100644 --- a/app/components/channel_drawer/channel_drawer.js +++ b/app/components/channel_drawer/channel_drawer.js @@ -315,26 +315,37 @@ export default class ChannelDrawer extends PureComponent { openDrawerOffset } = this.state; - const showTeams = openDrawerOffset !== 0 && teamsCount > 1; + const multipleTeams = teamsCount > 1; + const showTeams = openDrawerOffset !== 0 && multipleTeams; if (this.drawerSwiper) { - if (showTeams) { + if (multipleTeams) { this.drawerSwiper.getWrappedInstance().runOnLayout(); } else if (!openDrawerOffset) { this.drawerSwiper.getWrappedInstance().scrollToStart(); } } - const teamsList = ( - - - - ); + const lists = []; + if (multipleTeams) { + const teamsList = ( + + + + ); + lists.push(teamsList); + } - const channelsList = ( - + lists.push( + - {teamsList} - {channelsList} + {lists} ); }; diff --git a/app/components/channel_drawer/drawer_swipper/drawer_swiper.js b/app/components/channel_drawer/drawer_swipper/drawer_swiper.js index b6f26384d..bef5db83d 100644 --- a/app/components/channel_drawer/drawer_swipper/drawer_swiper.js +++ b/app/components/channel_drawer/drawer_swipper/drawer_swiper.js @@ -53,10 +53,12 @@ export default class DrawerSwiper extends PureComponent { theme } = this.props; + const initialPage = React.Children.count(children) - 1; + return ( { if (this.runOnLayout) { if (Platform.OS === 'ios') { - this.scrollView.scrollTo({x: this.offset, animated: false}); + setTimeout(() => { + this.scrollView.scrollTo({x: this.props.width * this.state.index, animated: false}); + }, 100); } else { this.scrollView.setPageWithoutAnimation(this.state.index); }