ZingTruyen.Xyz

לרפא את העולם עם קודי בינה מלאכותית

4

MarkPIcassoMPA

🌟 אפליקציית Holistic Health Snap – סיפור + קוד מלאהסיפור

עכשיו, כאשר המשפחה שלך חמה, והם יכולים להישאר בריאים בזכות מיומנויות היגיינה ובישול, בהתחלה הכל בסדר. אתם נהנים מהחיים ומהחברה של אחד את השני.

מרחוק אתם שומעים את ילדכם צועק. הוא הלך זה עתה לשירותים ומשהו לא בסדר. אינכם יודעים מה לעשות. אין לכם רופא, רק אתם. משהו לא תקין בצואה של הילד שלכם. היא לבנה ונראית חיה. אתם מפוחדים. אתם זוכרים שיש לכם אפליקציה חדשה בטלפון. אתם פותחים את האפליקציה:

אתם מצלמים תמונה של הבעיה, והיא מזוהה מיד, וגם מוצע פתרון. הילד שלכם סובל מהתולעים. מכיוון שאין רופא, הילד לומד מה עוזר להיפטר מהן. עכשיו יש לכם תוכנית ואתם יודעים שהם בטוחים. כל מה שהם צריכים הוא עזרה.

לגבי אפליקציה זו, רציתי כמה דברים:

היא חייבת לאפשר צילום תמונות של הבעיות.

חייב להיות מקום להוסיף ולעדכן תמונות חדשות באופן מתמשך כדי לזהות עוד בעיות.

🌐 React Native Code – Holistic Health Snapimport React, { useState, useEffect } from 'react'; import { View, Text, Button, Image, FlatList, TextInput, StyleSheet, TouchableOpacity } from 'react-native'; import { launchCamera } from 'react-native-image-picker'; import AsyncStorage from '@react-native-async-storage/async-storage'; // ------------------- // קטגוריות ופתרונות // ------------------- const CATEGORIES = [ { name: "עור", remedies: ["נקו בעדינות עם סבון עדין", "מרחו ג'ל אלוורה", "הימנעו מגירוד"] }, { name: "עקיצת חרק", remedies: ["נקה את העקיצה במים", "מרח דבש או אלוורה", "השתמש בקומפרס קר"] }, { name: "חבורה", remedies: ["הנח חבילת קרח בתחילה", "הרם את האזור הפגוע", "עיסוי עדין לאחר 48 שעות"] }, { name: "תולעים/פרזיטים", remedies: ["שמור על היגיינה", "רתח מים לפני שתייה", "אכל מזון עשיר בסיבים"] }, { name: "אחר", remedies: ["שמור על האזור נקי", "עקוב אחרי שינויים", "חפש עזרה אם המצב מחמיר"] }, ]; // ------------------- // אפליקציה ראשית // ------------------- export default function App() { const [photoData, setPhotoData] = useState([]); const [description, setDescription] = useState(''); const [selectedCategory, setSelectedCategory] = useState(CATEGORIES[0].name); const [currentPhoto, setCurrentPhoto] = useState(null); useEffect(() => { loadData(); }, []); // טען תמונות שמורות const loadData = async () => { try { const data = await AsyncStorage.getItem('photos'); if (data !== null) setPhotoData(JSON.parse(data)); } catch (error) { console.log(error); } }; // שמירת נתוני תמונה const saveData = async (newData) => { try { await AsyncStorage.setItem('photos', JSON.stringify(newData)); } catch (error) { console.log(error); } }; // פתיחת מצלמה const takePhoto = () => { launchCamera({ mediaType: 'photo', quality: 0.5 }, response => { if (response.assets && response.assets.length > 0) { setCurrentPhoto(response.assets[0].uri); } }); }; // שמירת תמונה + תיאור + פתרונות const savePhoto = () => { if (!currentPhoto) return; const categoryObj = CATEGORIES.find(cat => cat.name === selectedCategory) || { remedies: [] }; const newEntry = { uri: currentPhoto, category: selectedCategory, description, remedies: categoryObj.remedies, timestamp: new Date().toISOString() }; const updatedData = [newEntry, ...photoData]; setPhotoData(updatedData); saveData(updatedData); setCurrentPhoto(null); setDescription(''); }; // ------------------- // הצגת המסך // ------------------- return ( <View style={styles.container}> <Text style={styles.header}>Holistic Health Snap</Text> <Button onPress={takePhoto} /> {currentPhoto && ( <View style={styles.preview}> <Image source={{ uri: currentPhoto }} style={styles.image} /> <TextInput value={description} onChangeText={setDescription} style={styles.input} /> <View style={styles.categories}> {CATEGORIES.map(cat => ( <TouchableOpacity key={cat.name} onPress={() => setSelectedCategory(cat.name)} style={[styles.categoryButton, selectedCategory === cat.name && styles.selectedCategory]} > <Text>{cat.name}</Text> </TouchableOpacity> ))} </View> <Button onPress={savePhoto} /> </View> )} <Text style={styles.subHeader}>תמונות ופתרונות שמורים:</Text> <FlatList data={photoData} keyExtractor={(item, index) => index.toString()} renderItem={({ item }) => ( <View style={styles.item}> <Image source={{ uri: item.uri }} style={styles.thumbnail} /> <View style={{ flex: 1, marginLeft: 10 }}> <Text style={styles.itemText}>קטגוריה: {item.category}</Text> <Text style={styles.itemText}>תיאור: {item.description || "N/A"}</Text> <Text style={styles.itemText}>תאריך: {new Date(item.timestamp).toLocaleString()}</Text> <Text style={styles.itemTextBold}>פתרונות הוליסטיים:</Text> {item.remedies.map((remedy, i) => ( <Text key={i} style={styles.itemText}>• {remedy}</Text> ))} </View> </View> )} /> </View> ); } // ------------------- // עיצוב // ------------------- const styles = StyleSheet.create({ container: { flex: 1, padding: 20, backgroundColor: '#f5f5f5' }, header: { fontSize: 28, fontWeight: 'bold', marginBottom: 10 }, subHeader: { fontSize: 20, marginTop: 20, marginBottom: 10 }, preview: { marginVertical: 10 }, image: { width: '100%', height: 200, marginBottom: 10 }, input: { borderColor: '#ccc', borderWidth: 1, padding: 8, marginBottom: 10, borderRadius: 5 }, categories: { flexDirection: 'row', flexWrap: 'wrap', marginBottom: 10 }, categoryButton: { padding: 8, borderWidth: 1, borderColor: '#ccc', borderRadius: 5, marginRight: 5, marginBottom: 5 }, selectedCategory: { backgroundColor: '#a0e1e5' }, item: { flexDirection: 'row', marginBottom: 10, backgroundColor: '#fff', padding: 10, borderRadius: 5 }, thumbnail: { width: 80, height: 80, borderRadius: 5 }, itemText: { fontSize: 14 }, itemTextBold: { fontSize: 16, fontWeight: 'bold', marginTop: 5 } });

Bạn đang đọc truyện trên: ZingTruyen.Xyz