diff --git a/src/components/atoms/index.ts b/src/components/atoms/index.ts index c2f7ea27d..c27b8824d 100644 --- a/src/components/atoms/index.ts +++ b/src/components/atoms/index.ts @@ -1 +1,2 @@ -export * from './optionsModal'; \ No newline at end of file +export * from './optionsModal'; +export * from './progressBar' \ No newline at end of file diff --git a/src/components/atoms/progressBar/container/progressBar.tsx b/src/components/atoms/progressBar/container/progressBar.tsx new file mode 100644 index 000000000..f53fdb52e --- /dev/null +++ b/src/components/atoms/progressBar/container/progressBar.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import { View } from "react-native" + + + + +export const ProgressBar = ({ + progress +}) => { + + return ( + + + + + + ) +} \ No newline at end of file diff --git a/src/components/atoms/progressBar/index.ts b/src/components/atoms/progressBar/index.ts new file mode 100644 index 000000000..5c592bd57 --- /dev/null +++ b/src/components/atoms/progressBar/index.ts @@ -0,0 +1 @@ +export * from './container/progressBar'; \ No newline at end of file diff --git a/src/components/uploadsGalleryModal/uploadsGalleryModal.tsx b/src/components/uploadsGalleryModal/uploadsGalleryModal.tsx index f9162f677..53a400f0c 100644 --- a/src/components/uploadsGalleryModal/uploadsGalleryModal.tsx +++ b/src/components/uploadsGalleryModal/uploadsGalleryModal.tsx @@ -93,197 +93,208 @@ export const UploadsGalleryModal = forwardRef(({ await _getMediaUploads(); setIndices(new Map()); setIsLoading(false); - } catch(err){ + } catch (err) { console.warn("failed to remove image from gallery", err) setIsLoading(false); } } - + //fetch images from server const _getMediaUploads = async () => { - try{ + try { if (username) { setIsLoading(true); - console.log("getting images for: " + username ) + console.log("getting images for: " + username) const images = await getImages() console.log("images received", images) setMediaUploads(images); setIsLoading(false); } - }catch(err){ + } catch (err) { console.warn("Failed to get images") setIsLoading(false); } } //inserts media items in post body - const _insertMedia = async (selectedIndex?:number) => { - const map = selectedIndex > -1 ? new Map([[selectedIndex, true]]) : indices; - + const _insertMedia = async (selectedIndex?: number) => { + const map = selectedIndex > -1 ? new Map([[selectedIndex, true]]) : indices; + const data = [] for (const index of map.keys()) { console.log(index) const item = mediaUploads[index] data.push({ - url:item.url, - hash:item.url.split('/').pop() + url: item.url, + hash: item.url.split('/').pop() }) - + } handleOnSelect(data) setShowModal(false); } - //renders footer with add snipept button and shows new snippet modal - const _renderFloatingPanel = () => { + //renders footer with add snipept button and shows new snippet modal + const _renderFloatingPanel = () => { - if(!indices.size){ - return null - } - - const _onRemovePress = async () => { - const _onConfirm = () => { - _deleteMedia() - } - Alert.alert( - intl.formatMessage({id:'alert.delete'}), - intl.formatMessage({id:'alert.remove_alert'}), - [{ - text:intl.formatMessage({id:'alert.cancel'}), - style:'cancel' - },{ - text:intl.formatMessage({id:'alert.confirm'}), - onPress:_onConfirm - }] - ) - - } - - return ( - - - - - ); - }; - - - - //render list item for snippet and handle actions; - const _renderItem = ({ item, index }:{item:UploadedMedia, index:number}) => { - - const _onCheckPress = () => { - //update selection indices - if(indices.has(index)){ - indices.delete(index); - }else { - indices.set(index, true); + if (!indices.size) { + return null } - setIndices(new Map([...indices])); - } + const _onRemovePress = async () => { + const _onConfirm = () => { + _deleteMedia() + } + Alert.alert( + intl.formatMessage({ id: 'alert.delete' }), + intl.formatMessage({ id: 'alert.remove_alert' }), + [{ + text: intl.formatMessage({ id: 'alert.cancel' }), + style: 'cancel' + }, { + text: intl.formatMessage({ id: 'alert.confirm' }), + onPress: _onConfirm + }] + ) - const _onPress = () => { - - if(indices.size){ - _onCheckPress() - }else { - _insertMedia(index) - } - } + } - const thumbUrl = proxifyImageSrc(item.url, 600, 500, Platform.OS === 'ios' ? 'match' : 'webp'); + return ( + + + + + ); + }; - return ( - - - - - - - - ) - }; + + + //render list item for snippet and handle actions; + const _renderItem = ({ item, index }: { item: UploadedMedia, index: number }) => { + + const _onCheckPress = () => { + //update selection indices + if (indices.has(index)) { + indices.delete(index); + } else { + indices.set(index, true); + } + + setIndices(new Map([...indices])); + } + + const _onPress = () => { + + if (indices.size) { + _onCheckPress() + } else { + _insertMedia(index) + } + } + + const thumbUrl = proxifyImageSrc(item.url, 600, 500, Platform.OS === 'ios' ? 'match' : 'webp'); + + return ( + + + + + + + + ) + }; //render empty list placeholder const _renderEmptyContent = () => { return ( - <> - {intl.formatMessage({id:'uploads_modal.label_no_images'})} - + <> + {intl.formatMessage({ id: 'uploads_modal.label_no_images' })} + ); }; + const _renderUploadProgress = () => { + return ( + + + + ) + } + + const _renderContent = ( - `item_${item.url}`} - renderItem={_renderItem} - ListEmptyComponent={_renderEmptyContent} - ListFooterComponent={} - extraData={indices} - numColumns={2} - refreshControl={ - - } - /> + {true && } + + `item_${item.url}`} + renderItem={_renderItem} + ListEmptyComponent={_renderEmptyContent} + ListFooterComponent={} + extraData={indices} + numColumns={2} + refreshControl={ + + } + /> {_renderFloatingPanel()} ) - return ( - setShowModal(false)} - isFullScreen - isCloseButton - presentationStyle="formSheet" - title={intl.formatMessage({ - id:'uploads_modal.title' - })} - animationType="slide" - style={styles.modalStyle} - > - {_renderContent} - - - ); + return ( + setShowModal(false)} + isFullScreen + isCloseButton + presentationStyle="formSheet" + title={intl.formatMessage({ + id: 'uploads_modal.title' + })} + animationType="slide" + style={styles.modalStyle} + > + {_renderContent} + + + ); });