revert(gallery): keep ContentMediaGallery identical to other modules
This commit is contained in:
parent
0f68e31285
commit
effed053b8
|
|
@ -141,21 +141,6 @@ export function ContentMediaGallery({ media, title = "Visual Reference" }: Conte
|
||||||
const [viewerIndex, setViewerIndex] = useState<number | null>(null);
|
const [viewerIndex, setViewerIndex] = useState<number | null>(null);
|
||||||
const listRef = useRef<FlatList<ContentMediaItem>>(null);
|
const listRef = useRef<FlatList<ContentMediaItem>>(null);
|
||||||
|
|
||||||
const MAX_VISIBLE_DOTS = 7;
|
|
||||||
const visibleDots = useMemo(() => {
|
|
||||||
if (items.length <= MAX_VISIBLE_DOTS) {
|
|
||||||
return items.map((item, index) => ({ item, index }));
|
|
||||||
}
|
|
||||||
const half = Math.floor(MAX_VISIBLE_DOTS / 2);
|
|
||||||
let start = Math.max(0, activeIndex - half);
|
|
||||||
let end = start + MAX_VISIBLE_DOTS;
|
|
||||||
if (end > items.length) {
|
|
||||||
end = items.length;
|
|
||||||
start = Math.max(0, end - MAX_VISIBLE_DOTS);
|
|
||||||
}
|
|
||||||
return items.slice(start, end).map((item, i) => ({ item, index: start + i }));
|
|
||||||
}, [items, activeIndex]);
|
|
||||||
|
|
||||||
if (!items.length) return null;
|
if (!items.length) return null;
|
||||||
|
|
||||||
const handleMomentumEnd = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
const handleMomentumEnd = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
||||||
|
|
@ -205,18 +190,14 @@ export function ContentMediaGallery({ media, title = "Visual Reference" }: Conte
|
||||||
<Text style={styles.caption}>{mediaLabel(items[activeIndex], activeIndex)}</Text>
|
<Text style={styles.caption}>{mediaLabel(items[activeIndex], activeIndex)}</Text>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{items.length > 0 ? (
|
{items.length > 1 ? (
|
||||||
<View style={styles.dots} accessibilityElementsHidden>
|
<View style={styles.dots} accessibilityElementsHidden>
|
||||||
{visibleDots.map(({ item, index }) => (
|
{items.map((item, index) => (
|
||||||
<Pressable
|
<Pressable
|
||||||
key={item.id}
|
key={item.id}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setActiveIndex(index);
|
setActiveIndex(index);
|
||||||
try {
|
listRef.current?.scrollToIndex({ index, animated: true });
|
||||||
listRef.current?.scrollToIndex({ index, animated: true });
|
|
||||||
} catch {
|
|
||||||
listRef.current?.scrollToOffset({ offset: index * carouselWidth, animated: true });
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
hitSlop={6}
|
hitSlop={6}
|
||||||
>
|
>
|
||||||
|
|
@ -273,12 +254,7 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
zoomText: { color: Colors.white, fontSize: 12, fontWeight: "700" },
|
zoomText: { color: Colors.white, fontSize: 12, fontWeight: "700" },
|
||||||
caption: { color: Colors.textSecondary, fontSize: 13, lineHeight: 19, textAlign: "center" },
|
caption: { color: Colors.textSecondary, fontSize: 13, lineHeight: 19, textAlign: "center" },
|
||||||
dots: {
|
dots: { flexDirection: "row", flexWrap: "wrap", justifyContent: "center", gap: 7 },
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
gap: 7,
|
|
||||||
},
|
|
||||||
dot: { width: 7, height: 7, borderRadius: 4, backgroundColor: Colors.border },
|
dot: { width: 7, height: 7, borderRadius: 4, backgroundColor: Colors.border },
|
||||||
dotActive: { width: 18, backgroundColor: Colors.primary },
|
dotActive: { width: 18, backgroundColor: Colors.primary },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue