Skip to content

Commit fc3d793

Browse files
authored
Support passing useSafeArea for Picker modal contect (usefull for Expo users) (#1899)
1 parent dca74af commit fc3d793

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

generatedTypes/src/components/picker/types.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ export interface PickerBaseProps extends Omit<TextFieldProps, 'value' | 'onChang
145145
* Callback for modal onShow event
146146
*/
147147
onShow?: () => void;
148+
/**
149+
* Add safe area in the Picker modal view
150+
*/
151+
useSafeArea?: boolean;
148152
/**
149153
* Component test id
150154
*/
@@ -211,5 +215,5 @@ export interface PickerContextProps extends Pick<PickerProps, 'migrate' | 'value
211215
onSelectedLayout: (event: any) => any;
212216
selectionLimit: PickerProps['selectionLimit'];
213217
}
214-
export declare type PickerItemsListProps = Pick<PropsWithChildren<PickerProps>, 'topBarProps' | 'listProps' | 'children' | 'showSearch' | 'searchStyle' | 'searchPlaceholder' | 'onSearchChange' | 'renderCustomSearch' | 'testID'>;
218+
export declare type PickerItemsListProps = Pick<PropsWithChildren<PickerProps>, 'topBarProps' | 'listProps' | 'children' | 'showSearch' | 'searchStyle' | 'searchPlaceholder' | 'onSearchChange' | 'renderCustomSearch' | 'useSafeArea' | 'testID'>;
215219
export {};

src/components/picker/PickerItemsList.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const PickerItemsList = (props: PickerItemsListProps) => {
2020
searchPlaceholder = 'Search...',
2121
onSearchChange,
2222
renderCustomSearch,
23+
useSafeArea,
2324
testID
2425
} = props;
2526

@@ -51,10 +52,11 @@ const PickerItemsList = (props: PickerItemsListProps) => {
5152

5253
const renderItem = useCallback(({index}) => {
5354
return React.Children.toArray(children)[index];
54-
}, [children]);
55+
},
56+
[children]);
5557

5658
return (
57-
<>
59+
<View useSafeArea={useSafeArea}>
5860
<Modal.TopBar {...topBarProps}/>
5961
{renderSearchInput()}
6062

@@ -65,7 +67,7 @@ const PickerItemsList = (props: PickerItemsListProps) => {
6567
keyExtractor={keyExtractor}
6668
{...listProps}
6769
/>
68-
</>
70+
</View>
6971
);
7072
};
7173

src/components/picker/api/picker.api.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
"type": "FlatListProps",
9191
"description": "Pass props to the list component that wraps the picker options (allows to control FlatList behavior)"
9292
},
93-
{"name": "pickerModalProps", "type": "ModalProps", "description": "Pass props to the picker modal"}
93+
{"name": "pickerModalProps", "type": "ModalProps", "description": "Pass props to the picker modal"},
94+
{"name": "useSafeArea", "type": "boolean", "description": "Add safe area in the Picker modal view"}
9495
],
9596
"snippet": [
9697
"<Picker",
@@ -104,3 +105,4 @@
104105
"</Picker>"
105106
]
106107
}
108+

src/components/picker/new.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const Picker = (props: PropsWithChildren<PickerProps> & ForwardRefInjectedProps
5959
getItemValue,
6060
renderItem,
6161
children,
62+
useSafeArea,
6263
migrate,
6364
migrateTextField,
6465
...others
@@ -168,6 +169,7 @@ const Picker = (props: PropsWithChildren<PickerProps> & ForwardRefInjectedProps
168169
onSearchChange={_onSearchChange}
169170
renderCustomSearch={renderCustomSearch}
170171
listProps={listProps}
172+
useSafeArea={useSafeArea}
171173
>
172174
{filteredChildren}
173175
</PickerItemsList>
@@ -186,7 +188,8 @@ const Picker = (props: PropsWithChildren<PickerProps> & ForwardRefInjectedProps
186188
_onSearchChange,
187189
renderCustomSearch,
188190
listProps,
189-
filteredChildren
191+
filteredChildren,
192+
useSafeArea
190193
]);
191194

192195
if (useNativePicker) {

src/components/picker/types.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ export interface PickerBaseProps extends Omit<TextFieldProps, 'value' | 'onChang
158158
* Callback for modal onShow event
159159
*/
160160
onShow?: () => void;
161+
/**
162+
* Add safe area in the Picker modal view
163+
*/
164+
useSafeArea?: boolean;
161165
/**
162166
* Component test id
163167
*/
@@ -241,5 +245,6 @@ export type PickerItemsListProps = Pick<
241245
| 'searchPlaceholder'
242246
| 'onSearchChange'
243247
| 'renderCustomSearch'
248+
| 'useSafeArea'
244249
| 'testID'
245250
>;

0 commit comments

Comments
 (0)