Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function CurrencySelector({value = [], selectionListTextInputStyle, selectionLis
items={currencyOptions}
autoFocus={autoFocus}
isSearchable
isNegatable
Comment thread
JS00001 marked this conversation as resolved.
Resolved
selectionListTextInputStyle={selectionListTextInputStyle}
selectionListStyle={selectionListStyle}
footer={footer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function ExportedToSelector({value = [], policyID, selectionListTextInputStyle,
value={selectedExportedTo}
items={sortedExportedToPickerOptions}
isSearchable={exportedToPickerOptions.length >= CONST.STANDARD_LIST_ITEM_LIMIT}
isNegatable
autoFocus={autoFocus}
selectionListTextInputStyle={selectionListTextInputStyle}
selectionListStyle={selectionListStyle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function MultiSelectListFilterContent({baseFilterKey, value = [], type = CONST.S
items={items}
value={multiSelectValues}
selectionListStyle={selectionListStyle}
isNegatable={isFilterNegatable(baseFilterKey)}
footer={footer}
onChange={(selectedItems) => {
onChange(selectedItems.map((item) => item.value));
Expand Down Expand Up @@ -222,6 +223,7 @@ function ListFilterContent({
<UserSelector
value={typeof value === 'object' ? value : undefined}
key={baseFilterKey}
isNegatable={isFilterKeyNegatable}
selectionListTextInputStyle={selectionListTextInputStyle}
selectionListStyle={selectionListStyle}
autoFocus={autoFocus}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ type ListFilterWrapperProps = {
hasTitle?: boolean;
hasHeader?: boolean;
isSearchable?: boolean;
isNegatable?: boolean;
extraHeight?: number;
};

function ListFilterView({children, itemCount, itemHeight, hasTitle = true, hasHeader, isSearchable, extraHeight}: ListFilterWrapperProps) {
function ListFilterView({children, itemCount, itemHeight, hasTitle = true, hasHeader, isSearchable, isNegatable, extraHeight}: ListFilterWrapperProps) {
const styles = useThemeStyles();
const {windowHeight} = useWindowDimensions();
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
Expand All @@ -34,6 +35,7 @@ function ListFilterView({children, itemCount, itemHeight, hasTitle = true, hasHe
hasTitle: hasTitle && !hasHeader && isSmallScreenWidth,
hasHeader,
isSearchable,
isNegatable,
extraHeight,
}),
]}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Search/FilterComponents/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function MultiSelect<T extends string>({
value,
items,
isSearchable,
isNegatable,
searchPlaceholder,
selectionListTextInputStyle,
selectionListStyle,
Expand Down Expand Up @@ -124,6 +125,7 @@ function MultiSelect<T extends string>({
<ListFilterView
itemCount={listData.length}
isSearchable={isSearchable}
isNegatable={isNegatable}
>
{loading ? (
<View style={[styles.flex1, styles.justifyContentCenter, styles.alignItemsCenter]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function NegatableFilter({baseFilterKey, isNegated, children, style, onNegationC
const negative = translate(baseFilterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.HAS ? 'search.filters.filterType.has.negative' : 'search.filters.filterType.is.negative');

return (
<View style={[styles.flexGrow1, styles.gap3, style]}>
<View style={[styles.gap3, style]}>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.justifyContentBetween, styles.ph5, styles.gap2]}>
<Text style={[styles.textLabelSupporting]}>{translate('search.filters.filterType.label')}</Text>
<View style={[styles.border, styles.negatableFilterButtons]}>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Search/FilterComponents/UserSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import ListFilterWrapper from './ListFilterViewWrapper';

type UserSelectorProps = SearchFilterCommonProps<string[] | undefined>;

function UserSelector({value = [], selectionListTextInputStyle, selectionListStyle, autoFocus, ready = true, footer, onChange}: UserSelectorProps) {
function UserSelector({value = [], isNegatable, selectionListTextInputStyle, selectionListStyle, autoFocus, ready = true, footer, onChange}: UserSelectorProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const personalDetails = usePersonalDetails();
Expand Down Expand Up @@ -96,6 +96,7 @@ function UserSelector({value = [], selectionListTextInputStyle, selectionListSty
<ListFilterWrapper
itemCount={listData.length}
isSearchable={shouldShowSearchInput}
isNegatable={isNegatable}
>
<SelectionList
data={listData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function WorkspaceSelector({value = [], selectionListTextInputStyle, selectionLi
<ListFilterView
itemCount={listData.length}
isSearchable={shouldShowWorkspaceSearchInput}
isNegatable
>
{isAppLoadPending && !isOffline ? (
<View style={[styles.flex1, styles.justifyContentCenter, styles.alignItemsCenter]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function ListFilterContentPopupWrapper({baseFilterKey, value, isNegated: initial
isNegated={isNegated}
type={type}
policyID={policyID}
style={[styles.mt6]}
style={[styles.mt6, styles.flex1]}
selectionListTextInputStyle={[!isFilterKeyNegatable && [styles.pt5, styles.pb1]]}
selectionListStyle={{contentContainerStyle: [isFilterKeyNegatable ? styles.pb2 : styles.pv2]}}
onChange={(newValue) => onChange(newValue, isNegated)}
Expand Down
1 change: 1 addition & 0 deletions src/components/Search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ type SearchFilterCommonProps<T> = {
selectionListStyle?: SelectionListStyle;
autoFocus?: boolean;
ready?: boolean;
isNegatable?: boolean;
footer?: React.ReactNode;
onChange: (value: T) => void;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import type {ListFilterContentWrapperProps} from '@components/Search/FilterCompo
import ListFilterContent from '@components/Search/FilterComponents/ListFilterContent';

import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';

import CONST from '@src/CONST';

import React, {useState} from 'react';

function ListFilterContentPageWrapper({baseFilterKey, value: initialValue, isNegated: initialIsNegated, type, policyID, ready, onChange}: ListFilterContentWrapperProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const [value, setValue] = useState(initialValue);
const [isNegated, setIsNegatedValue] = useState(initialIsNegated);

Expand All @@ -24,6 +26,7 @@ function ListFilterContentPageWrapper({baseFilterKey, value: initialValue, isNeg
ready={ready}
onChange={setValue}
onNegationChange={setIsNegatedValue}
style={[styles.flex1]}
footer={
<Button
variant={CONST.BUTTON_VARIANT.SUCCESS}
Expand Down
6 changes: 5 additions & 1 deletion src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type SelectionListPopover = {
hasHeader?: boolean;
hasButton?: boolean;
isSearchable?: boolean;
isNegatable?: boolean;
extraHeight?: number;
};

Expand Down Expand Up @@ -6776,16 +6777,19 @@ const dynamicStyles = (theme: ThemeColors) =>
hasHeader,
hasButton = true,
isSearchable,
isNegatable,
extraHeight = 0,
}: SelectionListPopover) => {
const MODAL_VERTICAL_PADDING = 32;
const BUTTON_HEIGHT = hasButton ? 48 : 0;
const HEADER_HEIGHT = hasHeader ? 48 : 0;
const TITLE_HEIGHT = hasTitle ? 34 : 0;
const SEARCHBAR_HEIGHT = isSearchable ? 64 : 0;
const NEGATION_TOGGLE_BORDER_WIDTH = 1;
const NEGATION_TOGGLE_HEIGHT = isNegatable ? variables.componentSizeSmall + NEGATION_TOGGLE_BORDER_WIDTH * 2 + spacing.gap3.gap : 0;

const ESTIMATED_LIST_HEIGHT = itemCount * itemHeight + SEARCHBAR_HEIGHT + extraHeight;
const ESTIMATED_NON_LIST_HEIGHT = BUTTON_HEIGHT + HEADER_HEIGHT + TITLE_HEIGHT + MODAL_VERTICAL_PADDING;
const ESTIMATED_NON_LIST_HEIGHT = BUTTON_HEIGHT + HEADER_HEIGHT + TITLE_HEIGHT + MODAL_VERTICAL_PADDING + NEGATION_TOGGLE_HEIGHT;

const heightRatio = isInLandscapeMode ? CONST.MODAL_MAX_HEIGHT_TO_WINDOW_HEIGHT_RATIO_LANDSCAPE_MODE : CONST.MODAL_MAX_HEIGHT_TO_WINDOW_HEIGHT_RATIO;

Expand Down
Loading