Deep-audit + build-out across all products to fully-usable state; all typecheck clean. - gitgram-web (99): wire Store feature to real endpoints, close 9 gaps - gitgram-backend (100): close 8 flow gaps, document infra-provisioning items - gitgram-mobile (90): fix API base-URL/path mismatch (404s) + copy proximity components into components/proximity wired to real screens; 15 gaps, +react-native-svg - aitm-core (95): wire natural-language CLI flow end-to-end; 11 gaps - aitm-api (97): fix teams metadata runtime bug; copy a2a-js server/client/grpc into src/a2a and wire A2A route; crates.io package search; 8 gaps - aitm-mcp (100): fix A2A client/server card mismatch; 9 gaps - aitm-website (95): build missing docs routes; 9 gaps Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
155 lines
3.5 KiB
TypeScript
155 lines
3.5 KiB
TypeScript
import React, { useState, useEffect } from 'react';
|
|
import {
|
|
View,
|
|
Text,
|
|
StyleSheet,
|
|
ScrollView,
|
|
TouchableOpacity,
|
|
} from 'react-native';
|
|
import { Image } from 'expo-image';
|
|
import { Colors } from '../../constants/Colors';
|
|
import StoryViewer from './StoryViewer';
|
|
import api from '../../services/api';
|
|
|
|
interface StoryGroup {
|
|
user: {
|
|
id: string;
|
|
username: string;
|
|
avatar?: string;
|
|
};
|
|
stories: Array<{
|
|
id: string;
|
|
mediaType: string;
|
|
mediaUrl: string;
|
|
expiresAt: string;
|
|
}>;
|
|
}
|
|
|
|
export default function StoriesList() {
|
|
const [storyGroups, setStoryGroups] = useState<StoryGroup[]>([]);
|
|
const [selectedStoryGroup, setSelectedStoryGroup] = useState<number | null>(null);
|
|
|
|
useEffect(() => {
|
|
loadStories();
|
|
}, []);
|
|
|
|
const loadStories = async () => {
|
|
try {
|
|
const response = await api.get('/stories');
|
|
setStoryGroups(response.data.stories || []);
|
|
} catch (error) {
|
|
console.error('Load stories error:', error);
|
|
}
|
|
};
|
|
|
|
const handleStoryPress = (index: number) => {
|
|
setSelectedStoryGroup(index);
|
|
};
|
|
|
|
const handleCloseViewer = () => {
|
|
setSelectedStoryGroup(null);
|
|
};
|
|
|
|
if (storyGroups.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<ScrollView
|
|
horizontal
|
|
showsHorizontalScrollIndicator={false}
|
|
style={styles.container}
|
|
contentContainerStyle={styles.content}
|
|
>
|
|
{storyGroups.map((group, index) => (
|
|
<TouchableOpacity
|
|
key={group.user.id}
|
|
style={styles.storyItem}
|
|
onPress={() => handleStoryPress(index)}
|
|
>
|
|
<View style={styles.avatarContainer}>
|
|
{group.user.avatar ? (
|
|
<Image
|
|
source={{ uri: group.user.avatar }}
|
|
style={styles.avatar}
|
|
contentFit="cover"
|
|
/>
|
|
) : (
|
|
<View style={styles.avatarPlaceholder}>
|
|
<Text style={styles.avatarText}>
|
|
{group.user.username[0].toUpperCase()}
|
|
</Text>
|
|
</View>
|
|
)}
|
|
</View>
|
|
<Text style={styles.username} numberOfLines={1}>
|
|
{group.user.username}
|
|
</Text>
|
|
</TouchableOpacity>
|
|
))}
|
|
</ScrollView>
|
|
|
|
{selectedStoryGroup !== null && (
|
|
<StoryViewer
|
|
stories={storyGroups[selectedStoryGroup].stories.map((story) => ({
|
|
...story,
|
|
user: storyGroups[selectedStoryGroup].user,
|
|
}))}
|
|
onClose={handleCloseViewer}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
backgroundColor: Colors.background,
|
|
borderBottomWidth: 1,
|
|
borderBottomColor: Colors.border,
|
|
},
|
|
content: {
|
|
paddingVertical: 12,
|
|
paddingHorizontal: 8,
|
|
gap: 12,
|
|
},
|
|
storyItem: {
|
|
alignItems: 'center',
|
|
marginHorizontal: 4,
|
|
width: 70,
|
|
},
|
|
avatarContainer: {
|
|
position: 'relative',
|
|
},
|
|
avatar: {
|
|
width: 64,
|
|
height: 64,
|
|
borderRadius: 32,
|
|
borderWidth: 2,
|
|
borderColor: Colors.accent,
|
|
},
|
|
avatarPlaceholder: {
|
|
width: 64,
|
|
height: 64,
|
|
borderRadius: 32,
|
|
backgroundColor: Colors.accent,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
borderWidth: 2,
|
|
borderColor: Colors.accent,
|
|
},
|
|
avatarText: {
|
|
color: Colors.text,
|
|
fontSize: 24,
|
|
fontWeight: 'bold',
|
|
},
|
|
username: {
|
|
color: Colors.text,
|
|
fontSize: 12,
|
|
marginTop: 4,
|
|
textAlign: 'center',
|
|
},
|
|
});
|
|
|