- 게시물 카드 슬라이드 7종, 좋아요·댓글, 텍스트 공유 - 시트 7종(RN Modal), 위 막대 지역·계절·로그인/아바타 - 각·노을·주말·행사·계절·상식 탭, 당겨서 새로고침 - 히어로 해·구름·비·눈 움직임, 스켈레톤 깜빡임, 첫 로딩 덮개, 하늘색 전환
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
import type { ReactNode } from 'react';
|
|
import { ScrollView, View, type NativeScrollEvent, type NativeSyntheticEvent } from 'react-native';
|
|
|
|
/** 옆으로 한 장씩 넘기는 슬라이드 (웹 Embla 캐러셀 대신 가로 paging ScrollView) */
|
|
export function Pager({ width, height, onIndex, children }: { width: number; height: number; onIndex: (i: number) => void; children: ReactNode[] }) {
|
|
const onEnd = (e: NativeSyntheticEvent<NativeScrollEvent>) => onIndex(Math.round(e.nativeEvent.contentOffset.x / width));
|
|
return (
|
|
<ScrollView horizontal pagingEnabled showsHorizontalScrollIndicator={false} scrollEnabled={children.length > 1} onMomentumScrollEnd={onEnd} style={{ width, height }}>
|
|
{children.map((c, i) => (
|
|
<View key={i} style={{ width, height }}>
|
|
{c}
|
|
</View>
|
|
))}
|
|
</ScrollView>
|
|
);
|
|
}
|
|
|
|
/** 슬라이드 위치 점 */
|
|
export function Dots({ n, index }: { n: number; index: number }) {
|
|
if (n < 2) return null;
|
|
const items = Array.from({ length: n }, (_, i) => i);
|
|
return (
|
|
<View className="flex-row justify-center gap-1.5 pt-2" accessibilityElementsHidden>
|
|
{items.map((i) => (
|
|
<View key={i} className={`h-1.5 rounded-full ${i === index ? 'w-4 bg-orange' : 'w-1.5 bg-ink3/40'}`} />
|
|
))}
|
|
</View>
|
|
);
|
|
}
|