Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
301 lines
7.8 KiB
TypeScript
301 lines
7.8 KiB
TypeScript
import React, { useState } from 'react';
|
||
import {
|
||
View,
|
||
Text,
|
||
StyleSheet,
|
||
ScrollView,
|
||
TextInput,
|
||
TouchableOpacity,
|
||
Alert,
|
||
} from 'react-native';
|
||
import { useRouter } from 'expo-router';
|
||
import { Colors } from '../../constants/Colors';
|
||
import Header from '../../components/navigation/Header';
|
||
import LoadingSpinner from '../../components/common/LoadingSpinner';
|
||
import { logger } from '../../utils/logger';
|
||
import * as ImagePicker from 'expo-image-picker';
|
||
import { Image } from 'expo-image';
|
||
import { storeService } from '../../services/storeService';
|
||
|
||
export default function SellItemScreen() {
|
||
const router = useRouter();
|
||
const [title, setTitle] = useState('');
|
||
const [description, setDescription] = useState('');
|
||
const [price, setPrice] = useState('');
|
||
const [category, setCategory] = useState<'project' | 'code' | 'template'>('project');
|
||
const [images, setImages] = useState<string[]>([]);
|
||
const [loading, setLoading] = useState(false);
|
||
|
||
const pickImage = async () => {
|
||
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||
if (status !== 'granted') {
|
||
Alert.alert('Permission needed', 'Please grant camera roll permissions');
|
||
return;
|
||
}
|
||
|
||
const result = await ImagePicker.launchImageLibraryAsync({
|
||
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||
allowsMultipleSelection: true,
|
||
quality: 0.8,
|
||
});
|
||
|
||
if (!result.canceled) {
|
||
setImages([...images, ...result.assets.map((asset) => asset.uri)]);
|
||
}
|
||
};
|
||
|
||
const handleSubmit = async () => {
|
||
if (!title.trim()) {
|
||
Alert.alert('Error', 'Please enter a title');
|
||
return;
|
||
}
|
||
if (!description.trim()) {
|
||
Alert.alert('Error', 'Please enter a description');
|
||
return;
|
||
}
|
||
if (!price || parseFloat(price) <= 0) {
|
||
Alert.alert('Error', 'Please enter a valid price');
|
||
return;
|
||
}
|
||
|
||
setLoading(true);
|
||
try {
|
||
const formData = new FormData();
|
||
formData.append('title', title);
|
||
formData.append('description', description);
|
||
formData.append('price', parseFloat(price).toString());
|
||
formData.append('category', category);
|
||
|
||
images.forEach((uri, index) => {
|
||
formData.append('images', {
|
||
uri,
|
||
type: 'image/jpeg',
|
||
name: `image_${index}.jpg`,
|
||
} as any);
|
||
});
|
||
|
||
await storeService.createItem(formData);
|
||
Alert.alert('Success', 'Item listed successfully!', [
|
||
{ text: 'OK', onPress: () => router.back() },
|
||
]);
|
||
} catch (error) {
|
||
logger.error('Create store item error:', error);
|
||
Alert.alert('Error', 'Failed to list item');
|
||
} finally {
|
||
setLoading(false);
|
||
}
|
||
};
|
||
|
||
return (
|
||
<ScrollView style={styles.container}>
|
||
<Header title="Sell Item" />
|
||
<View style={styles.content}>
|
||
<Text style={styles.label}>Category</Text>
|
||
<View style={styles.categories}>
|
||
{(['project', 'code', 'template'] as const).map((cat) => (
|
||
<TouchableOpacity
|
||
key={cat}
|
||
style={[
|
||
styles.categoryButton,
|
||
category === cat && styles.selectedCategory,
|
||
]}
|
||
onPress={() => setCategory(cat)}
|
||
>
|
||
<Text
|
||
style={[
|
||
styles.categoryText,
|
||
category === cat && styles.selectedCategoryText,
|
||
]}
|
||
>
|
||
{cat.charAt(0).toUpperCase() + cat.slice(1)}
|
||
</Text>
|
||
</TouchableOpacity>
|
||
))}
|
||
</View>
|
||
|
||
<Text style={styles.label}>Title</Text>
|
||
<TextInput
|
||
style={styles.input}
|
||
value={title}
|
||
onChangeText={setTitle}
|
||
placeholder="Enter item title"
|
||
placeholderTextColor={Colors.textSecondary}
|
||
maxLength={100}
|
||
/>
|
||
|
||
<Text style={styles.label}>Description</Text>
|
||
<TextInput
|
||
style={styles.input}
|
||
value={description}
|
||
onChangeText={setDescription}
|
||
placeholder="Describe your item..."
|
||
placeholderTextColor={Colors.textSecondary}
|
||
multiline
|
||
numberOfLines={6}
|
||
maxLength={1000}
|
||
/>
|
||
|
||
<Text style={styles.label}>Price ($)</Text>
|
||
<TextInput
|
||
style={styles.input}
|
||
value={price}
|
||
onChangeText={setPrice}
|
||
placeholder="0.00"
|
||
placeholderTextColor={Colors.textSecondary}
|
||
keyboardType="decimal-pad"
|
||
/>
|
||
|
||
<Text style={styles.label}>Images</Text>
|
||
<TouchableOpacity style={styles.imagePicker} onPress={pickImage}>
|
||
<Text style={styles.imagePickerText}>Add Images</Text>
|
||
</TouchableOpacity>
|
||
|
||
{images.length > 0 && (
|
||
<View style={styles.imagePreview}>
|
||
{images.map((uri, index) => (
|
||
<View key={index} style={styles.imageContainer}>
|
||
<Image source={{ uri }} style={styles.previewImage} />
|
||
<TouchableOpacity
|
||
style={styles.removeImage}
|
||
onPress={() => setImages(images.filter((_, i) => i !== index))}
|
||
>
|
||
<Text style={styles.removeImageText}>×</Text>
|
||
</TouchableOpacity>
|
||
</View>
|
||
))}
|
||
</View>
|
||
)}
|
||
|
||
<TouchableOpacity
|
||
style={[styles.button, loading && styles.buttonDisabled]}
|
||
onPress={handleSubmit}
|
||
disabled={loading}
|
||
>
|
||
{loading ? (
|
||
<LoadingSpinner />
|
||
) : (
|
||
<Text style={styles.buttonText}>List Item for Sale</Text>
|
||
)}
|
||
</TouchableOpacity>
|
||
</View>
|
||
</ScrollView>
|
||
);
|
||
}
|
||
|
||
const styles = StyleSheet.create({
|
||
container: {
|
||
flex: 1,
|
||
backgroundColor: Colors.background,
|
||
},
|
||
content: {
|
||
padding: 16,
|
||
},
|
||
label: {
|
||
color: Colors.text,
|
||
fontSize: 16,
|
||
fontWeight: '600',
|
||
marginBottom: 8,
|
||
marginTop: 16,
|
||
},
|
||
categories: {
|
||
flexDirection: 'row',
|
||
gap: 8,
|
||
marginBottom: 16,
|
||
},
|
||
categoryButton: {
|
||
flex: 1,
|
||
backgroundColor: Colors.surface,
|
||
borderRadius: 8,
|
||
padding: 12,
|
||
alignItems: 'center',
|
||
borderWidth: 2,
|
||
borderColor: 'transparent',
|
||
},
|
||
selectedCategory: {
|
||
borderColor: Colors.accent,
|
||
backgroundColor: Colors.accentBackground || Colors.surface,
|
||
},
|
||
categoryText: {
|
||
fontSize: 14,
|
||
fontWeight: '600',
|
||
color: Colors.text,
|
||
},
|
||
selectedCategoryText: {
|
||
color: Colors.accent,
|
||
},
|
||
input: {
|
||
backgroundColor: Colors.surface,
|
||
borderRadius: 8,
|
||
padding: 12,
|
||
color: Colors.text,
|
||
fontSize: 16,
|
||
borderWidth: 1,
|
||
borderColor: Colors.border,
|
||
marginBottom: 12,
|
||
textAlignVertical: 'top',
|
||
},
|
||
imagePicker: {
|
||
backgroundColor: Colors.surface,
|
||
borderRadius: 8,
|
||
padding: 16,
|
||
alignItems: 'center',
|
||
borderWidth: 2,
|
||
borderColor: Colors.border,
|
||
borderStyle: 'dashed',
|
||
marginBottom: 12,
|
||
},
|
||
imagePickerText: {
|
||
color: Colors.accent,
|
||
fontSize: 16,
|
||
fontWeight: '600',
|
||
},
|
||
imagePreview: {
|
||
flexDirection: 'row',
|
||
flexWrap: 'wrap',
|
||
gap: 8,
|
||
marginBottom: 16,
|
||
},
|
||
imageContainer: {
|
||
position: 'relative',
|
||
width: 100,
|
||
height: 100,
|
||
},
|
||
previewImage: {
|
||
width: 100,
|
||
height: 100,
|
||
borderRadius: 8,
|
||
},
|
||
removeImage: {
|
||
position: 'absolute',
|
||
top: -8,
|
||
right: -8,
|
||
width: 24,
|
||
height: 24,
|
||
borderRadius: 12,
|
||
backgroundColor: Colors.error || '#ff4444',
|
||
justifyContent: 'center',
|
||
alignItems: 'center',
|
||
},
|
||
removeImageText: {
|
||
color: Colors.text,
|
||
fontSize: 18,
|
||
fontWeight: 'bold',
|
||
},
|
||
button: {
|
||
backgroundColor: Colors.buttonPrimary,
|
||
borderRadius: 6,
|
||
padding: 16,
|
||
alignItems: 'center',
|
||
marginTop: 20,
|
||
},
|
||
buttonDisabled: {
|
||
opacity: 0.6,
|
||
},
|
||
buttonText: {
|
||
color: Colors.text,
|
||
fontSize: 16,
|
||
fontWeight: '600',
|
||
},
|
||
});
|
||
|