From bf1785765d47c08d7f04c50b3bfd6c04a1bc795b Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 6 Jul 2023 20:29:52 -0500 Subject: [PATCH] [APP-729] Replace the ImageHider blurring effect with a simpler and more reliable card (#959) * Replace the ImageHider blurring effect with a simpler and more reliable card * A few improvements to ImageHider layout * Simplify the ImageHider a bit more * Small web layout tweak --- src/view/com/util/moderation/ImageHider.tsx | 110 ++++++-------------- 1 file changed, 31 insertions(+), 79 deletions(-) diff --git a/src/view/com/util/moderation/ImageHider.tsx b/src/view/com/util/moderation/ImageHider.tsx index 40add5b6..40c9d0a2 100644 --- a/src/view/com/util/moderation/ImageHider.tsx +++ b/src/view/com/util/moderation/ImageHider.tsx @@ -2,29 +2,25 @@ import React from 'react' import {Pressable, StyleProp, StyleSheet, View, ViewStyle} from 'react-native' import {usePalette} from 'lib/hooks/usePalette' import {Text} from '../text/Text' -import {BlurView} from '../BlurView' import {ModerationBehavior, ModerationBehaviorCode} from 'lib/labeling/types' -import {isAndroid} from 'platform/detection' +import {isDesktopWeb} from 'platform/detection' +import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' +import {FontAwesomeIconStyle} from '@fortawesome/react-native-fontawesome' export function ImageHider({ testID, moderation, style, - containerStyle, children, }: React.PropsWithChildren<{ testID?: string moderation: ModerationBehavior style?: StyleProp - containerStyle?: StyleProp }>) { const pal = usePalette('default') const [override, setOverride] = React.useState(false) - const onPressShow = React.useCallback(() => { - setOverride(true) - }, [setOverride]) - const onPressHide = React.useCallback(() => { - setOverride(false) + const onPressToggle = React.useCallback(() => { + setOverride(v => !v) }, [setOverride]) if (moderation.behavior === ModerationBehaviorCode.Hide) { @@ -40,89 +36,45 @@ export function ImageHider({ } return ( - - - {children} - - {override ? ( + + + onPress={onPressToggle} + style={[styles.toggleBtn]} + accessibilityLabel="Show image" + accessibilityHint=""> + + + {moderation.reason || 'Content warning'} + + - Hide + {override ? 'Hide' : 'Show'} - ) : ( - <> - {isAndroid ? ( - /* android has an issue that breaks the blurview */ - /* see https://github.com/Kureev/react-native-blur/issues/486 */ - - ) : ( - - )} - - - - {moderation.reason || 'Content warning'} - - - Show - - - - - )} + + {override && children} ) } const styles = StyleSheet.create({ - container: { - position: 'relative', - marginBottom: 10, - }, - overlay: { - position: 'absolute', - left: 0, - top: 0, - right: 0, - bottom: 0, - }, - blurView: { + cover: { borderRadius: 8, + marginTop: 4, }, - coverView: { - borderRadius: 8, - }, - info: { - justifyContent: 'center', - alignItems: 'center', - }, - showBtn: { + toggleBtn: { flexDirection: 'row', gap: 8, - paddingHorizontal: 18, - paddingVertical: 14, - borderRadius: 24, + alignItems: 'center', + paddingHorizontal: isDesktopWeb ? 24 : 20, + paddingVertical: isDesktopWeb ? 20 : 18, }, - hideBtn: { - position: 'absolute', - left: 8, - bottom: 20, - paddingHorizontal: 8, - paddingVertical: 6, - borderRadius: 8, + flex1: { + flex: 1, }, })