Skip to content

Commit

Permalink
Go full width on native and mobile web (#5184)
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey authored Sep 6, 2024
1 parent b90cd68 commit 64b50ba
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/view/com/util/images/AutoSizedImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import {useLingui} from '@lingui/react'

import * as imageSizes from '#/lib/media/image-sizes'
import {Dimensions} from '#/lib/media/types'
import {isNative} from '#/platform/detection'
import {useLargeAltBadgeEnabled} from '#/state/preferences/large-alt-badge'
import {atoms as a, useTheme} from '#/alf'
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
import {Crop_Stroke2_Corner0_Rounded as Crop} from '#/components/icons/Crop'
import {Text} from '#/components/Typography'

Expand Down Expand Up @@ -65,14 +66,18 @@ export function ConstrainedImage({
children: React.ReactNode
}) {
const t = useTheme()
const {gtMobile} = useBreakpoints()
/**
* Computed as a % value to apply as `paddingTop`
*/
const outerAspectRatio = React.useMemo<DimensionValue>(() => {
// capped to square or shorter
const ratio = Math.min(1 / aspectRatio, 1)
const ratio =
isNative || !gtMobile
? Math.min(1 / aspectRatio, 1.5)
: Math.min(1 / aspectRatio, 1)
return `${ratio * 100}%`
}, [aspectRatio])
}, [aspectRatio, gtMobile])

return (
<View style={[a.w_full]}>
Expand Down

0 comments on commit 64b50ba

Please sign in to comment.