-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/26126-tag_menu_item_and_picker
- Loading branch information
Showing
107 changed files
with
1,281 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
src/components/Attachments/AttachmentCarousel/CarouselItem.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import React, {useContext, useState} from 'react'; | ||
import {View} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import CONST from '../../../CONST'; | ||
import styles from '../../../styles/styles'; | ||
import useLocalize from '../../../hooks/useLocalize'; | ||
import PressableWithoutFeedback from '../../Pressable/PressableWithoutFeedback'; | ||
import Text from '../../Text'; | ||
import Button from '../../Button'; | ||
import AttachmentView from '../AttachmentView'; | ||
import SafeAreaConsumer from '../../SafeAreaConsumer'; | ||
import ReportAttachmentsContext from '../../../pages/home/report/ReportAttachmentsContext'; | ||
|
||
const propTypes = { | ||
/** Attachment required information such as the source and file name */ | ||
item: PropTypes.shape({ | ||
/** Report action ID of the attachment */ | ||
reportActionID: PropTypes.string, | ||
|
||
/** Whether source URL requires authentication */ | ||
isAuthTokenRequired: PropTypes.bool, | ||
|
||
/** The source (URL) of the attachment */ | ||
source: PropTypes.string, | ||
|
||
/** Additional information about the attachment file */ | ||
file: PropTypes.shape({ | ||
/** File name of the attachment */ | ||
name: PropTypes.string, | ||
}), | ||
|
||
/** Whether the attachment has been flagged */ | ||
hasBeenFlagged: PropTypes.bool, | ||
}).isRequired, | ||
|
||
/** Whether the attachment is currently being viewed in the carousel */ | ||
isFocused: PropTypes.bool.isRequired, | ||
|
||
/** onPress callback */ | ||
onPress: PropTypes.func, | ||
}; | ||
|
||
const defaultProps = { | ||
onPress: undefined, | ||
}; | ||
|
||
function CarouselItem({item, isFocused, onPress}) { | ||
const {translate} = useLocalize(); | ||
const {isAttachmentHidden} = useContext(ReportAttachmentsContext); | ||
// eslint-disable-next-line es/no-nullish-coalescing-operators | ||
const [isHidden, setIsHidden] = useState(isAttachmentHidden(item.reportActionID) ?? item.hasBeenFlagged); | ||
|
||
const renderButton = (style) => ( | ||
<Button | ||
small | ||
style={style} | ||
onPress={() => setIsHidden(!isHidden)} | ||
> | ||
<Text | ||
style={styles.buttonSmallText} | ||
selectable={false} | ||
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}} | ||
> | ||
{isHidden ? translate('moderation.revealMessage') : translate('moderation.hideMessage')} | ||
</Text> | ||
</Button> | ||
); | ||
|
||
if (isHidden) { | ||
const children = ( | ||
<> | ||
<Text style={[styles.textLabelSupporting, styles.textAlignCenter, styles.lh20]}>{translate('moderation.flaggedContent')}</Text> | ||
{renderButton([styles.mt2])} | ||
</> | ||
); | ||
return onPress ? ( | ||
<PressableWithoutFeedback | ||
style={[styles.attachmentRevealButtonContainer]} | ||
onPress={onPress} | ||
accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON} | ||
accessibilityLabel={item.file.name || translate('attachmentView.unknownFilename')} | ||
> | ||
{children} | ||
</PressableWithoutFeedback> | ||
) : ( | ||
<View style={[styles.attachmentRevealButtonContainer]}>{children}</View> | ||
); | ||
} | ||
|
||
return ( | ||
<View style={[styles.flex1]}> | ||
<View style={[styles.flex1]}> | ||
<AttachmentView | ||
source={item.source} | ||
file={item.file} | ||
isAuthTokenRequired={item.isAuthTokenRequired} | ||
isFocused={isFocused} | ||
onPress={onPress} | ||
isUsedInCarousel | ||
/> | ||
</View> | ||
|
||
{item.hasBeenFlagged && ( | ||
<SafeAreaConsumer> | ||
{({safeAreaPaddingBottomStyle}) => <View style={[styles.appBG, safeAreaPaddingBottomStyle]}>{renderButton([styles.m4, styles.alignSelfCenter])}</View>} | ||
</SafeAreaConsumer> | ||
)} | ||
</View> | ||
); | ||
} | ||
|
||
CarouselItem.propTypes = propTypes; | ||
CarouselItem.defaultProps = defaultProps; | ||
|
||
export default CarouselItem; |
Oops, something went wrong.