Skip to content

Commit 2b837a0

Browse files
committed
refactor(chat): fade both list edges over the same distance
1 parent 8baf19a commit 2b837a0

2 files changed

Lines changed: 4 additions & 17 deletions

File tree

components/chat-screen/EdgeFade.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { LinearGradient } from 'expo-linear-gradient';
44
import { useTheme } from '../../context/ThemeContext';
55
import { withAlpha } from '../../styles/colors';
66

7-
export const TOP_FADE_HEIGHT = 32;
8-
export const BOTTOM_FADE_RUNUP = 24;
9-
export const BOTTOM_FADE_SCALE = 0.5;
7+
export const FADE_HEIGHT = 24;
108

119
const LOCATIONS = [0, 0.25, 0.5, 0.75, 1] as const;
1210
const ALPHAS = [0, 0.156, 0.5, 0.844, 1] as const;

components/chat-screen/Messages.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ import Reanimated, {
3434
} from 'react-native-reanimated';
3535
import type { SharedValue } from 'react-native-reanimated';
3636
import MessageItem from './MessageItem';
37-
import {
38-
BOTTOM_FADE_RUNUP,
39-
BOTTOM_FADE_SCALE,
40-
EdgeFade,
41-
TOP_FADE_HEIGHT,
42-
} from './EdgeFade';
37+
import { EdgeFade, FADE_HEIGHT } from './EdgeFade';
4338
import { Message, type ChatBranchMarker } from '../../database/chatRepository';
4439
import { useTheme } from '../../context/ThemeContext';
4540
import { Theme } from '../../styles/colors';
@@ -256,12 +251,7 @@ const Messages = ({
256251
[styles.scrollToBottomButtonContainer, chatBarInset]
257252
);
258253

259-
const navInset = navBarInset(theme);
260254
const bottomFadeAnimatedStyle = useAnimatedStyle(() => ({
261-
height:
262-
(chatBarInset + extraContentPadding.value + BOTTOM_FADE_RUNUP) *
263-
BOTTOM_FADE_SCALE +
264-
navInset,
265255
transform: [
266256
{
267257
translateY:
@@ -780,15 +770,14 @@ const createStyles = (theme: Theme) => {
780770
top: 0,
781771
left: 0,
782772
right: SCROLL_INDICATOR_GUTTER,
783-
height: TOP_FADE_HEIGHT,
773+
height: FADE_HEIGHT,
784774
},
785-
// Positions the ramp and the flat block below it, so the gutter set here
786-
// applies to both.
787775
bottomFade: {
788776
position: 'absolute',
789777
bottom: 0,
790778
left: 0,
791779
right: SCROLL_INDICATOR_GUTTER,
780+
height: FADE_HEIGHT + navInset,
792781
},
793782
// On Android the ramp must reach full opacity by the top of the navigation
794783
// bar, or text stays visible sliding under it. insets.bottom carries the

0 commit comments

Comments
 (0)