[Gekidou] Fix initial Channel list width on iPad (#6164)

* Fix initial Channel list width on iPad

* feedback review
This commit is contained in:
Elias Nahum
2022-04-12 09:07:55 -04:00
committed by GitHub
parent 2b3d84ee61
commit 57e3334507

View File

@@ -34,10 +34,21 @@ type ChannelListProps = {
teamsCount: number;
}
const getTabletWidth = (teamsCount: number) => {
return TABLET_SIDEBAR_WIDTH - (teamsCount > 1 ? TEAM_SIDEBAR_WIDTH : 0);
};
const ChannelList = ({channelsCount, currentTeamId, iconPad, isTablet, teamsCount}: ChannelListProps) => {
const theme = useTheme();
const styles = getStyleSheet(theme);
const tabletWidth = useSharedValue(TABLET_SIDEBAR_WIDTH);
const tabletWidth = useSharedValue(isTablet ? getTabletWidth(teamsCount) : 0);
useEffect(() => {
if (isTablet) {
tabletWidth.value = getTabletWidth(teamsCount);
}
}, [isTablet && teamsCount]);
const tabletStyle = useAnimatedStyle(() => {
if (!isTablet) {
return {
@@ -48,12 +59,6 @@ const ChannelList = ({channelsCount, currentTeamId, iconPad, isTablet, teamsCoun
return {maxWidth: withTiming(tabletWidth.value, {duration: 350})};
}, [isTablet]);
useEffect(() => {
if (isTablet) {
tabletWidth.value = TABLET_SIDEBAR_WIDTH - (teamsCount > 1 ? TEAM_SIDEBAR_WIDTH : 0);
}
}, [isTablet, teamsCount]);
let content;
if (!currentTeamId) {