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>
81 lines
2.7 KiB
TypeScript
81 lines
2.7 KiB
TypeScript
import { useState } from 'react';
|
|
import { View, TextInput, FlatList, TouchableOpacity, Text, StyleSheet } from 'react-native';
|
|
import { useRouter } from 'expo-router';
|
|
import repositoryService from '../../services/repositoryService';
|
|
import { logger } from '../../utils/logger';
|
|
|
|
export default function RepoSearch() {
|
|
const router = useRouter();
|
|
const [query, setQuery] = useState('');
|
|
const [results, setResults] = useState([]);
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const handleSearch = async () => {
|
|
if (!query.trim()) return;
|
|
|
|
setLoading(true);
|
|
try {
|
|
const data = await repositoryService.search(query);
|
|
setResults(data.repositories);
|
|
} catch (error) {
|
|
logger.error('Search failed', error);
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
const renderRepo = ({ item }: any) => (
|
|
<TouchableOpacity
|
|
style={styles.repoCard}
|
|
onPress={() => router.push(`/repo/${item.owner}/${item.name}`)}
|
|
>
|
|
<Text style={styles.repoName}>{item.fullName}</Text>
|
|
<Text style={styles.repoDesc} numberOfLines={2}>
|
|
{item.description || 'No description'}
|
|
</Text>
|
|
<View style={styles.repoStats}>
|
|
<Text style={styles.stat}>⭐ {item.stars.toLocaleString()}</Text>
|
|
{item.language && <Text style={styles.stat}>💻 {item.language}</Text>}
|
|
</View>
|
|
</TouchableOpacity>
|
|
);
|
|
|
|
return (
|
|
<View style={styles.container}>
|
|
<View style={styles.searchBar}>
|
|
<TextInput
|
|
style={styles.input}
|
|
value={query}
|
|
onChangeText={setQuery}
|
|
placeholder="Search GitHub repos (e.g., vscode, react)"
|
|
onSubmitEditing={handleSearch}
|
|
/>
|
|
<TouchableOpacity style={styles.searchBtn} onPress={handleSearch}>
|
|
<Text style={styles.searchBtnText}>Search</Text>
|
|
</TouchableOpacity>
|
|
</View>
|
|
|
|
<FlatList
|
|
data={results}
|
|
renderItem={renderRepo}
|
|
keyExtractor={(item: any) => item.fullName}
|
|
contentContainerStyle={styles.list}
|
|
/>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: { flex: 1, backgroundColor: '#fff' },
|
|
searchBar: { flexDirection: 'row', padding: 16, gap: 8 },
|
|
input: { flex: 1, borderWidth: 1, borderColor: '#ddd', borderRadius: 8, padding: 12 },
|
|
searchBtn: { backgroundColor: '#007AFF', borderRadius: 8, padding: 12, justifyContent: 'center' },
|
|
searchBtnText: { color: '#fff', fontWeight: '600' },
|
|
list: { padding: 16 },
|
|
repoCard: { backgroundColor: '#f9f9f9', borderRadius: 8, padding: 16, marginBottom: 12 },
|
|
repoName: { fontSize: 16, fontWeight: '600', marginBottom: 8 },
|
|
repoDesc: { fontSize: 14, color: '#666', marginBottom: 8 },
|
|
repoStats: { flexDirection: 'row', gap: 16 },
|
|
stat: { fontSize: 12, color: '#666' },
|
|
});
|