stream-chat-react-native-core 4.1.3-beta.1 → 4.1.4-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -291,13 +291,13 @@ var AttachmentPicker = _react["default"].forwardRef(function (props, ref) {
291
291
  };
292
292
  }, [selectedPicker]);
293
293
  (0, _react.useEffect)(function () {
294
- if (_reactNative.Platform.OS === 'ios') {
295
- _reactNative.Keyboard.addListener('keyboardWillShow', hideAttachmentPicker);
296
- } else {
297
- _reactNative.Keyboard.addListener('keyboardDidShow', hideAttachmentPicker);
298
- }
299
-
294
+ var keyboardSubscription = _reactNative.Platform.OS === 'ios' ? _reactNative.Keyboard.addListener('keyboardWillShow', hideAttachmentPicker) : _reactNative.Keyboard.addListener('keyboardDidShow', hideAttachmentPicker);
300
295
  return function () {
296
+ if (keyboardSubscription != null && keyboardSubscription.remove) {
297
+ keyboardSubscription.remove();
298
+ return;
299
+ }
300
+
301
301
  if (_reactNative.Platform.OS === 'ios') {
302
302
  _reactNative.Keyboard.removeListener('keyboardWillShow', hideAttachmentPicker);
303
303
  } else {
@@ -354,7 +354,7 @@ var AttachmentPicker = _react["default"].forwardRef(function (props, ref) {
354
354
  __self: _this,
355
355
  __source: {
356
356
  fileName: _jsxFileName,
357
- lineNumber: 346,
357
+ lineNumber: 351,
358
358
  columnNumber: 9
359
359
  }
360
360
  }, _react["default"].createElement(_bottomSheet.BottomSheetFlatList, {
@@ -373,7 +373,7 @@ var AttachmentPicker = _react["default"].forwardRef(function (props, ref) {
373
373
  __self: _this,
374
374
  __source: {
375
375
  fileName: _jsxFileName,
376
- lineNumber: 362,
376
+ lineNumber: 367,
377
377
  columnNumber: 11
378
378
  }
379
379
  })), selectedPicker === 'images' && photoError && _react["default"].createElement(AttachmentPickerError, {
@@ -384,7 +384,7 @@ var AttachmentPicker = _react["default"].forwardRef(function (props, ref) {
384
384
  __self: _this,
385
385
  __source: {
386
386
  fileName: _jsxFileName,
387
- lineNumber: 377,
387
+ lineNumber: 382,
388
388
  columnNumber: 11
389
389
  }
390
390
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["AttachmentPicker.tsx"],"names":["styles","StyleSheet","create","container","flexGrow","overlay","alignItems","flex","screenHeight","fullScreenHeight","Dimensions","get","height","AttachmentImage","props","ImageOverlaySelectedComponent","numberOfAttachmentPickerImageColumns","onPress","selected","uri","theme","attachmentPicker","image","imageOverlay","colors","size","margin","width","backgroundColor","renderImage","item","asset","maxNumberOfFiles","setSelectedImages","images","filter","length","AttachmentPicker","React","forwardRef","ref","AttachmentPickerBottomSheetHandle","attachmentPickerBottomSheetHandleHeight","attachmentPickerBottomSheetHeight","AttachmentPickerError","attachmentPickerErrorButtonText","AttachmentPickerErrorImage","attachmentPickerErrorText","numberOfAttachmentImagesToLoadPerCall","translucentStatusBar","bottomSheetContentContainer","white","closePicker","selectedImages","selectedPicker","setSelectedPicker","topInset","currentIndex","setCurrentIndex","endCursor","setEndCursor","photoError","setPhotoError","hasNextPage","setHasNextPage","loadingPhotos","setLoadingPhotos","photos","setPhotos","hideAttachmentPicker","undefined","current","close","getMorePhotos","after","first","results","assets","console","log","backAction","backHandler","BackHandler","addEventListener","remove","Platform","OS","Keyboard","addListener","removeListener","selectedPhotos","map","some","handleHeight","statusBarHeight","StatusBar","currentHeight","bottomBarHeight","androidBottomBarHeightAdjustment","snapPoints","index","opacity","displayName"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AAWA;;AAQA;;AACA;;AACA;;AACA;;;;;;;;;AAEA,IAAMA,MAAM,GAAGC,wBAAWC,MAAX,CAAkB;AAC/BC,EAAAA,SAAS,EAAE;AACTC,IAAAA,QAAQ,EAAE;AADD,GADoB;AAI/BC,EAAAA,OAAO,EAAE;AACPC,IAAAA,UAAU,EAAE,UADL;AAEPC,IAAAA,IAAI,EAAE;AAFC;AAJsB,CAAlB,CAAf;;AAUA,IAAMC,YAAY,GAAG,eAAG,GAAH,CAArB;;AACA,IAA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AAA;AAAA;AAAA;AAAA;AAAA,IAhBF,CADF,EA+BGyB,cAAc,KAAK,QAAnB,IAA+BO,UAA/B,IACC,gCAAC,qBAAD;AACE,IAAA,iCAAiC,EAAElB,iCADrC;AAEE,IAAA,+BAA+B,EAAEE,+BAFnC;AAGE,IAAA,0BAA0B,EAAEC,0BAH9B;AAIE,IAAA,yBAAyB,EAAEC,yBAJ7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAhCJ,CADF;AA0CD,CA7N6B,CAAzB;;;AAgOPV,gBAAgB,CAACiE,WAAjB,GAA+B,kBAA/B","sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport {\n BackHandler,\n Dimensions,\n ImageBackground,\n Keyboard,\n Platform,\n StatusBar,\n StyleSheet,\n View,\n} from 'react-native';\n\nimport BottomSheet, {\n BottomSheetFlatList,\n BottomSheetHandleProps,\n TouchableOpacity,\n} from '@gorhom/bottom-sheet';\n\nimport type { AttachmentPickerErrorProps } from './components/AttachmentPickerError';\n\nimport { useAttachmentPickerContext } from '../../contexts/attachmentPickerContext/AttachmentPickerContext';\nimport { useTheme } from '../../contexts/themeContext/ThemeContext';\nimport { Asset, getPhotos } from '../../native';\nimport { vh, vw } from '../../utils/utils';\n\nconst styles = StyleSheet.create({\n container: {\n flexGrow: 1,\n },\n overlay: {\n alignItems: 'flex-end',\n flex: 1,\n },\n});\n\nconst screenHeight = vh(100);\nconst fullScreenHeight = Dimensions.get('screen').height;\n\ntype AttachmentImageProps = {\n ImageOverlaySelectedComponent: React.ComponentType;\n onPress: () => void;\n selected: boolean;\n uri: string;\n numberOfAttachmentPickerImageColumns?: number;\n};\n\nconst AttachmentImage: React.FC<AttachmentImageProps> = (props) => {\n const {\n ImageOverlaySelectedComponent,\n numberOfAttachmentPickerImageColumns,\n onPress,\n selected,\n uri,\n } = props;\n const {\n theme: {\n attachmentPicker: { image, imageOverlay },\n colors: { overlay },\n },\n } = useTheme();\n\n const size = vw(100) / (numberOfAttachmentPickerImageColumns || 3) - 2;\n\n return (\n <TouchableOpacity onPress={onPress}>\n <ImageBackground\n source={{ uri }}\n style={[\n {\n height: size,\n margin: 1,\n width: size,\n },\n image,\n ]}\n >\n {selected && (\n <View style={[styles.overlay, { backgroundColor: overlay }, imageOverlay]}>\n <ImageOverlaySelectedComponent />\n </View>\n )}\n </ImageBackground>\n </TouchableOpacity>\n );\n};\n\nconst renderImage = ({\n item,\n}: {\n item: {\n asset: Asset;\n ImageOverlaySelectedComponent: React.ComponentType;\n maxNumberOfFiles: number;\n selected: boolean;\n setSelectedImages: React.Dispatch<React.SetStateAction<Asset[]>>;\n numberOfAttachmentPickerImageColumns?: number;\n };\n}) => {\n const {\n asset,\n ImageOverlaySelectedComponent,\n maxNumberOfFiles,\n numberOfAttachmentPickerImageColumns,\n selected,\n setSelectedImages,\n } = item;\n const onPress = () => {\n if (selected) {\n setSelectedImages((images) => images.filter((image) => image.uri !== asset.uri));\n } else {\n setSelectedImages((images) => {\n if (images.length >= maxNumberOfFiles) {\n return images;\n }\n return [...images, asset];\n });\n }\n };\n\n return (\n <AttachmentImage\n ImageOverlaySelectedComponent={ImageOverlaySelectedComponent}\n numberOfAttachmentPickerImageColumns={numberOfAttachmentPickerImageColumns}\n onPress={onPress}\n selected={selected}\n uri={asset.uri}\n />\n );\n};\n\nexport type AttachmentPickerProps = {\n /**\n * Custom UI component to render [draggable handle](https://github.com/GetStream/stream-chat-react-native/blob/master/screenshots/docs/1.png) of attachment picker.\n *\n * **Default** [AttachmentPickerBottomSheetHandle](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/AttachmentPicker/components/AttachmentPickerBottomSheetHandle.tsx)\n */\n AttachmentPickerBottomSheetHandle: React.FC<BottomSheetHandleProps>;\n /**\n * Custom UI component to render error component while opening attachment picker.\n *\n * **Default** [AttachmentPickerError](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/AttachmentPicker/components/AttachmentPickerError.tsx)\n */\n AttachmentPickerError: React.ComponentType<AttachmentPickerErrorProps>;\n /**\n * Custom UI component to render error image for attachment picker\n *\n * **Default** [AttachmentPickerErrorImage](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/AttachmentPicker/components/AttachmentPickerErrorImage.tsx)\n */\n AttachmentPickerErrorImage: React.ComponentType;\n /**\n * Custom UI component to render overlay component, that shows up on top of [selected image](https://github.com/GetStream/stream-chat-react-native/blob/master/screenshots/docs/1.png) (with tick mark)\n *\n * **Default** [ImageOverlaySelectedComponent](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/AttachmentPicker/components/ImageOverlaySelectedComponent.tsx)\n */\n ImageOverlaySelectedComponent: React.ComponentType;\n attachmentPickerBottomSheetHandleHeight?: number;\n attachmentPickerBottomSheetHeight?: number;\n attachmentPickerErrorButtonText?: string;\n attachmentPickerErrorText?: string;\n numberOfAttachmentImagesToLoadPerCall?: number;\n numberOfAttachmentPickerImageColumns?: number;\n translucentStatusBar?: boolean;\n};\n\nexport const AttachmentPicker = React.forwardRef(\n (props: AttachmentPickerProps, ref: React.ForwardedRef<BottomSheet>) => {\n const {\n AttachmentPickerBottomSheetHandle,\n attachmentPickerBottomSheetHandleHeight,\n attachmentPickerBottomSheetHeight,\n AttachmentPickerError,\n attachmentPickerErrorButtonText,\n AttachmentPickerErrorImage,\n attachmentPickerErrorText,\n ImageOverlaySelectedComponent,\n numberOfAttachmentImagesToLoadPerCall,\n numberOfAttachmentPickerImageColumns,\n translucentStatusBar,\n } = props;\n\n const {\n theme: {\n attachmentPicker: { bottomSheetContentContainer },\n colors: { white },\n },\n } = useTheme();\n const {\n closePicker,\n maxNumberOfFiles,\n selectedImages,\n selectedPicker,\n setSelectedImages,\n setSelectedPicker,\n topInset,\n } = useAttachmentPickerContext();\n\n const [currentIndex, setCurrentIndex] = useState(-1);\n const [endCursor, setEndCursor] = useState<string>();\n const [photoError, setPhotoError] = useState(false);\n const [hasNextPage, setHasNextPage] = useState(true);\n const [loadingPhotos, setLoadingPhotos] = useState(false);\n const [photos, setPhotos] = useState<Asset[]>([]);\n\n const hideAttachmentPicker = () => {\n setSelectedPicker(undefined);\n if ((ref as React.MutableRefObject<BottomSheet>)?.current) {\n (ref as React.MutableRefObject<BottomSheet>).current.close();\n }\n };\n\n const getMorePhotos = async () => {\n if (hasNextPage && !loadingPhotos && currentIndex > -1 && selectedPicker === 'images') {\n setLoadingPhotos(true);\n try {\n const results = await getPhotos({\n after: endCursor,\n first: numberOfAttachmentImagesToLoadPerCall ?? 60,\n });\n if (endCursor) {\n setPhotos([...photos, ...results.assets]);\n } else {\n setPhotos(results.assets);\n }\n setEndCursor(results.endCursor);\n setHasNextPage(results.hasNextPage || false);\n } catch (error) {\n console.log(error);\n setPhotoError(true);\n }\n setLoadingPhotos(false);\n }\n };\n\n useEffect(() => {\n const backAction = () => {\n if (selectedPicker) {\n setSelectedPicker(undefined);\n closePicker();\n return true;\n }\n\n return false;\n };\n\n const backHandler = BackHandler.addEventListener('hardwareBackPress', backAction);\n\n return () => backHandler.remove();\n }, [selectedPicker]);\n\n useEffect(() => {\n if (Platform.OS === 'ios') {\n Keyboard.addListener('keyboardWillShow', hideAttachmentPicker);\n } else {\n Keyboard.addListener('keyboardDidShow', hideAttachmentPicker);\n }\n\n return () => {\n if (Platform.OS === 'ios') {\n Keyboard.removeListener('keyboardWillShow', hideAttachmentPicker);\n } else {\n Keyboard.removeListener('keyboardDidShow', hideAttachmentPicker);\n }\n };\n }, []);\n\n useEffect(() => {\n if (currentIndex < 0) {\n setSelectedPicker(undefined);\n if (!loadingPhotos) {\n setEndCursor(undefined);\n setHasNextPage(true);\n }\n }\n }, [currentIndex]);\n\n useEffect(() => {\n if (\n selectedPicker === 'images' &&\n endCursor === undefined &&\n currentIndex > -1 &&\n !loadingPhotos\n ) {\n setPhotoError(false);\n getMorePhotos();\n }\n }, [currentIndex, selectedPicker]);\n\n const selectedPhotos = photos.map((asset) => ({\n asset,\n ImageOverlaySelectedComponent,\n maxNumberOfFiles,\n numberOfAttachmentPickerImageColumns,\n selected: selectedImages.some((image) => image.uri === asset.uri),\n setSelectedImages,\n }));\n\n const handleHeight = attachmentPickerBottomSheetHandleHeight || 20;\n\n /**\n * This is to handle issues with Android measurements coming back incorrect.\n * If the StatusBar height is perfectly 1/2 of the difference between the two\n * dimensions for screen and window, it is incorrect and we need to account for\n * this. If you use a translucent header bar more adjustments are needed.\n */\n const statusBarHeight = StatusBar.currentHeight ?? 0;\n const bottomBarHeight = fullScreenHeight - screenHeight - statusBarHeight;\n const androidBottomBarHeightAdjustment =\n Platform.OS === 'android'\n ? bottomBarHeight === statusBarHeight\n ? translucentStatusBar\n ? 0\n : StatusBar.currentHeight ?? 0\n : translucentStatusBar\n ? bottomBarHeight > statusBarHeight\n ? -bottomBarHeight + statusBarHeight\n : bottomBarHeight > 0\n ? -statusBarHeight\n : 0\n : bottomBarHeight > 0\n ? 0\n : statusBarHeight\n : 0;\n\n /**\n * Snap points changing cause a rerender of the position,\n * this is an issue if you are calling close on the bottom sheet.\n */\n const snapPoints = useMemo(\n () => [\n attachmentPickerBottomSheetHeight ??\n 308 + (fullScreenHeight - screenHeight + androidBottomBarHeightAdjustment) - handleHeight,\n fullScreenHeight - topInset - handleHeight,\n ],\n [\n androidBottomBarHeightAdjustment,\n attachmentPickerBottomSheetHeight,\n fullScreenHeight,\n handleHeight,\n screenHeight,\n topInset,\n ],\n );\n\n return (\n <>\n <BottomSheet\n containerHeight={fullScreenHeight}\n enablePanDownToClose={true}\n handleComponent={\n /**\n * using `null` here instead of `style={{ opacity: photoError ? 0 : 1 }}`\n * as opacity is not an allowed style\n */\n photoError ? null : AttachmentPickerBottomSheetHandle\n }\n handleHeight={handleHeight}\n index={-1}\n onChange={(index: number) => setCurrentIndex(index)}\n ref={ref}\n snapPoints={snapPoints}\n >\n <BottomSheetFlatList\n contentContainerStyle={[\n styles.container,\n { backgroundColor: white },\n bottomSheetContentContainer,\n { opacity: photoError ? 0 : 1 },\n ]}\n data={selectedPhotos}\n keyExtractor={(item) => item.asset.uri}\n numColumns={numberOfAttachmentPickerImageColumns ?? 3}\n onEndReached={getMorePhotos}\n renderItem={renderImage}\n />\n </BottomSheet>\n {selectedPicker === 'images' && photoError && (\n <AttachmentPickerError\n attachmentPickerBottomSheetHeight={attachmentPickerBottomSheetHeight}\n attachmentPickerErrorButtonText={attachmentPickerErrorButtonText}\n AttachmentPickerErrorImage={AttachmentPickerErrorImage}\n attachmentPickerErrorText={attachmentPickerErrorText}\n />\n )}\n </>\n );\n },\n);\n\nAttachmentPicker.displayName = 'AttachmentPicker';\n"]}
1
+ {"version":3,"sources":["AttachmentPicker.tsx"],"names":["styles","StyleSheet","create","container","flexGrow","overlay","alignItems","flex","screenHeight","fullScreenHeight","Dimensions","get","height","AttachmentImage","props","ImageOverlaySelectedComponent","numberOfAttachmentPickerImageColumns","onPress","selected","uri","theme","attachmentPicker","image","imageOverlay","colors","size","margin","width","backgroundColor","renderImage","item","asset","maxNumberOfFiles","setSelectedImages","images","filter","length","AttachmentPicker","React","forwardRef","ref","AttachmentPickerBottomSheetHandle","attachmentPickerBottomSheetHandleHeight","attachmentPickerBottomSheetHeight","AttachmentPickerError","attachmentPickerErrorButtonText","AttachmentPickerErrorImage","attachmentPickerErrorText","numberOfAttachmentImagesToLoadPerCall","translucentStatusBar","bottomSheetContentContainer","white","closePicker","selectedImages","selectedPicker","setSelectedPicker","topInset","currentIndex","setCurrentIndex","endCursor","setEndCursor","photoError","setPhotoError","hasNextPage","setHasNextPage","loadingPhotos","setLoadingPhotos","photos","setPhotos","hideAttachmentPicker","undefined","current","close","getMorePhotos","after","first","results","assets","console","log","backAction","backHandler","BackHandler","addEventListener","remove","keyboardSubscription","Platform","OS","Keyboard","addListener","removeListener","selectedPhotos","map","some","handleHeight","statusBarHeight","StatusBar","currentHeight","bottomBarHeight","androidBottomBarHeightAdjustment","snapPoints","index","opacity","displayName"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AAWA;;AAQA;;AACA;;AACA;;AACA;;;;;;;;;A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uB;AAAnB,KAFqB,EAGrBD,2BAHqB,EAIrB;AAAEoD,MAAAA,OAAO,EAAEzC,UAAU,GAAG,CAAH,GAAO;AAA5B,KAJqB,CADzB;AAOE,IAAA,IAAI,EAAE8B,cAPR;AAQE,IAAA,YAAY,EAAE,sBAAC7D,IAAD;AAAA,aAAUA,IAAI,CAACC,KAAL,CAAWZ,GAArB;AAAA,KARhB;AASE,IAAA,UAAU,EAAEH,oCAAF,WAAEA,oCAAF,GAA0C,CATtD;AAUE,IAAA,YAAY,EAAEyD,aAVhB;AAWE,IAAA,UAAU,EAAE5C,WAXd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAhBF,CADF,EA+BGyB,cAAc,KAAK,QAAnB,IAA+BO,UAA/B,IACC,gCAAC,qBAAD;AACE,IAAA,iCAAiC,EAAElB,iCADrC;AAEE,IAAA,+BAA+B,EAAEE,+BAFnC;AAGE,IAAA,0BAA0B,EAAEC,0BAH9B;AAIE,IAAA,yBAAyB,EAAEC,yBAJ7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAhCJ,CADF;AA0CD,CAlO6B,CAAzB;;;AAqOPV,gBAAgB,CAACkE,WAAjB,GAA+B,kBAA/B","sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport {\n BackHandler,\n Dimensions,\n ImageBackground,\n Keyboard,\n Platform,\n StatusBar,\n StyleSheet,\n View,\n} from 'react-native';\n\nimport BottomSheet, {\n BottomSheetFlatList,\n BottomSheetHandleProps,\n TouchableOpacity,\n} from '@gorhom/bottom-sheet';\n\nimport type { AttachmentPickerErrorProps } from './components/AttachmentPickerError';\n\nimport { useAttachmentPickerContext } from '../../contexts/attachmentPickerContext/AttachmentPickerContext';\nimport { useTheme } from '../../contexts/themeContext/ThemeContext';\nimport { Asset, getPhotos } from '../../native';\nimport { vh, vw } from '../../utils/utils';\n\nconst styles = StyleSheet.create({\n container: {\n flexGrow: 1,\n },\n overlay: {\n alignItems: 'flex-end',\n flex: 1,\n },\n});\n\nconst screenHeight = vh(100);\nconst fullScreenHeight = Dimensions.get('screen').height;\n\ntype AttachmentImageProps = {\n ImageOverlaySelectedComponent: React.ComponentType;\n onPress: () => void;\n selected: boolean;\n uri: string;\n numberOfAttachmentPickerImageColumns?: number;\n};\n\nconst AttachmentImage: React.FC<AttachmentImageProps> = (props) => {\n const {\n ImageOverlaySelectedComponent,\n numberOfAttachmentPickerImageColumns,\n onPress,\n selected,\n uri,\n } = props;\n const {\n theme: {\n attachmentPicker: { image, imageOverlay },\n colors: { overlay },\n },\n } = useTheme();\n\n const size = vw(100) / (numberOfAttachmentPickerImageColumns || 3) - 2;\n\n return (\n <TouchableOpacity onPress={onPress}>\n <ImageBackground\n source={{ uri }}\n style={[\n {\n height: size,\n margin: 1,\n width: size,\n },\n image,\n ]}\n >\n {selected && (\n <View style={[styles.overlay, { backgroundColor: overlay }, imageOverlay]}>\n <ImageOverlaySelectedComponent />\n </View>\n )}\n </ImageBackground>\n </TouchableOpacity>\n );\n};\n\nconst renderImage = ({\n item,\n}: {\n item: {\n asset: Asset;\n ImageOverlaySelectedComponent: React.ComponentType;\n maxNumberOfFiles: number;\n selected: boolean;\n setSelectedImages: React.Dispatch<React.SetStateAction<Asset[]>>;\n numberOfAttachmentPickerImageColumns?: number;\n };\n}) => {\n const {\n asset,\n ImageOverlaySelectedComponent,\n maxNumberOfFiles,\n numberOfAttachmentPickerImageColumns,\n selected,\n setSelectedImages,\n } = item;\n const onPress = () => {\n if (selected) {\n setSelectedImages((images) => images.filter((image) => image.uri !== asset.uri));\n } else {\n setSelectedImages((images) => {\n if (images.length >= maxNumberOfFiles) {\n return images;\n }\n return [...images, asset];\n });\n }\n };\n\n return (\n <AttachmentImage\n ImageOverlaySelectedComponent={ImageOverlaySelectedComponent}\n numberOfAttachmentPickerImageColumns={numberOfAttachmentPickerImageColumns}\n onPress={onPress}\n selected={selected}\n uri={asset.uri}\n />\n );\n};\n\nexport type AttachmentPickerProps = {\n /**\n * Custom UI component to render [draggable handle](https://github.com/GetStream/stream-chat-react-native/blob/master/screenshots/docs/1.png) of attachment picker.\n *\n * **Default** [AttachmentPickerBottomSheetHandle](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/AttachmentPicker/components/AttachmentPickerBottomSheetHandle.tsx)\n */\n AttachmentPickerBottomSheetHandle: React.FC<BottomSheetHandleProps>;\n /**\n * Custom UI component to render error component while opening attachment picker.\n *\n * **Default** [AttachmentPickerError](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/AttachmentPicker/components/AttachmentPickerError.tsx)\n */\n AttachmentPickerError: React.ComponentType<AttachmentPickerErrorProps>;\n /**\n * Custom UI component to render error image for attachment picker\n *\n * **Default** [AttachmentPickerErrorImage](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/AttachmentPicker/components/AttachmentPickerErrorImage.tsx)\n */\n AttachmentPickerErrorImage: React.ComponentType;\n /**\n * Custom UI component to render overlay component, that shows up on top of [selected image](https://github.com/GetStream/stream-chat-react-native/blob/master/screenshots/docs/1.png) (with tick mark)\n *\n * **Default** [ImageOverlaySelectedComponent](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/AttachmentPicker/components/ImageOverlaySelectedComponent.tsx)\n */\n ImageOverlaySelectedComponent: React.ComponentType;\n attachmentPickerBottomSheetHandleHeight?: number;\n attachmentPickerBottomSheetHeight?: number;\n attachmentPickerErrorButtonText?: string;\n attachmentPickerErrorText?: string;\n numberOfAttachmentImagesToLoadPerCall?: number;\n numberOfAttachmentPickerImageColumns?: number;\n translucentStatusBar?: boolean;\n};\n\nexport const AttachmentPicker = React.forwardRef(\n (props: AttachmentPickerProps, ref: React.ForwardedRef<BottomSheet>) => {\n const {\n AttachmentPickerBottomSheetHandle,\n attachmentPickerBottomSheetHandleHeight,\n attachmentPickerBottomSheetHeight,\n AttachmentPickerError,\n attachmentPickerErrorButtonText,\n AttachmentPickerErrorImage,\n attachmentPickerErrorText,\n ImageOverlaySelectedComponent,\n numberOfAttachmentImagesToLoadPerCall,\n numberOfAttachmentPickerImageColumns,\n translucentStatusBar,\n } = props;\n\n const {\n theme: {\n attachmentPicker: { bottomSheetContentContainer },\n colors: { white },\n },\n } = useTheme();\n const {\n closePicker,\n maxNumberOfFiles,\n selectedImages,\n selectedPicker,\n setSelectedImages,\n setSelectedPicker,\n topInset,\n } = useAttachmentPickerContext();\n\n const [currentIndex, setCurrentIndex] = useState(-1);\n const [endCursor, setEndCursor] = useState<string>();\n const [photoError, setPhotoError] = useState(false);\n const [hasNextPage, setHasNextPage] = useState(true);\n const [loadingPhotos, setLoadingPhotos] = useState(false);\n const [photos, setPhotos] = useState<Asset[]>([]);\n\n const hideAttachmentPicker = () => {\n setSelectedPicker(undefined);\n if ((ref as React.MutableRefObject<BottomSheet>)?.current) {\n (ref as React.MutableRefObject<BottomSheet>).current.close();\n }\n };\n\n const getMorePhotos = async () => {\n if (hasNextPage && !loadingPhotos && currentIndex > -1 && selectedPicker === 'images') {\n setLoadingPhotos(true);\n try {\n const results = await getPhotos({\n after: endCursor,\n first: numberOfAttachmentImagesToLoadPerCall ?? 60,\n });\n if (endCursor) {\n setPhotos([...photos, ...results.assets]);\n } else {\n setPhotos(results.assets);\n }\n setEndCursor(results.endCursor);\n setHasNextPage(results.hasNextPage || false);\n } catch (error) {\n console.log(error);\n setPhotoError(true);\n }\n setLoadingPhotos(false);\n }\n };\n\n useEffect(() => {\n const backAction = () => {\n if (selectedPicker) {\n setSelectedPicker(undefined);\n closePicker();\n return true;\n }\n\n return false;\n };\n\n const backHandler = BackHandler.addEventListener('hardwareBackPress', backAction);\n\n return () => backHandler.remove();\n }, [selectedPicker]);\n\n useEffect(() => {\n const keyboardSubscription =\n Platform.OS === 'ios'\n ? Keyboard.addListener('keyboardWillShow', hideAttachmentPicker)\n : Keyboard.addListener('keyboardDidShow', hideAttachmentPicker);\n\n return () => {\n if (keyboardSubscription?.remove) {\n keyboardSubscription.remove();\n return;\n }\n\n // To keep compatibility with older versions of React Native, where `remove()` is not available\n if (Platform.OS === 'ios') {\n Keyboard.removeListener('keyboardWillShow', hideAttachmentPicker);\n } else {\n Keyboard.removeListener('keyboardDidShow', hideAttachmentPicker);\n }\n };\n }, []);\n\n useEffect(() => {\n if (currentIndex < 0) {\n setSelectedPicker(undefined);\n if (!loadingPhotos) {\n setEndCursor(undefined);\n setHasNextPage(true);\n }\n }\n }, [currentIndex]);\n\n useEffect(() => {\n if (\n selectedPicker === 'images' &&\n endCursor === undefined &&\n currentIndex > -1 &&\n !loadingPhotos\n ) {\n setPhotoError(false);\n getMorePhotos();\n }\n }, [currentIndex, selectedPicker]);\n\n const selectedPhotos = photos.map((asset) => ({\n asset,\n ImageOverlaySelectedComponent,\n maxNumberOfFiles,\n numberOfAttachmentPickerImageColumns,\n selected: selectedImages.some((image) => image.uri === asset.uri),\n setSelectedImages,\n }));\n\n const handleHeight = attachmentPickerBottomSheetHandleHeight || 20;\n\n /**\n * This is to handle issues with Android measurements coming back incorrect.\n * If the StatusBar height is perfectly 1/2 of the difference between the two\n * dimensions for screen and window, it is incorrect and we need to account for\n * this. If you use a translucent header bar more adjustments are needed.\n */\n const statusBarHeight = StatusBar.currentHeight ?? 0;\n const bottomBarHeight = fullScreenHeight - screenHeight - statusBarHeight;\n const androidBottomBarHeightAdjustment =\n Platform.OS === 'android'\n ? bottomBarHeight === statusBarHeight\n ? translucentStatusBar\n ? 0\n : StatusBar.currentHeight ?? 0\n : translucentStatusBar\n ? bottomBarHeight > statusBarHeight\n ? -bottomBarHeight + statusBarHeight\n : bottomBarHeight > 0\n ? -statusBarHeight\n : 0\n : bottomBarHeight > 0\n ? 0\n : statusBarHeight\n : 0;\n\n /**\n * Snap points changing cause a rerender of the position,\n * this is an issue if you are calling close on the bottom sheet.\n */\n const snapPoints = useMemo(\n () => [\n attachmentPickerBottomSheetHeight ??\n 308 + (fullScreenHeight - screenHeight + androidBottomBarHeightAdjustment) - handleHeight,\n fullScreenHeight - topInset - handleHeight,\n ],\n [\n androidBottomBarHeightAdjustment,\n attachmentPickerBottomSheetHeight,\n fullScreenHeight,\n handleHeight,\n screenHeight,\n topInset,\n ],\n );\n\n return (\n <>\n <BottomSheet\n containerHeight={fullScreenHeight}\n enablePanDownToClose={true}\n handleComponent={\n /**\n * using `null` here instead of `style={{ opacity: photoError ? 0 : 1 }}`\n * as opacity is not an allowed style\n */\n photoError ? null : AttachmentPickerBottomSheetHandle\n }\n handleHeight={handleHeight}\n index={-1}\n onChange={(index: number) => setCurrentIndex(index)}\n ref={ref}\n snapPoints={snapPoints}\n >\n <BottomSheetFlatList\n contentContainerStyle={[\n styles.container,\n { backgroundColor: white },\n bottomSheetContentContainer,\n { opacity: photoError ? 0 : 1 },\n ]}\n data={selectedPhotos}\n keyExtractor={(item) => item.asset.uri}\n numColumns={numberOfAttachmentPickerImageColumns ?? 3}\n onEndReached={getMorePhotos}\n renderItem={renderImage}\n />\n </BottomSheet>\n {selectedPicker === 'images' && photoError && (\n <AttachmentPickerError\n attachmentPickerBottomSheetHeight={attachmentPickerBottomSheetHeight}\n attachmentPickerErrorButtonText={attachmentPickerErrorButtonText}\n AttachmentPickerErrorImage={AttachmentPickerErrorImage}\n attachmentPickerErrorText={attachmentPickerErrorText}\n />\n )}\n </>\n );\n },\n);\n\nAttachmentPicker.displayName = 'AttachmentPicker';\n"]}