[Gekidou MM-46195] Fix team picker height (#6554)

This commit is contained in:
Jason Frerich
2022-08-10 06:32:40 -05:00
committed by GitHub
parent f55976a2c3
commit f376b3f6af
9 changed files with 92 additions and 90 deletions

View File

@@ -0,0 +1,32 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {ScaledSize} from 'react-native';
import {EdgeInsets} from 'react-native-safe-area-context';
import {ITEM_HEIGHT} from '@components/team_sidebar/add_team/team_list_item/team_list_item';
import {PADDING_TOP_MOBILE} from '@screens/bottom_sheet';
import {TITLE_HEIGHT, TITLE_SEPARATOR_MARGIN} from '@screens/bottom_sheet/content';
import {bottomSheetSnapPoint} from '@utils/helpers';
import type TeamModel from '@typings/database/models/servers/team';
type TeamsSnapProps = {
teams: TeamModel[];
dimensions: ScaledSize;
insets: EdgeInsets;
}
const NO_TEAMS_HEIGHT = 392;
export const getTeamsSnapHeight = ({dimensions, teams, insets}: TeamsSnapProps) => {
let height = NO_TEAMS_HEIGHT;
if (teams.length) {
const itemsHeight = bottomSheetSnapPoint(teams.length, ITEM_HEIGHT, 0);
const heightWithHeader = PADDING_TOP_MOBILE +
TITLE_HEIGHT + (TITLE_SEPARATOR_MARGIN * 2) +
itemsHeight + insets.bottom;
const maxHeight = Math.round((dimensions.height * 0.9));
height = Math.min(maxHeight, heightWithHeader);
}
return height;
};