diff --git a/app/components/option_item/index.tsx b/app/components/option_item/index.tsx index a0b5faa31..641ade7ec 100644 --- a/app/components/option_item/index.tsx +++ b/app/components/option_item/index.tsx @@ -30,6 +30,14 @@ const OptionType = { export type OptionType = typeof OptionType[keyof typeof OptionType]; export const ITEM_HEIGHT = 48; +const DESCRIPTION_MARGIN_TOP = 2; + +export function getItemHeightWithDescription(descriptionNumberOfLines: number) { + const labelHeight = 24; // typography 200 line height + const descriptionLineHeight = 16; // typography 75 line height; + + return Math.max(48, labelHeight + DESCRIPTION_MARGIN_TOP + (descriptionLineHeight * descriptionNumberOfLines)); +} const hitSlop = {top: 11, bottom: 11, left: 11, right: 11}; const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => { @@ -50,7 +58,7 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => { description: { color: changeOpacity(theme.centerChannelColor, 0.64), ...typography('Body', 75), - marginTop: 2, + marginTop: DESCRIPTION_MARGIN_TOP, }, iconContainer: {marginRight: 16}, infoContainer: {marginRight: 2}, @@ -118,6 +126,7 @@ export type OptionItemProps = { type: OptionType; value?: string; onLayout?: (event: LayoutChangeEvent) => void; + descriptionNumberOfLines?: number; } const OptionItem = ({ @@ -141,6 +150,7 @@ const OptionItem = ({ type, value, onLayout, + descriptionNumberOfLines, }: OptionItemProps) => { const theme = useTheme(); const styles = getStyleSheet(theme); @@ -262,6 +272,7 @@ const OptionItem = ({ {description} diff --git a/app/products/calls/components/message_bar.tsx b/app/products/calls/components/message_bar.tsx index a63e82160..3a5ed10d9 100644 --- a/app/products/calls/components/message_bar.tsx +++ b/app/products/calls/components/message_bar.tsx @@ -14,8 +14,8 @@ import {useTheme} from '@context/theme'; import {makeStyleSheetFromTheme} from '@utils/theme'; import {typography} from '@utils/typography'; -import type {MessageBarType} from '@app/constants/calls'; import type {CallsTheme} from '@calls/types/calls'; +import type {MessageBarType} from '@constants/calls'; type Props = { type: MessageBarType; diff --git a/app/screens/post_priority_picker/components/picker_option.tsx b/app/screens/post_priority_picker/components/picker_option.tsx index 74defc931..a4fc65e17 100644 --- a/app/screens/post_priority_picker/components/picker_option.tsx +++ b/app/screens/post_priority_picker/components/picker_option.tsx @@ -2,36 +2,26 @@ // See LICENSE.txt for license information. import React from 'react'; +import {StyleSheet} from 'react-native'; import OptionItem, {type OptionItemProps, type OptionType} from '@components/option_item'; -import {useTheme} from '@context/theme'; -import {makeStyleSheetFromTheme} from '@utils/theme'; -import {typography} from '@utils/typography'; -const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ +const style = StyleSheet.create({ labelContainer: { alignItems: 'flex-start', }, - optionLabelText: { - color: theme.centerChannelColor, - ...typography('Body', 200, 'Regular'), - }, -})); +}); type Props = Omit & { type?: OptionType; } const PickerOption = ({type, ...rest}: Props) => { - const theme = useTheme(); - const style = getStyleSheet(theme); - const testID = `post_priority_picker_item.${rest.value || 'standard'}`; return ( void; } +const TEXT_HEIGHT = 24; // typography 200 line height +const BUTTON_PADDING = 15; +const FOOTER_PADDING = 20; +const FOOTER_PADDING_BOTTOM_TABLET_ADJUST = 12; +export const FOOTER_HEIGHT = (FOOTER_PADDING * 2) + (BUTTON_PADDING * 2) + TEXT_HEIGHT; + const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ container: { backgroundColor: theme.centerChannelBg, borderTopColor: changeOpacity(theme.centerChannelColor, 0.16), borderTopWidth: 1, - paddingTop: 20, + paddingTop: FOOTER_PADDING, flexDirection: 'row', paddingHorizontal: 20, }, @@ -30,7 +36,7 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ backgroundColor: changeOpacity(theme.buttonBg, 0.08), borderRadius: 4, flex: 1, - paddingVertical: 15, + paddingVertical: BUTTON_PADDING, }, cancelButtonText: { color: theme.buttonBg, @@ -42,7 +48,7 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ borderRadius: 4, flex: 1, marginLeft: 8, - paddingVertical: 15, + paddingVertical: BUTTON_PADDING, }, applyButtonText: { color: theme.buttonColor, @@ -59,7 +65,7 @@ const PostPriorityPickerFooter = ({onCancel, onSubmit, ...props}: Props) => { ({ container: { backgroundColor: theme.centerChannelBg, @@ -59,16 +66,16 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ }, optionsContainer: { - paddingTop: 12, + paddingTop: OPTIONS_PADDING, }, optionsSeparator: { backgroundColor: changeOpacity(theme.centerChannelColor, 0.08), - height: 1, + height: OPTIONS_SEPARATOR_HEIGHT, }, toggleOptionContainer: { - marginTop: 16, + marginTop: TOGGLE_OPTION_MARGIN_TOP, }, })); @@ -98,17 +105,18 @@ const PostPriorityPicker = ({ const displayPersistentNotifications = isPersistenNotificationsEnabled && data.priority === PostPriorityType.URGENT; const snapPoints = useMemo(() => { - let COMPONENT_HEIGHT = 280; + const paddingBottom = 10; + const bottomSheetAdjust = 5; + let COMPONENT_HEIGHT = TITLE_HEIGHT + OPTIONS_PADDING + FOOTER_HEIGHT + bottomSheetSnapPoint(3, ITEM_HEIGHT, bottom) + paddingBottom + bottomSheetAdjust; if (isPostAcknowledgementEnabled) { - COMPONENT_HEIGHT += 75; - + COMPONENT_HEIGHT += OPTIONS_SEPARATOR_HEIGHT + TOGGLE_OPTION_MARGIN_TOP + getItemHeightWithDescription(2); if (displayPersistentNotifications) { - COMPONENT_HEIGHT += 75; + COMPONENT_HEIGHT += OPTIONS_SEPARATOR_HEIGHT + TOGGLE_OPTION_MARGIN_TOP + getItemHeightWithDescription(2); } } - return [1, bottomSheetSnapPoint(1, COMPONENT_HEIGHT, bottom)]; + return [1, COMPONENT_HEIGHT]; }, [displayPersistentNotifications, isPostAcknowledgementEnabled, bottom]); const handleUpdatePriority = useCallback((priority: PostPriority['priority']) => { @@ -185,6 +193,7 @@ const PostPriorityPicker = ({ icon='check-circle-outline' type='toggle' selected={data.requested_ack} + descriptionNumberOfLines={2} /> {displayPersistentNotifications && ( @@ -196,6 +205,7 @@ const PostPriorityPicker = ({ icon='bell-ring-outline' type='toggle' selected={data.persistent_notifications} + descriptionNumberOfLines={2} /> )} diff --git a/app/screens/post_priority_picker/utils.ts b/app/screens/post_priority_picker/utils.ts index f07a74bed..f2df2cb40 100644 --- a/app/screens/post_priority_picker/utils.ts +++ b/app/screens/post_priority_picker/utils.ts @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {t} from '@app/i18n'; +import {t} from '@i18n'; export const labels = { standard: {