Skip to content

Commit

Permalink
fix(mobile): improve animation and UI tweaks
Browse files Browse the repository at this point in the history
- Cancel ongoing animations in Tabbar and Player components
- Adjust unread indicator position in EntryNormalItem
- Enhance player cover art scale transition with spring preset

Signed-off-by: Innei <tukon479@gmail.com>
  • Loading branch information
Innei committed Feb 27, 2025
1 parent 9203a4d commit 001a4b0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions apps/mobile/src/components/layouts/tabbar/Tabbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { memo, useContext, useEffect } from "react"
import type { StyleProp, TextStyle } from "react-native"
import { Platform, Pressable, StyleSheet, View } from "react-native"
import Animated, {
cancelAnimation,
interpolateColor,
useAnimatedStyle,
useSharedValue,
Expand Down Expand Up @@ -34,6 +35,7 @@ export const Tabbar: FC<BottomTabBarProps> = (props) => {

const translateY = useSharedValue(0)
useEffect(() => {
cancelAnimation(translateY)
translateY.value = withSpring(
tabBarVisible ? 0 : 100,
!tabBarVisible ? quickSpringPreset : softSpringPreset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function EntryNormalItem({ entryId, extraData }: { entryId: string; extra
<EntryItemContextMenu id={entryId}>
<ItemPressable className="flex flex-row items-center p-4 pl-6" onPress={handlePress}>
<ReAnimated.View
className="bg-red absolute left-2 top-[40] size-2 rounded-full"
className="bg-red absolute left-2 top-[43] size-2 rounded-full"
style={unreadIndicatorStyle}
/>

Expand Down
15 changes: 11 additions & 4 deletions apps/mobile/src/screens/player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ import { LinearGradient } from "expo-linear-gradient"
import { router } from "expo-router"
import { useEffect, useMemo } from "react"
import { StyleSheet, Text, View } from "react-native"
import Reanimated, { useAnimatedStyle, useSharedValue, withSpring } from "react-native-reanimated"
import Reanimated, {
cancelAnimation,
useAnimatedStyle,
useSharedValue,
withSpring,
} from "react-native-reanimated"
import { SheetScreen } from "react-native-sheet-transitions"

import { gentleSpringPreset } from "../constants/spring"
import { useActiveTrack, useIsPlaying } from "../lib/player"
import { PlayerScreenContext } from "../modules/player/context"
import { ControlGroup, ProgressBar, VolumeBar } from "../modules/player/control"
Expand All @@ -18,12 +24,13 @@ function CoverArt({ cover }: { cover?: string }) {
const { playing } = useIsPlaying()

useEffect(() => {
scale.value = playing ? 1 : 0.7
}, [playing])
cancelAnimation(scale)
scale.value = withSpring(playing ? 1 : 0.7, gentleSpringPreset)
}, [playing, scale])

const animatedStyle = useAnimatedStyle(() => {
return {
transform: [{ scale: withSpring(scale.value) }],
transform: [{ scale: scale.value }],
}
})

Expand Down

0 comments on commit 001a4b0

Please sign in to comment.