feat(lightbox): enhance image viewing experience with save and share functionality
- Updated ImageDefaultHeader to include save and share buttons for the current image. - Refactored ImageView to pass current image URI to the header. - Cleaned up unused code and improved footer rendering logic. - Updated Info.plist to reflect new app version. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -53,7 +53,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<string>110</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
|
||||
+76
-17
@@ -10,38 +10,97 @@ import { StyleSheet, TouchableOpacity, View } from "react-native"
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
||||
|
||||
import { CloseCuteReIcon } from "@/src/icons/close_cute_re"
|
||||
import { Download2CuteReIcon } from "@/src/icons/download_2_cute_re"
|
||||
import { ShareForwardCuteReIcon } from "@/src/icons/share_forward_cute_re"
|
||||
|
||||
type Props = {
|
||||
onRequestClose: () => void
|
||||
onPressSave: (uri: string) => void
|
||||
onPressShare: (uri: string) => void
|
||||
currentImageUri?: string
|
||||
}
|
||||
|
||||
const ImageDefaultHeader = ({ onRequestClose }: Props) => {
|
||||
const ImageDefaultHeader = ({
|
||||
onRequestClose,
|
||||
onPressSave,
|
||||
onPressShare,
|
||||
currentImageUri,
|
||||
}: Props) => {
|
||||
const insets = useSafeAreaInsets()
|
||||
|
||||
return (
|
||||
<View style={[styles.root, { marginTop: insets.top, marginRight: insets.right }]}>
|
||||
<TouchableOpacity
|
||||
style={[styles.closeButton, styles.blurredBackground]}
|
||||
onPress={onRequestClose}
|
||||
hitSlop={16}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={`Close image`}
|
||||
accessibilityHint={`Closes viewer for header image`}
|
||||
onAccessibilityEscape={onRequestClose}
|
||||
>
|
||||
<CloseCuteReIcon color="#fff" />
|
||||
</TouchableOpacity>
|
||||
<View
|
||||
style={[
|
||||
styles.root,
|
||||
{ marginTop: insets.top, marginLeft: insets.left, marginRight: insets.right },
|
||||
]}
|
||||
>
|
||||
{/* Left side - Close button */}
|
||||
<View style={styles.leftActions}>
|
||||
<TouchableOpacity
|
||||
style={[styles.actionButton, styles.blurredBackground]}
|
||||
onPress={onRequestClose}
|
||||
hitSlop={16}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Close image"
|
||||
accessibilityHint="Closes viewer for header image"
|
||||
onAccessibilityEscape={onRequestClose}
|
||||
>
|
||||
<CloseCuteReIcon color="#fff" width={20} height={20} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||
{/* Right side - Save and Share buttons */}
|
||||
<View style={styles.rightActions}>
|
||||
{currentImageUri && (
|
||||
<>
|
||||
<TouchableOpacity
|
||||
style={[styles.actionButton, styles.blurredBackground]}
|
||||
onPress={() => onPressSave(currentImageUri)}
|
||||
hitSlop={16}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Save image"
|
||||
accessibilityHint="Saves image to photo library"
|
||||
>
|
||||
<Download2CuteReIcon color="#fff" width={20} height={20} />
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity
|
||||
style={[styles.actionButton, styles.blurredBackground]}
|
||||
onPress={() => onPressShare(currentImageUri)}
|
||||
hitSlop={16}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Share image"
|
||||
accessibilityHint="Shares image with other apps"
|
||||
>
|
||||
<ShareForwardCuteReIcon color="#fff" width={20} height={20} />
|
||||
</TouchableOpacity>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
root: {
|
||||
alignItems: "flex-end",
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "flex-start",
|
||||
paddingHorizontal: 16,
|
||||
paddingTop: 16,
|
||||
pointerEvents: "box-none",
|
||||
},
|
||||
closeButton: {
|
||||
marginRight: 10,
|
||||
marginTop: 10,
|
||||
leftActions: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
},
|
||||
rightActions: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: 12,
|
||||
},
|
||||
actionButton: {
|
||||
width: 44,
|
||||
height: 44,
|
||||
alignItems: "center",
|
||||
|
||||
@@ -11,15 +11,7 @@
|
||||
// import * as ScreenOrientation from "expo-screen-orientation"
|
||||
import * as React from "react"
|
||||
import { useCallback, useMemo, useState } from "react"
|
||||
import {
|
||||
LayoutAnimation,
|
||||
PixelRatio,
|
||||
Pressable,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native"
|
||||
import { LayoutAnimation, PixelRatio, ScrollView, StyleSheet, Text, View } from "react-native"
|
||||
import { SystemBars } from "react-native-edge-to-edge"
|
||||
import { Gesture } from "react-native-gesture-handler"
|
||||
import PagerView from "react-native-pager-view"
|
||||
@@ -40,8 +32,6 @@ import Animated, {
|
||||
} from "react-native-reanimated"
|
||||
import { useSafeAreaFrame, useSafeAreaInsets } from "react-native-safe-area-context"
|
||||
|
||||
import { Download2CuteReIcon } from "@/src/icons/download_2_cute_re"
|
||||
import { ShareForwardCuteReIcon } from "@/src/icons/share_forward_cute_re"
|
||||
import { isIOS } from "@/src/lib/platform"
|
||||
|
||||
import type { Lightbox } from "../lightboxState"
|
||||
@@ -210,6 +200,10 @@ function ImageView({
|
||||
const dismissSwipeTranslateY = useSharedValue(0)
|
||||
const isFlyingAway = useSharedValue(false)
|
||||
|
||||
// Get current image URI for the header buttons
|
||||
const currentImage = images[imageIndex]
|
||||
const currentImageUri = currentImage?.uri
|
||||
|
||||
const containerStyle = useAnimatedStyle(() => {
|
||||
if (openProgress.get() < 1) {
|
||||
return {
|
||||
@@ -349,7 +343,12 @@ function ImageView({
|
||||
</PagerView>
|
||||
<View style={styles.controls}>
|
||||
<Animated.View style={animatedHeaderStyle} renderToHardwareTextureAndroid>
|
||||
<ImageDefaultHeader onRequestClose={onRequestClose} />
|
||||
<ImageDefaultHeader
|
||||
onRequestClose={onRequestClose}
|
||||
onPressSave={onPressSave}
|
||||
onPressShare={onPressShare}
|
||||
currentImageUri={currentImageUri}
|
||||
/>
|
||||
</Animated.View>
|
||||
<Animated.View style={animatedFooterStyle} renderToHardwareTextureAndroid={!isAltExpanded}>
|
||||
<LightboxFooter
|
||||
@@ -357,8 +356,6 @@ function ImageView({
|
||||
index={imageIndex}
|
||||
isAltExpanded={isAltExpanded}
|
||||
toggleAltExpanded={() => setAltExpanded((e) => !e)}
|
||||
onPressSave={onPressSave}
|
||||
onPressShare={onPressShare}
|
||||
/>
|
||||
</Animated.View>
|
||||
</View>
|
||||
@@ -519,25 +516,22 @@ function LightboxFooter({
|
||||
index,
|
||||
isAltExpanded,
|
||||
toggleAltExpanded,
|
||||
onPressSave,
|
||||
onPressShare,
|
||||
}: {
|
||||
images: ImageSource[]
|
||||
index: number
|
||||
isAltExpanded: boolean
|
||||
toggleAltExpanded: () => void
|
||||
onPressSave: (uri: string) => void
|
||||
onPressShare: (uri: string) => void
|
||||
}) {
|
||||
const insets = useSafeAreaInsets()
|
||||
const image = images.at(index)
|
||||
const altText = image?.alt
|
||||
const uri = image?.uri
|
||||
const isMomentumScrolling = React.useRef(false)
|
||||
if (!image || !uri) {
|
||||
// If the image is not available, we don't render the footer.
|
||||
|
||||
// If there's no alt text, don't render the footer
|
||||
if (!altText) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
style={styles.footerScrollView}
|
||||
@@ -554,45 +548,25 @@ function LightboxFooter({
|
||||
}}
|
||||
>
|
||||
<View style={{ marginBottom: insets.bottom }}>
|
||||
{altText ? (
|
||||
<View accessibilityRole="button" style={styles.footerText}>
|
||||
<Text
|
||||
className="text-gray-3"
|
||||
numberOfLines={isAltExpanded ? undefined : 3}
|
||||
selectable
|
||||
onPress={() => {
|
||||
if (isMomentumScrolling.current) {
|
||||
return
|
||||
}
|
||||
LayoutAnimation.configureNext({
|
||||
duration: 450,
|
||||
update: { type: "spring", springDamping: 1 },
|
||||
})
|
||||
toggleAltExpanded()
|
||||
}}
|
||||
onLongPress={() => {}}
|
||||
>
|
||||
{altText}
|
||||
</Text>
|
||||
</View>
|
||||
) : null}
|
||||
<View style={styles.footerBtns}>
|
||||
<Pressable
|
||||
className="rounded-3xl border border-white px-4 py-2"
|
||||
style={styles.footerBtn}
|
||||
onPress={() => onPressSave(uri)}
|
||||
<View accessibilityRole="button" style={styles.footerText}>
|
||||
<Text
|
||||
className="text-gray-3"
|
||||
numberOfLines={isAltExpanded ? undefined : 3}
|
||||
selectable
|
||||
onPress={() => {
|
||||
if (isMomentumScrolling.current) {
|
||||
return
|
||||
}
|
||||
LayoutAnimation.configureNext({
|
||||
duration: 450,
|
||||
update: { type: "spring", springDamping: 1 },
|
||||
})
|
||||
toggleAltExpanded()
|
||||
}}
|
||||
onLongPress={() => {}}
|
||||
>
|
||||
<Download2CuteReIcon color="#fff" />
|
||||
<Text className="text-xl text-white">Save</Text>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
className="rounded-3xl border border-white px-4 py-2"
|
||||
style={styles.footerBtn}
|
||||
onPress={() => onPressShare(uri)}
|
||||
>
|
||||
<ShareForwardCuteReIcon color="#fff" />
|
||||
<Text className="text-xl text-white">Share</Text>
|
||||
</Pressable>
|
||||
{altText}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
@@ -658,17 +632,6 @@ const styles = StyleSheet.create({
|
||||
footerText: {
|
||||
paddingBottom: isIOS ? 20 : 16,
|
||||
},
|
||||
footerBtns: {
|
||||
flexDirection: "row",
|
||||
justifyContent: "center",
|
||||
gap: 8,
|
||||
},
|
||||
footerBtn: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: 8,
|
||||
backgroundColor: "transparent",
|
||||
},
|
||||
})
|
||||
|
||||
function interpolatePx(px: number, inputRange: readonly number[], outputRange: readonly number[]) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { whoami } from "@follow/store/user/getters"
|
||||
import { setFirebaseTracker, setPostHogTracker, tracker } from "@follow/tracker"
|
||||
import { getAnalytics } from "@react-native-firebase/analytics"
|
||||
import { nativeApplicationVersion, nativeBuildVersion } from "expo-application"
|
||||
import PostHog from "posthog-react-native"
|
||||
|
||||
import { ga4 } from "../lib/ga4"
|
||||
import { proxyEnv } from "../lib/proxy-env"
|
||||
|
||||
export const initAnalytics = async () => {
|
||||
setFirebaseTracker(ga4)
|
||||
setFirebaseTracker(getAnalytics())
|
||||
|
||||
const user = whoami()
|
||||
if (user) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { FetchError, ofetch } from "ofetch"
|
||||
|
||||
import { InvitationScreen } from "../screens/(modal)/InvitationScreen"
|
||||
import { getCookie } from "./auth"
|
||||
import { getClientId, getSessionId } from "./client-session"
|
||||
import { getUserAgent } from "./native/user-agent"
|
||||
import { Navigation } from "./navigation/Navigation"
|
||||
import { proxyEnv } from "./proxy-env"
|
||||
@@ -68,6 +69,8 @@ export const apiClient = hc<AppType>(proxyEnv.API_URL, {
|
||||
"X-App-Name": "Folo Mobile",
|
||||
cookie: getCookie(),
|
||||
"User-Agent": await getUserAgent(),
|
||||
"X-Client-Id": getClientId(),
|
||||
"X-Session-Id": getSessionId(),
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user