Loading mobile/src/common/components/caroussel/caroussel.tsx +61 −54 Original line number Diff line number Diff line import { View, Animated, Text, Dimensions, Image, NativeSyntheticEvent, NativeScrollEvent } from "react-native"; import { View, Animated, Text, Dimensions, Image, NativeSyntheticEvent, NativeScrollEvent, } from "react-native"; import { PlaceInfoEntity } from "../../../domain/entities/place_info_entity"; import { useRef } from "react"; import { StateDataSource } from "../../../domain/datasources/state_datasource"; import { CarousselTile } from "./caroussel_tile"; import { router } from "expo-router"; import { BLANK_ITEM_WIDTH, ITEM_WIDTH } from "../../constants/caroussel"; interface CarousselProps { data: PlaceInfoEntity[]; Loading @@ -11,9 +20,6 @@ interface CarousselProps { onIndexChange?: (index: number) => void; } const ITEM_WIDTH = Dimensions.get("window").width * 0.7; const BLANK_ITEM_WIDTH = Dimensions.get("window").width * 0.15; export const Caroussel = ({ data, onPress, onIndexChange }: CarousselProps) => { const scrollX = useRef(new Animated.Value(0)).current; const finalData = [ Loading Loading @@ -43,12 +49,14 @@ export const Caroussel = ({ data, onPress, onIndexChange }: CarousselProps) => { showsHorizontalScrollIndicator={false} decelerationRate={0} initialNumToRender={1} bounces={false} snapToInterval={ITEM_WIDTH} onScroll={Animated.event([{ nativeEvent: { contentOffset: { x: scrollX } } }], { onScroll={Animated.event( [{ nativeEvent: { contentOffset: { x: scrollX } } }], { useNativeDriver: true, })} } )} renderItem={({ item, index }) => { if (item.id === -1 || item.id === -2) { return <View style={{ width: BLANK_ITEM_WIDTH }} />; Loading Loading @@ -82,8 +90,7 @@ export const Caroussel = ({ data, onPress, onIndexChange }: CarousselProps) => { if (item.id !== -1 && item.id !== -2) { onPress && onPress(item.id); } } } }} /> ); }} Loading mobile/src/common/components/caroussel/caroussel_tile.tsx +1 −4 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ import { } from "react-native"; import { PlaceInfoEntity } from "../../../domain/entities/place_info_entity"; import { Link } from "expo-router"; import { ITEM_HEIGHT, ITEM_WIDTH } from "../../constants/caroussel"; interface CarousselTileProps { onPress?: () => void; Loading @@ -18,10 +19,6 @@ interface CarousselTileProps { opacity: Animated.AnimatedInterpolation<number>; } const ITEM_WIDTH = Dimensions.get("window").width * 0.7; const BLANK_ITEM_WIDTH = Dimensions.get("window").width * 0.15; const ITEM_HEIGHT = Dimensions.get("window").height * 0.7; export const CarousselTile = memo( ({ translateY, scale, opacity, item, onPress }: CarousselTileProps) => { return ( Loading mobile/src/common/constants/caroussel.ts 0 → 100644 +7 −0 Original line number Diff line number Diff line import { Dimensions } from "react-native"; export const CARROUSEL_HEIGHT = Dimensions.get("window").height * 0.5; export const CARROUSEL_WIDTH = Dimensions.get("window").width; export const ITEM_WIDTH = CARROUSEL_WIDTH * 0.8; export const BLANK_ITEM_WIDTH = CARROUSEL_WIDTH * 0.1; export const ITEM_HEIGHT = CARROUSEL_HEIGHT * 0.7; No newline at end of file Loading
mobile/src/common/components/caroussel/caroussel.tsx +61 −54 Original line number Diff line number Diff line import { View, Animated, Text, Dimensions, Image, NativeSyntheticEvent, NativeScrollEvent } from "react-native"; import { View, Animated, Text, Dimensions, Image, NativeSyntheticEvent, NativeScrollEvent, } from "react-native"; import { PlaceInfoEntity } from "../../../domain/entities/place_info_entity"; import { useRef } from "react"; import { StateDataSource } from "../../../domain/datasources/state_datasource"; import { CarousselTile } from "./caroussel_tile"; import { router } from "expo-router"; import { BLANK_ITEM_WIDTH, ITEM_WIDTH } from "../../constants/caroussel"; interface CarousselProps { data: PlaceInfoEntity[]; Loading @@ -11,9 +20,6 @@ interface CarousselProps { onIndexChange?: (index: number) => void; } const ITEM_WIDTH = Dimensions.get("window").width * 0.7; const BLANK_ITEM_WIDTH = Dimensions.get("window").width * 0.15; export const Caroussel = ({ data, onPress, onIndexChange }: CarousselProps) => { const scrollX = useRef(new Animated.Value(0)).current; const finalData = [ Loading Loading @@ -43,12 +49,14 @@ export const Caroussel = ({ data, onPress, onIndexChange }: CarousselProps) => { showsHorizontalScrollIndicator={false} decelerationRate={0} initialNumToRender={1} bounces={false} snapToInterval={ITEM_WIDTH} onScroll={Animated.event([{ nativeEvent: { contentOffset: { x: scrollX } } }], { onScroll={Animated.event( [{ nativeEvent: { contentOffset: { x: scrollX } } }], { useNativeDriver: true, })} } )} renderItem={({ item, index }) => { if (item.id === -1 || item.id === -2) { return <View style={{ width: BLANK_ITEM_WIDTH }} />; Loading Loading @@ -82,8 +90,7 @@ export const Caroussel = ({ data, onPress, onIndexChange }: CarousselProps) => { if (item.id !== -1 && item.id !== -2) { onPress && onPress(item.id); } } } }} /> ); }} Loading
mobile/src/common/components/caroussel/caroussel_tile.tsx +1 −4 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ import { } from "react-native"; import { PlaceInfoEntity } from "../../../domain/entities/place_info_entity"; import { Link } from "expo-router"; import { ITEM_HEIGHT, ITEM_WIDTH } from "../../constants/caroussel"; interface CarousselTileProps { onPress?: () => void; Loading @@ -18,10 +19,6 @@ interface CarousselTileProps { opacity: Animated.AnimatedInterpolation<number>; } const ITEM_WIDTH = Dimensions.get("window").width * 0.7; const BLANK_ITEM_WIDTH = Dimensions.get("window").width * 0.15; const ITEM_HEIGHT = Dimensions.get("window").height * 0.7; export const CarousselTile = memo( ({ translateY, scale, opacity, item, onPress }: CarousselTileProps) => { return ( Loading
mobile/src/common/constants/caroussel.ts 0 → 100644 +7 −0 Original line number Diff line number Diff line import { Dimensions } from "react-native"; export const CARROUSEL_HEIGHT = Dimensions.get("window").height * 0.5; export const CARROUSEL_WIDTH = Dimensions.get("window").width; export const ITEM_WIDTH = CARROUSEL_WIDTH * 0.8; export const BLANK_ITEM_WIDTH = CARROUSEL_WIDTH * 0.1; export const ITEM_HEIGHT = CARROUSEL_HEIGHT * 0.7; No newline at end of file