Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align lightbox status bar behaviour on Android 15 with iOS #7222

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
* LICENSE file in the root directory of this source tree.
*
*/
import {
SafeAreaView,
StyleSheet,
TouchableOpacity,
ViewStyle,
} from 'react-native'
import {StyleSheet, TouchableOpacity, ViewStyle} from 'react-native'
import {SafeAreaView} from 'react-native-safe-area-context'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
Expand Down
26 changes: 16 additions & 10 deletions src/view/com/lightbox/ImageViewing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ import {
useSafeAreaFrame,
useSafeAreaInsets,
} from 'react-native-safe-area-context'
import * as NavigationBar from 'expo-navigation-bar'
import {StatusBar} from 'expo-status-bar'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {Trans} from '@lingui/macro'

import {Dimensions} from '#/lib/media/types'
import {colors, s} from '#/lib/styles'
import {isIOS} from '#/platform/detection'
import {isAndroid, isIOS} from '#/platform/detection'
import {Lightbox} from '#/state/lightbox'
import {Button} from '#/view/com/util/forms/Button'
import {Text} from '#/view/com/util/text/Text'
import {ScrollView} from '#/view/com/util/Views'
import {ios, useTheme} from '#/alf'
import {useTheme} from '#/alf'
import {setNavigationBar} from '#/alf/util/navigationBar'
import {PlatformInfo} from '../../../../../modules/expo-bluesky-swiss-army'
import {ImageSource, Transform} from './@types'
Expand All @@ -60,11 +61,12 @@ import ImageItem from './components/ImageItem/ImageItem'

type Rect = {x: number; y: number; width: number; height: number}

const EDGE_TO_EDGE = !(Platform.OS === 'android' && Platform.Version < 35)

const PIXEL_RATIO = PixelRatio.get()
const EDGES =
Platform.OS === 'android'
? (['top', 'bottom', 'left', 'right'] satisfies Edge[])
: (['left', 'right'] satisfies Edge[]) // iOS, so no top/bottom safe area
const EDGES = EDGE_TO_EDGE
? (['left', 'right'] satisfies Edge[]) // iOS or Android 15+, so no top/bottom safe area
: (['top', 'bottom', 'left', 'right'] satisfies Edge[])

const SLOW_SPRING: WithSpringConfig = {
mass: isIOS ? 1.25 : 0.75,
Expand Down Expand Up @@ -298,10 +300,16 @@ function ImageView({
const t = useTheme()
useEffect(() => {
setNavigationBar('lightbox', t)
if (isAndroid && EDGE_TO_EDGE && !showControls) {
NavigationBar.setVisibilityAsync('hidden')
}
return () => {
setNavigationBar('theme', t)
if (isAndroid && EDGE_TO_EDGE && !showControls) {
NavigationBar.setVisibilityAsync('visible')
}
}
}, [t])
}, [t, showControls])

return (
<Animated.View style={[styles.container, containerStyle]}>
Expand All @@ -310,9 +318,7 @@ function ImageView({
style="light"
hideTransitionAnimation="slide"
backgroundColor="black"
// hiding causes layout shifts on android,
// so avoid until we add edge-to-edge mode
hidden={ios(isScaled || !showControls)}
hidden={EDGE_TO_EDGE ? isScaled || !showControls : false}
/>
<Animated.View
style={[styles.backdrop, backdropStyle]}
Expand Down
Loading