Skip to content

Commit

Permalink
Merge pull request #4266 from tloncorp/po/tlon-3316-fix-gallery-item-…
Browse files Browse the repository at this point in the history
…size-issues

gallery: fix item size issues on desktop
  • Loading branch information
patosullivan authored Dec 9, 2024
2 parents 86950b3 + db76b4c commit 6d0f9fa
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/ui/src/components/Channel/Scroller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
} from 'react-native';
import Animated from 'react-native-reanimated';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { View, styled, useStyle, useTheme } from 'tamagui';
import { View, getTokenValue, styled, useStyle, useTheme } from 'tamagui';

import { RenderItemType } from '../../contexts/componentsKits';
import { useLivePost } from '../../contexts/requests';
Expand Down Expand Up @@ -201,10 +201,10 @@ const Scroller = forwardRef(

const theme = useTheme();

// Used to hide the scroller until we've found the anchor post.
const style = useMemo(() => {
return {
backgroundColor: theme.background.val,
// Used to hide the scroller until we've found the anchor post.
opacity: readyToDisplayPosts ? 1 : 0,
};
}, [readyToDisplayPosts, theme.background.val]);
Expand Down Expand Up @@ -268,6 +268,7 @@ const Scroller = forwardRef(
messageRef={activeMessageRefs.current[post.id]}
dividersEnabled={collectionLayout.dividersEnabled}
itemAspectRatio={collectionLayout.itemAspectRatio ?? undefined}
columnCount={collectionLayout.columnCount}
{...anchorScrollLockScrollerItemProps}
/>
);
Expand All @@ -290,6 +291,7 @@ const Scroller = forwardRef(
showDividers,
collectionLayout.dividersEnabled,
collectionLayout.itemAspectRatio,
collectionLayout.columnCount,
]
);

Expand Down Expand Up @@ -335,6 +337,9 @@ const Scroller = forwardRef(
: {
gap: '$l',
width: '100%',
// Necessary to prevent content from flowing off the right side of the
// screen when the scroller is in two-column mode.
paddingRight: '$l',
}
) as StyleProp<ViewStyle>;

Expand Down Expand Up @@ -580,6 +585,7 @@ const BaseScrollerItem = ({
isLastPostOfBlock,
dividersEnabled,
itemAspectRatio,
columnCount,
}: {
showUnreadDivider: boolean;
showAuthor: boolean;
Expand All @@ -603,6 +609,7 @@ const BaseScrollerItem = ({
isLastPostOfBlock: boolean;
dividersEnabled: boolean;
itemAspectRatio?: number;
columnCount: number;
}) => {
const post = useLivePost(item);

Expand Down Expand Up @@ -652,7 +659,11 @@ const BaseScrollerItem = ({
}, [dividerType, post, unreadCount, showDayDivider]);

return (
<View onLayout={handleLayout} flex={1} aspectRatio={itemAspectRatio}>
<View
onLayout={handleLayout}
width={columnCount === 2 ? '50%' : '100%'}
aspectRatio={itemAspectRatio}
>
{divider}
<PressableMessage
ref={messageRef}
Expand Down

0 comments on commit 6d0f9fa

Please sign in to comment.