hacı bu sayfadan şimdi firebaseden stories bilgilerini… · The Chat Archive
Explore / Programming o1-mini-2024-09-12 · OpenAI WildChat-4.8M (AI2)hacı bu sayfadan şimdi firebaseden stories bilgilerini çekiyoruz incele: import React, {… Save Share Download ▾ Reporthacı bu sayfadan şimdi firebaseden stories bilgilerini çekiyoruz incele:
import React, { useState, useEffect, useCallback, useMemo, useContext } from 'react';
import {
View,
ScrollView,
Text,
StyleSheet,
FlatList,
Image,
RefreshControl,
TouchableOpacity,
Dimensions,
ActivityIndicator
} from 'react-native';
import { collection, getDocs, query, where, doc, getDoc } from 'firebase/firestore';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { db, auth } from '../utils/firebase';
import { useThemeAndLanguage } from '../utils/ThemeAndLanguageContext';
import { useNavigation } from '@react-navigation/native';
import Carousel from 'react-native-reanimated-carousel';
import useInternetStatus from '../utils/useInternetStatus';
import InternetStatusAlert from '../components/InternetStatusAlert';
import { Ionicons } from '@expo/vector-icons';
import { HeartContext } from './HeartContext'; // HeartContext import edildi
const { width: screenWidth } = Dimensions.get('window');
const NewsTab = () => {
const { theme, t, locale, arabicFont } = useThemeAndLanguage();
const [news, setNews] = useState([]);
const [refreshing, setRefreshing] = useState(false);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
const [categories, setCategories] = useState([]);
const [selectedCategory, setSelectedCategory] = useState('All');
const [showInternetAlert, setShowInternetAlert] = useState(false);
const [initialLoad, setInitialLoad] = useState(true);
const navigation = useNavigation();
const { isConnected } = useInternetStatus();
const categoryField = useMemo(() => locale === 'tr' ? 'categoryturkish' : 'categoryenglish', [locale]);
const loadCachedData = useCallback(async () => {
const cachedNews = await AsyncStorage.getItem('news');
if (cachedNews) {
const parsedNews = JSON.parse(cachedNews);
const newsWithDates = parsedNews.map(item => ({
...item,
formattedDate: item.formattedDate ? new Date(item.formattedDate) : null
}));
setNews(newsWithDates);
updateCategories(newsWithDates);
}
}, [updateCategories]);
const updateCategories = useCallback((newsData) => {
const categoriesSet = new Set(newsData.map(item => item[categoryField]));
setCategories(['All', ...Array.from(categoriesSet)]);
}, [categoryField]);
const getTimeAgo = useCallback((dateString) => {
if (!dateString) {
return t('noDate');
}
const date = new Date(dateString);
if (isNaN(date.getTime())) {
return t('invalidDate');
}
const now = new Date();
const diffInSeconds = Math.floor((now - date) / 1000);
if (diffInSeconds < 60) return t('justNow');
if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)} ${t('minutesAgo')}`;
if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)} ${t('hoursAgo')}`;
if (diffInSeconds < 2592000) return `${Math.floor(diffInSeconds / 86400)} ${t('daysAgo')}`;
if (diffInSeconds < 31536000) return `${Math.floor(diffInSeconds / 2592000)} ${t('monthsAgo')}`;
return `${Math.floor(diffInSeconds / 31536000)} ${t('yearsAgo')}`;
Assistant2024-11-01 19:00 UTC Copy response
Copy first prompt
Other models, same or similar prompt Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Details
Model o1-mini-2024-09-12
Provider OpenAI
Model provenance As recorded by source dataset
Turns 1 (2 messages)
Language tr
Conversation date Nov 1, 2024
Added to archive Nov 16, 2026
ID 01m7h4240h1q8q7tcdx6fc8ebjSource & license Imported from WildChat-4.8M (AI2) (source ). Imported records earn no Research Points.
Upstream record: e48dcc1283ac39f83b1c9245d3ca6f2b
Zhao et al., WildChat: 1M ChatGPT Interaction Logs in the Wild (ICLR 2024). Contains information from WildChat-4.8M, made available under the ODC Attribution License.
License: ODC-BY-1.0
Dataset releases Not yet included in a published release.
const fetchNews = useCallback(async () => {
if (!isConnected) {
setError(t('noInternetError'));
return;
}
setError(null);
setLoading(true);
try {
const storiesCollection = collection(db, 'stories');
const newsQuery = query(storiesCollection, where("news", "==", 1));
const newsSnapshot = await getDocs(newsQuery);
const newsData = newsSnapshot.docs.map(doc => {
const data = doc.data();
return {
id: doc.id,
...data,
formattedDate: data.date ? new Date(data.date).toISOString() : null,
hearts: data.hearts || 0
};
});
const sortedNewsData = newsData.sort((a, b) => {
if (a.formattedDate && b.formattedDate) {
return new Date(b.formattedDate) - new Date(a.formattedDate);
}
if (a.formattedDate) return -1;
if (b.formattedDate) return 1;
return 0;
});
await AsyncStorage.setItem('news', JSON.stringify(sortedNewsData));
await AsyncStorage.setItem('lastNewsFetch', new Date().toISOString().split('T')[0]);
setNews(sortedNewsData);
updateCategories(sortedNewsData);
} catch (error) {
console.error('Error fetching news:', error);
setError(t('fetchNewsError'));
await loadCachedData();
} finally {
setLoading(false);
setInitialLoad(false);
}
}, [updateCategories, isConnected, t, loadCachedData]);
const { heartsCounts, userHearts } = useContext(HeartContext); // Correctly destructure HeartContext
useEffect(() => {
// Update news hearts with heart counts from context
setNews(prevNews =>
prevNews.map(story => ({
...story,
hearts: heartsCounts[story.id] !== undefined ? heartsCounts[story.id] : story.hearts
}))
);
}, [heartsCounts]);
useEffect(() => {
const loadData = async () => {
const lastFetch = await AsyncStorage.getItem('lastNewsFetch');
const currentDate = new Date().toISOString().split('T')[0];
if (lastFetch === currentDate) {
await loadCachedData();
setLoading(false);
} else {
if (isConnected) {
await fetchNews();
} else {
await loadCachedData();
setLoading(false);
}
}
};
loadData();
}, [isConnected, loadCachedData, fetchNews]);
useEffect(() => {
if (!isConnected && !initialLoad) {
setShowInternetAlert(true);
} else {
setShowInternetAlert(false);
}
}, [isConnected, initialLoad]);
const onRefresh = useCallback(async () => {
if (!isConnected) {
setShowInternetAlert(true);
return;
}
setRefreshing(true);
await fetchNews();
setRefreshing(false);
}, [fetchNews, isConnected]);
const renderCategoryItem = useCallback((item) => (
<TouchableOpacity
key={item}
style={[
styles.categoryLabel,
selectedCategory === item && { backgroundColor: theme.primaryColor }
]}
onPress={() => setSelectedCategory(item)}
>
<Text style={[
styles.categoryText,
selectedCategory === item && { color: theme.backgroundColor }
]}>
{item === 'All' ? t('all') : item}
), [selectedCategory, theme, t]);
const renderCarouselItem = useCallback(({ item }) => (
<TouchableOpacity
style={styles.carouselItem}
onPress={() => navigation.navigate('ReadStoryScreen', { story: item })}
>
<Image source={{ uri: item.thumbnail }} style={styles.carouselThumbnail} />
<Text style={[styles.carouselTitleArabic, { fontFamily: arabicFont }]}>
{item.storytitlearabic}
{item[storytitle${locale === 'tr' ? 'turkish' : 'english'}]}
), [navigation, locale, arabicFont]);
const renderRegularNews = useCallback(({ item }) => {
const isHearted = !!userHearts[item.id]; // Using context's userHearts
const heartCount = heartsCounts[item.id] || item.hearts; // Using context's heartsCounts
return (
<TouchableOpacity
style={[styles.regularNewsItem, { backgroundColor: theme.lighterCardBackgroundColor }]}
onPress={() => navigation.navigate('ReadStoryScreen', { story: item })}
>
<Image
source={{ uri: item.thumbnail }}
style={styles.thumbnail}
resizeMode="cover"
/>
<View style={styles.regularTextContainer}>
<Text style={[styles.regularTitleArabic, { color: theme.textColor, fontFamily: arabicFont }]}>
{item.storytitlearabic}
</Text>
<Text style={[styles.regularTitleTurkish, { color: theme.textColor }]}>
{item[`storytitle${locale === 'tr' ? 'turkish' : 'english'}`]}
</Text>
<View style={styles.infoContainer}>
<Text style={[styles.infoText, { color: theme.textColor, borderColor: theme.textColor }]}>
{item[categoryField]}
</Text>
<Text style={[styles.infoText, { color: theme.textColor, borderColor: theme.textColor }]}>
{item.langlevel}
</Text>
<Text style={[styles.infoText, { color: theme.textColor, borderColor: theme.textColor }]}>
{getTimeAgo(item.formattedDate)}
</Text>
<View style={styles.infoText}>
<Ionicons
name={isHearted ? 'heart' : 'heart-outline'} // Eğer beğenildiyse 'heart', değilse 'heart-outline'
color={isHearted ? 'red' : theme.textColor} // Beğenildiyse kırmızı, değilse mevcut tema rengi
size={8} // Kalp simgesi boyutu, değiştirmedim
/>
<Text style={[styles.heartCount, { color: theme.textColor, marginLeft: 4 }]}>
{heartCount}
</Text>
</View>
</View>
</View>
</TouchableOpacity>
);
}, [theme, categoryField, locale, arabicFont, navigation, getTimeAgo, t, userHearts, heartsCounts]);
const filteredNews = useMemo(() =>
news.filter(item => selectedCategory === 'All' || item[categoryField] === selectedCategory),
[news, selectedCategory, categoryField]
);
const carouselData = useMemo(() => news.slice(0, 4), [news]);
const regularNewsData = useMemo(() =>
selectedCategory === 'All' ? filteredNews.slice(4) : filteredNews,
[selectedCategory, filteredNews]
);
const ListHeaderComponent = useCallback(() => (
<>
{error && <Text style={[styles.errorText, { color: theme.errorColor }]}>{error}}
{selectedCategory === 'All' && (
<Carousel
style={[styles.carousel, { aspectRatio: 3 / 2 }]}
width={screenWidth}
data={carouselData}
renderItem={renderCarouselItem}
loop
autoPlay
autoPlayInterval={5000}
mode="parallax"
modeConfig={{
parallaxScrollingScale: 0.9,
parallaxScrollingOffset: 50,
}}
/>
)}
{categories.map(renderCategoryItem)}
</>
), [error, selectedCategory, carouselData, renderCarouselItem, categories, renderCategoryItem, theme.errorColor]);
if (loading) {
return (
<View style={[styles.loadingContainer, { backgroundColor: theme.backgroundColor }]}>
);
}
return (
<View style={{ flex: 1, backgroundColor: theme.backgroundColor }}>
<InternetStatusAlert
visible={showInternetAlert}
onDismiss={() => setShowInternetAlert(false)}
/>
<FlatList
data={regularNewsData}
keyExtractor={item => item.id}
renderItem={renderRegularNews}
ListHeaderComponent={ListHeaderComponent}
refreshControl={
}
initialNumToRender={5}
maxToRenderPerBatch={5}
windowSize={11}
/>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
loadingContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
errorText: {
textAlign: 'center',
marginTop: 10,
marginBottom: 10,
},
categoryContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'center',
marginVertical: 5,
},
categoryLabel: {
backgroundColor: 'white',
borderRadius: 10,
paddingVertical: 3,
paddingHorizontal: 2,
marginHorizontal: 3,
marginBottom: 5,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 2,
elevation: 2,
},
categoryText: {
fontSize: 13,
fontWeight: 'bold',
padding: 8,
},
carousel: {
aspectRatio: 3 / 2,
width: "100%",
},
carouselItem: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
borderRadius: 10,
overflow: 'hidden',
},
carouselThumbnail: {
width: '100%',
height: '100%',
resizeMode: 'cover',
},
carouselTitleContainer: {
position: 'absolute',
bottom: 10,
left: 10,
right: 10,
padding: 5,
backgroundColor: 'rgba(255, 255, 255, 0.8)',
borderRadius: 10,
},
carouselTitleArabic: {
fontSize: 22,
textAlign: 'center',
color: '#000',
},
carouselTitleTurkish: {
fontSize: 16,
marginTop: 5,
textAlign: 'center',
color: '#000',
},
regularNewsItem: {
flexDirection: 'row',
marginBottom: 10,
borderRadius: 10,
overflow: 'hidden',
elevation: 3,
marginHorizontal: 10,
},
thumbnail: {
width: '40%',
height: '100%',
resizeMode: 'center',
},
regularTextContainer: {
padding: 10,
flex: 1,
justifyContent: 'space-between',
},
regularTitleArabic: {
fontSize: 22,
textAlign: 'center',
},
regularTitleTurkish: {
fontSize: 15,
},
infoContainer: {
paddingTop: 10,
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'center',
alignItems: 'center',
},
infoText: {
fontSize: 8,
textAlign: 'center',
marginRight: 4,
marginBottom: 2,
paddingVertical: 4,
paddingHorizontal: 5,
borderWidth:0.3,
borderRadius: 4,
backgroundColor: 'transparent',
textTransform: 'uppercase',
fontWeight: 'bold',
flexDirection: 'row',
},
heartCount: {
fontSize: 8,
fontWeight: 'bold',
},
});
export default React.memo(NewsTab);
import React, { useEffect, useState, useRef, useCallback, useMemo } from 'react';
import { View, StyleSheet, Text, FlatList, Image, TouchableOpacity, ActivityIndicator, BackHandler } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import WordExplanationBox from './WordExplanationBox';
import AsyncStorage from '@react-native-async-storage/async-storage';
import * as Font from 'expo-font';
import { useThemeAndLanguage } from '../utils/ThemeAndLanguageContext';
import { BottomSheetModal, BottomSheetModalProvider, BottomSheetScrollView } from '@gorhom/bottom-sheet';
import QuizScreen from './QuizScreen';
import { doc, getDoc } from 'firebase/firestore';
import { db } from '../utils/firebase';
import { useFocusEffect } from '@react-navigation/native';
import { useVocabulary } from './VocabularyContext';
import PropTypes from 'prop-types';
import ToggleHeartButton from './heart';
const ARABIC_FONTS = {
'Scheherazade': require('../../assets/fonts/scheherazade.ttf'),
'Adobe Arabic': require('../../assets/fonts/adobearabic.ttf'),
'Amiri': require('../../assets/fonts/amiri.ttf'),
'Noto Naskh Arabic': require('../../assets/fonts/noto.ttf'),
};
const STORAGE_KEY = '@user_words';
const Word = React.memo(({ word, onPress, style, isKnown }) => (
<TouchableOpacity onPress={() => onPress(word)}>
<Text style={[style, isKnown && styles.knownWord]}>{word}
));
Word.propTypes = {
word: PropTypes.string.isRequired,
onPress: PropTypes.func.isRequired,
style: PropTypes.object,
isKnown: PropTypes.bool,
};
const Sentence = React.memo(({ sentenceObj, selectedSentence, handleSentenceButtonPress, handleWordPress, fontSize, theme, arabicFont, knownWords }) => {
if (sentenceObj.type === 'image') {
return (
<Image
source={{ uri: sentenceObj.content }}
style={[styles.imageStyle]}
/>
);
}
const isHeaderOrSubHeader = sentenceObj.type === 'header' || sentenceObj.type === 'subheader';
return (
<View style={[
styles.sentenceContainer,
selectedSentence === sentenceObj.content && styles.selectedSentence,
isHeaderOrSubHeader && (sentenceObj.type === 'header' ? styles.headerContainer : styles.subHeaderContainer),
{
borderRightColor: sentenceObj.type === 'header' ? theme.primaryColor : theme.secondaryColor
} ]}>
<TouchableOpacity style={styles.explanationButton} onPress={() => handleSentenceButtonPress(sentenceObj.content)}>
{sentenceObj.content.split(' ').map((word, wordIndex) => (
<Word
key={${sentenceObj.id}-${wordIndex}}
word={word}
onPress={handleWordPress}
style={[
styles.descriptionArabic,
{
fontSize: isHeaderOrSubHeader ? fontSize * 1.6 : fontSize * 1.4,
color: theme.textColor,
fontFamily: arabicFont,
}
]}
isKnown={knownWords.has(word)}
/>
))}
);
});
Sentence.propTypes = {
sentenceObj: PropTypes.shape({
type: PropTypes.string,
content: PropTypes.string,
id: PropTypes.string,
}).isRequired,
selectedSentence: PropTypes.string,
handleSentenceButtonPress: PropTypes.func.isRequired,
handleWordPress: PropTypes.func.isRequired,
fontSize: PropTypes.number.isRequired,
theme: PropTypes.object.isRequired,
arabicFont: PropTypes.string.isRequired,
knownWords: PropTypes.instanceOf(Set).isRequired,
};
export default function ReadStoryScreen({ route, navigation }) {
const { story, storyId } = route.params;
const [fontSize, setFontSize] = useState(18);
const [selectedWord, setSelectedWord] = useState(null);
const [selectedSentence, setSelectedSentence] = useState(null);
const [loading, setLoading] = useState(true);
const [cachedStory, setCachedStory] = useState(null);
const [hasQuiz, setHasQuiz] = useState(false);
const bottomSheetModalRef = useRef(null);
const settingsBottomSheetModalRef = useRef(null);
const quizBottomSheetModalRef = useRef(null);
const { locale, theme, arabicFont, setFontFamily, t } = useThemeAndLanguage();
const [activeModal, setActiveModal] = useState(null);
const [knownWords, setKnownWords] = useState(new Set());
const { vocabulary, isLoggedIn, userId} = useVocabulary();
const increaseFontSize = useCallback(() => setFontSize(prevSize => prevSize + 2), []);
const decreaseFontSize = useCallback(() => setFontSize(prevSize => prevSize - 2), []);
const closeAllModals = useCallback(() => {
bottomSheetModalRef.current?.dismiss();
settingsBottomSheetModalRef.current?.dismiss();
quizBottomSheetModalRef.current?.dismiss();
setActiveModal(null);
}, []);
const openSettingsModal = useCallback(() => {
settingsBottomSheetModalRef.current?.present();
setActiveModal('settings');
}, []);
const openQuizModal = useCallback(() => {
quizBottomSheetModalRef.current?.present();
setActiveModal('quiz');
}, []);
const handleWordPress = useCallback((word) => {
setSelectedWord(word);
setSelectedSentence(null);
bottomSheetModalRef.current?.present();
setActiveModal('word');
}, []);
const handleSentenceButtonPress = useCallback((sentence) => {
setSelectedSentence(sentence);
setSelectedWord(null);
bottomSheetModalRef.current?.present();
setActiveModal('sentence');
}, []);
const loadFonts = useCallback(async () => {
await Font.loadAsync(ARABIC_FONTS);
}, []);
const fetchStoryFromFirestore = useCallback(async (id) => {
const storyDocRef = doc(db, 'stories', id);
const storyDoc = await getDoc(storyDocRef);
return storyDoc.exists() ? { id: storyDoc.id, ...storyDoc.data() } : null;
}, []);
const fetchStory = useCallback(async () => {
try {
let storyData;
if (story) {
storyData = story;
} else if (storyId) {
const cachedData = await AsyncStorage.getItem(story-${storyId});
if (cachedData) {
storyData = JSON.parse(cachedData);
} else {
storyData = await fetchStoryFromFirestore(storyId);
if (storyData) {
await AsyncStorage.setItem(story-${storyId}, JSON.stringify(storyData));
}
}
}
if (storyData) {
setCachedStory(storyData);
setHasQuiz(storyData.test_questions && storyData.test_questions.length > 0);
}
} catch (error) {
console.error('Error fetching story:', error);
} finally {
setLoading(false);
}
}, [story, storyId, fetchStoryFromFirestore]);
const fetchKnownWords = useCallback(async () => {
if (!isLoggedIn) {
setKnownWords(new Set());
return;
}
try {
const cachedWords = await AsyncStorage.getItem(STORAGE_KEY);
if (cachedWords) {
const wordsArray = JSON.parse(cachedWords);
setKnownWords(new Set(wordsArray.map(word => word.word)));
}
} catch (error) {
console.error('Error fetching known words:', error);
}
useEffect(() => {
const initialize = async () => {
await loadFonts();
await fetchStory();
await fetchKnownWords();
};
}, [loadFonts, fetchStory, fetchKnownWords]);
useEffect(() => {
if (cachedStory) {
const storyTitle = locale === 'tr' ? cachedStory.storytitleturkish : cachedStory.storytitleenglish;
const truncatedTitle = storyTitle.length > 23 ? ${storyTitle.substring(0, 23)}... : storyTitle;
navigation.setOptions({
title: truncatedTitle,
headerStyle: { backgroundColor: theme.lighterCardBackgroundColor },
headerTintColor: theme.textColor,
headerTitleStyle: { color: theme.textColor, fontWeight: 'bold' },
headerRight: () => (
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
}, [navigation, cachedStory, theme, locale, openSettingsModal]);
useFocusEffect(
useCallback(() => {
const onBackPress = () => {
if (activeModal) {
closeAllModals();
return true;
}
return false;
};
BackHandler.addEventListener('hardwareBackPress', onBackPress);
return () => BackHandler.removeEventListener('hardwareBackPress', onBackPress);
}, [activeModal, closeAllModals])
const renderSentence = useCallback(({ item: sentenceObj }) => (
), [selectedSentence, handleSentenceButtonPress, handleWordPress, fontSize, theme, arabicFont, knownWords]);
const memoizedData = useMemo(() => cachedStory?.sentences || [], [cachedStory]);
const keyExtractor = useCallback((item) => item.id.toString(), []);
useEffect(() => {
const updatedKnownWords = new Set(vocabulary.map(word => word.word));
setKnownWords(updatedKnownWords);
}, [vocabulary]);
if (loading) {
return (
<View style={[styles.loadingContainer, { backgroundColor: theme.backgroundColorForWordBox }]}>
);
}
if (!cachedStory) {
return (
<View style={[styles.loadingContainer, { backgroundColor: theme.backgroundColorForWordBox }]}>
<Text style={{ color: theme.textColor }}>{t('storyNotFound')}
);
}
return (
<View style={[styles.container, { backgroundColor: theme.backgroundColorForWordBox }]}>
<FlatList
data={memoizedData}
renderItem={renderSentence}
keyExtractor={keyExtractor}
ListHeaderComponent={() => (
<>
<Image source={{ uri: cachedStory.thumbnail }} style={styles.thumbnail} />
<Text style={[styles.titleArabic, { color: theme.textColor, fontFamily: arabicFont }]}>{cachedStory.storytitlearabic}
<Text style={[styles.titleTurkish, { color: theme.secondaryColor }]}>
{locale === 'tr' ? cachedStory.storytitleturkish : cachedStory.storytitleenglish}
</>
)}
initialNumToRender={10}
maxToRenderPerBatch={5}
windowSize={10}
/>
{hasQuiz && (
<TouchableOpacity
style={[styles.quizButton, { backgroundColor: theme.primaryColor }]}
onPress={openQuizModal}
>
<Text style={styles.quizButtonText}>{t('startQuiz')}</Text>
</TouchableOpacity>
)}
<BottomSheetModal
ref={bottomSheetModalRef}
index={0}
snapPoints={['45%', '90%']}
handleStyle={{ backgroundColor: theme.backgroundColorForWordBox }}
onDismiss={() => setActiveModal(null)}
>
<WordExplanationBox
word={selectedWord || selectedSentence}
storyId={cachedStory.id}
onClose={() => bottomSheetModalRef.current?.dismiss()}
/>
<BottomSheetModal
ref={settingsBottomSheetModalRef}
index={0}
snapPoints={['85%']}
handleStyle={{ backgroundColor: theme.backgroundColorForWordBox }}
onDismiss={() => setActiveModal(null)}
>
<BottomSheetScrollView
contentContainerStyle={[
styles.settingsContent,
{ backgroundColor: theme.backgroundColorForWordBox }
]}
>
<View style={styles.exampleCard}>
<Text style={[styles.exampleText, { fontSize: fontSize * 1.4, fontFamily: arabicFont }]}>
(هذا مثال على الكتابة بالعربية)
</Text>
</View>
<View style={styles.fontSizeControls}>
<TouchableOpacity onPress={increaseFontSize} style={styles.fontSizeButton}>
<Ionicons name="add-circle-outline" size={40} color={theme.primaryColor} />
<Text style={styles.fontSizeButtonText}>{t('increaseFontSize')}</Text>
</TouchableOpacity>
<TouchableOpacity onPress={decreaseFontSize} style={styles.fontSizeButton}>
<Ionicons name="remove-circle-outline" size={40} color={theme.primaryColor} />
<Text style={styles.fontSizeButtonText}>{t('decreaseFontSize')}</Text>
</TouchableOpacity>
</View>
<View style={styles.fontOptionsContainer}>
{Object.keys(ARABIC_FONTS).map((font) => (
<TouchableOpacity
key={font}
style={styles.fontOption}
onPress={() => setFontFamily(font)}
>
<Text style={styles.fontOptionText}>{font}</Text>
<Text style={[styles.fontOptionSample, { fontFamily: font }]}>
(اقرأ العربية)
</Text>
</TouchableOpacity>
))}
</View>
</BottomSheetScrollView>
</BottomSheetModal>
{hasQuiz && (
<BottomSheetModal
ref={quizBottomSheetModalRef}
index={0}
snapPoints={['90%']}
handleStyle={{ backgroundColor: theme.backgroundColorForWordBox }}
onDismiss={() => setActiveModal(null)}
>
<QuizScreen
story={cachedStory}
onClose={() => {
quizBottomSheetModalRef.current?.dismiss();
setActiveModal(null);
}}
/>
</BottomSheetModal>
)}
</View>
</BottomSheetModalProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
knownWord: {
backgroundColor: 'rgba(0, 255, 0, 0.1)',
borderRadius: 10,
},
loadingContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
thumbnail: {
width: '100%',
aspectRatio:1/1,
},
content: {
padding: 5,
},
header: {
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
},
titleArabic: {
fontSize: 26,
},
titleTurkish: {
fontSize: 20,
marginTop: 4,
textAlign: 'center',
},
headerRight: {
flexDirection: 'row',
alignItems: 'center',
marginRight: 10,
},
fontSizeControl: {
marginHorizontal: 5,
},
sentenceContainer: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: 0,
paddingLeft: 10,
},
explanationButton: {
marginRight: 2,
},
arabicTextWrapper: {
flex: 1,
flexDirection: 'row-reverse',
flexWrap: 'wrap',
paddingRight: 15,
},
descriptionArabic: {
},
selectedSentence: {
backgroundColor: 'rgba(255, 215, 0, 0.3)',
},
settingsContent: {
flexGrow: 1,
paddingBottom: 20,
},
fontExampleContainer: {
alignItems: 'center',
marginBottom: 20,
},
exampleLabel: {
fontSize: 18,
fontWeight: 'bold',
marginBottom: 10,
},
exampleBox: {
borderWidth: 1,
borderColor: '#ccc',
borderRadius: 10,
padding: 10,
width: '80%',
alignItems: 'center',
backgroundColor: 'white',
elevation: 4,
},
fontSizeControls: {
flexDirection: 'row',
justifyContent: 'space-between',
marginVertical: 25,
paddingHorizontal: 25,
width: '80%',
alignSelf: 'center',
},
fontSizeControl: {
alignItems: 'center',
padding: 10,
},
fontSizeControlText: {
marginTop: 5,
fontSize: 14,
color: 'gray',
},
selectFontLabel: {
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
marginBottom: 10,
},
fontGrid: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-around',
marginTop: 20,
width: '80%',
alignSelf: 'center',
},
fontOptionGridItem: {
width: '45%',
padding: 5,
marginBottom: 20,
borderWidth: 1,
borderColor: '#ccc',
borderRadius: 10,
alignItems: 'center',
backgroundColor: 'white',
elevation: 4,
},
fontOptionText: {
fontSize: 16,
marginBottom: 5,
textAlign: 'center',
},
quizButton: {
display: 'flex', // Flexbox ile genişliği içeriğe göre yap
justifyContent: 'center', // İçeriği ortala
alignItems: 'center', // İçeriği dikeyde ortala
padding: 10,
},
quizButtonText: {
color: 'white',
fontWeight: 'bold',
},
bottomSheetContent: {
flexGrow: 1,
},
settingsContent: {
flexGrow: 1,
paddingHorizontal: 20,
paddingBottom: 20,
alignItems: 'center',
},
exampleCard: {
backgroundColor: 'white',
borderRadius: 10,
padding: 15,
marginVertical: 20,
width: '90%',
alignItems: 'center',
elevation: 4,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 3.84,
},
exampleText: {
textAlign: 'center',
},
fontSizeControls: {
flexDirection: 'row',
justifyContent: 'space-around',
width: '100%',
marginBottom: 20,
},
fontSizeButton: {
alignItems: 'center',
},
fontSizeButtonText: {
marginTop: 5,
fontSize: 12,
color: 'gray',
textAlign: 'center',
},
fontOptionsContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between',
width: '100%',
},
fontOption: {
width: '48%',
backgroundColor: 'white',
borderRadius: 10,
padding: 10,
marginBottom: 15,
alignItems: 'center',
elevation: 2,
shadowColor: '#000',
shadowOffset: { width: 0, height: 1 },
shadowOpacity: 0.22,
shadowRadius: 2.22,
},
fontOptionText: {
fontSize: 16,
marginBottom: 5,
},
fontOptionSample: {
fontSize: 18,
},
headerContainer: {
marginVertical: 10,
backgroundColor: 'rgba(0, 0, 0, 0.03)',
borderRightWidth: 5,
width: '97%', // Genişliği biraz küçülttük
},
subHeaderContainer: {
marginVertical: 10,
backgroundColor: 'rgba(0, 0, 0, 0.03)',
borderRightWidth: 3,
width: '97%',
},
imageStyle: {
width: "90%",
alignSelf: "center", // Ortalamak için bunu ekledik
marginBottom: 10,
aspectRatio: 1 / 1, // Oranı sabit tutmak için ekledik
elevation:1,
borderRadius:15,
},
});burada readstoryscreende şunu istiyorum cümleleri tek tek çekiyoruz ve kelime kelime tıklanılabilir hale getiriyoruz. çok güzel. ancak şunu istiyorum her bir cümleden sonra explanationButton geliyor ancak sonrasında alt satıra geçiyor onun yerine bir paragraf gibi görünmesini istiyorum. yani cümle 1 (handleSentenceButtonPress) cümle 2(handleSentenceButtonPress) şu an bu buton solda duruyor ve her cümlenin sol tarafında duruyor. bunun yerine şöyle istiyorum. 1. cümlenin ardından o buton gelecek sonrasında diğer cümle gelecek sonra yine o buton. farklı satırlarda olmayacak yani aynı satırdan devam edecek. bu handleSentenceButtonPress u da bir emoji haline getir. inşallah dediğim anlaşılmıştır. kodu eksiksiz gönder ve başka hiçbir şeyi değiştirme. rtl kalsın arapça diliyle çalışıyoruz
Anladığım kadarıyla, ReadStoryScreen bileşeninizde her cümleyi metin olarak göstermek ve cümlelerin sonuna tıklanabilir bir emoji eklemek istiyorsunuz. Bu değişiklikle birlikte, açıklama butonunun cümlenin sonuna yerleştirilmesini ve paragraf şeklinde görünmesini sağlayacağız. Ayrıca, butonu bir emoji ile değiştireceğiz.
Aşağıda, istediğiniz değişiklikleri içeren tam ReadStoryScreen bileşeni kodunu bulabilirsiniz. Bu kodda, Sentence bileşenini güncelleyerek açıklama butonunun cümlenin sonuna eklenmesini sağladık ve butonu bir emoji ile değiştirdik. RTL (sağdan sola) düzenini koruduk.
import React, { useEffect, useState, useRef, useCallback, useMemo, useContext } from 'react';
import { View, StyleSheet, Text, FlatList, Image, TouchableOpacity, ActivityIndicator, BackHandler } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import WordExplanationBox from './WordExplanationBox';
import AsyncStorage from '@react-native-async-storage/async-storage';
import * as Font from 'expo-font';
import { useThemeAndLanguage } from '../utils/ThemeAndLanguageContext';
import { BottomSheetModal, BottomSheetModalProvider, BottomSheetScrollView } from '@gorhom/bottom-sheet';
import QuizScreen from './QuizScreen';
import { doc, getDoc } from 'firebase/firestore';
import { db } from '../utils/firebase';
import { useFocusEffect } from '@react-navigation/native';
import { useVocabulary } from './VocabularyContext';
import PropTypes from 'prop-types';
import ToggleHeartButton from './heart';
const ARABIC_FONTS = {
'Scheherazade': require('../../assets/fonts/scheherazade.ttf'),
'Adobe Arabic': require('../../assets/fonts/adobearabic.ttf'),
'Amiri': require('../../assets/fonts/amiri.ttf'),
'Noto Naskh Arabic': require('../../assets/fonts/noto.ttf'),
};
const STORAGE_KEY = '@user_words';
const Word = React.memo(({ word, onPress, style, isKnown }) => (
<TouchableOpacity onPress={() => onPress(word)}>
<Text style={[style, isKnown && styles.knownWord]}>{word}</Text>
</TouchableOpacity>
));
Word.propTypes = {
word: PropTypes.string.isRequired,
onPress: PropTypes.func.isRequired,
style: PropTypes.object,
isKnown: PropTypes.bool,
};
const Sentence = React.memo(({ sentenceObj, selectedSentence, handleSentenceButtonPress, handleWordPress, fontSize, theme, arabicFont, knownWords }) => {
if (sentenceObj.type === 'image') {
return (
<Image
source={{ uri: sentenceObj.content }}
style={styles.imageStyle}
/>
);
}
const isHeaderOrSubHeader = sentenceObj.type === 'header' || sentenceObj.type === 'subheader';
return (
<View style={[
styles.sentenceContainer,
selectedSentence === sentenceObj.content && styles.selectedSentence,
isHeaderOrSubHeader && (sentenceObj.type === 'header' ? styles.headerContainer : styles.subHeaderContainer),
{
borderRightColor: sentenceObj.type === 'header' ? theme.primaryColor : theme.secondaryColor
}
]}>
<View style={styles.arabicTextWrapper}>
{sentenceObj.content.split(' ').map((word, wordIndex) => (
<Word
key={`${sentenceObj.id}-${wordIndex}`}
word={word}
onPress={handleWordPress}
style={[
styles.descriptionArabic,
{
fontSize: isHeaderOrSubHeader ? fontSize * 1.6 : fontSize * 1.4,
color: theme.textColor,
fontFamily: arabicFont,
}
]}
isKnown={knownWords.has(word)}
/>
))}
<TouchableOpacity onPress={() => handleSentenceButtonPress(sentenceObj.content)}>
<Text style={styles.emojiButton}>🗨️</Text>
</TouchableOpacity>
</View>
</View>
);
});
Sentence.propTypes = {
sentenceObj: PropTypes.shape({
type: PropTypes.string,
content: PropTypes.string,
id: PropTypes.string,
}).isRequired,
selectedSentence: PropTypes.string,
handleSentenceButtonPress: PropTypes.func.isRequired,
handleWordPress: PropTypes.func.isRequired,
fontSize: PropTypes.number.isRequired,
theme: PropTypes.object.isRequired,
arabicFont: PropTypes.string.isRequired,
knownWords: PropTypes.instanceOf(Set).isRequired,
};
export default function ReadStoryScreen({ route, navigation }) {
const { story, storyId } = route.params;
const [fontSize, setFontSize] = useState(18);
const [selectedWord, setSelectedWord] = useState(null);
const [selectedSentence, setSelectedSentence] = useState(null);
const [loading, setLoading] = useState(true);
const [cachedStory, setCachedStory] = useState(null);
const [hasQuiz, setHasQuiz] = useState(false);
const bottomSheetModalRef = useRef(null);
const settingsBottomSheetModalRef = useRef(null);
const quizBottomSheetModalRef = useRef(null);
const { locale, theme, arabicFont, setFontFamily, t } = useThemeAndLanguage();
const [activeModal, setActiveModal] = useState(null);
const [knownWords, setKnownWords] = useState(new Set());
const { vocabulary, isLoggedIn, userId } = useVocabulary();
const increaseFontSize = useCallback(() => setFontSize(prevSize => prevSize + 2), []);
const decreaseFontSize = useCallback(() => setFontSize(prevSize => prevSize - 2), []);
const closeAllModals = useCallback(() => {
bottomSheetModalRef.current?.dismiss();
settingsBottomSheetModalRef.current?.dismiss();
quizBottomSheetModalRef.current?.dismiss();
setActiveModal(null);
}, []);
const openSettingsModal = useCallback(() => {
settingsBottomSheetModalRef.current?.present();
setActiveModal('settings');
}, []);
const openQuizModal = useCallback(() => {
quizBottomSheetModalRef.current?.present();
setActiveModal('quiz');
}, []);
const handleWordPress = useCallback((word) => {
setSelectedWord(word);
setSelectedSentence(null);
bottomSheetModalRef.current?.present();
setActiveModal('word');
}, []);
const handleSentenceButtonPress = useCallback((sentence) => {
setSelectedSentence(sentence);
setSelectedWord(null);
bottomSheetModalRef.current?.present();
setActiveModal('sentence');
}, []);
const loadFonts = useCallback(async () => {
await Font.loadAsync(ARABIC_FONTS);
}, []);
const fetchStoryFromFirestore = useCallback(async (id) => {
const storyDocRef = doc(db, 'stories', id);
const storyDoc = await getDoc(storyDocRef);
return storyDoc.exists() ? { id: storyDoc.id, ...storyDoc.data() } : null;
}, []);
const fetchStory = useCallback(async () => {
try {
let storyData;
if (story) {
storyData = story;
} else if (storyId) {
const cachedData = await AsyncStorage.getItem(`story-${storyId}`);
if (cachedData) {
storyData = JSON.parse(cachedData);
} else {
storyData = await fetchStoryFromFirestore(storyId);
if (storyData) {
await AsyncStorage.setItem(`story-${storyId}`, JSON.stringify(storyData));
}
}
}
if (storyData) {
setCachedStory(storyData);
setHasQuiz(storyData.test_questions && storyData.test_questions.length > 0);
}
} catch (error) {
console.error('Error fetching story:', error);
} finally {
setLoading(false);
}
}, [story, storyId, fetchStoryFromFirestore]);
const fetchKnownWords = useCallback(async () => {
if (!isLoggedIn) {
setKnownWords(new Set());
return;
}
try {
const cachedWords = await AsyncStorage.getItem(STORAGE_KEY);
if (cachedWords) {
const wordsArray = JSON.parse(cachedWords);
setKnownWords(new Set(wordsArray.map(word => word.word)));
}
} catch (error) {
console.error('Error fetching known words:', error);
}
}, [isLoggedIn]);
useEffect(() => {
const initialize = async () => {
await loadFonts();
await fetchStory();
await fetchKnownWords();
};
initialize();
}, [loadFonts, fetchStory, fetchKnownWords]);
useEffect(() => {
if (cachedStory) {
const storyTitle = locale === 'tr' ? cachedStory.storytitleturkish : cachedStory.storytitleenglish;
const truncatedTitle = storyTitle.length > 23 ? `${storyTitle.substring(0, 23)}...` : storyTitle;
navigation.setOptions({
title: truncatedTitle,
headerStyle: { backgroundColor: theme.lighterCardBackgroundColor },
headerTintColor: theme.textColor,
headerTitleStyle: { color: theme.textColor, fontWeight: 'bold' },
headerRight: () => (
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<ToggleHeartButton storyId={cachedStory.id} initialHeartCount={cachedStory.hearts} />
<TouchableOpacity onPress={openSettingsModal} style={styles.fontSizeControl}>
<Ionicons name="settings-outline" size={24} color={theme.textColor} />
</TouchableOpacity>
</View>
),
});
}
}, [navigation, cachedStory, theme, locale, openSettingsModal]);
useFocusEffect(
useCallback(() => {
const onBackPress = () => {
if (activeModal) {
closeAllModals();
return true;
}
return false;
};
BackHandler.addEventListener('hardwareBackPress', onBackPress);
return () => BackHandler.removeEventListener('hardwareBackPress', onBackPress);
}, [activeModal, closeAllModals])
);
const renderSentence = useCallback(({ item: sentenceObj }) => (
<Sentence
sentenceObj={sentenceObj}
selectedSentence={selectedSentence}
handleSentenceButtonPress={handleSentenceButtonPress}
handleWordPress={handleWordPress}
fontSize={fontSize}
theme={theme}
arabicFont={arabicFont}
knownWords={knownWords}
/>
), [selectedSentence, handleSentenceButtonPress, handleWordPress, fontSize, theme, arabicFont, knownWords]);
const memoizedData = useMemo(() => cachedStory?.sentences || [], [cachedStory]);
const keyExtractor = useCallback((item) => item.id.toString(), []);
useEffect(() => {
const updatedKnownWords = new Set(vocabulary.map(word => word.word));
setKnownWords(updatedKnownWords);
}, [vocabulary]);
if (loading) {
return (
<View style={[styles.loadingContainer, { backgroundColor: theme.backgroundColorForWordBox }]}>
<ActivityIndicator size="large" color={theme.primaryColor} />
</View>
);
}
if (!cachedStory) {
return (
<View style={[styles.loadingContainer, { backgroundColor: theme.backgroundColorForWordBox }]}>
<Text style={{ color: theme.textColor }}>{t('storyNotFound')}</Text>
</View>
);
}
return (
<BottomSheetModalProvider>
<View style={[styles.container, { backgroundColor: theme.backgroundColorForWordBox }]}>
<FlatList
data={memoizedData}
renderItem={renderSentence}
keyExtractor={keyExtractor}
ListHeaderComponent={() => (
<>
<Image source={{ uri: cachedStory.thumbnail }} style={styles.thumbnail} />
<View style={styles.content}>
<View style={styles.header}>
<Text style={[styles.titleArabic, { color: theme.textColor, fontFamily: arabicFont }]}>
{cachedStory.storytitlearabic}
</Text>
<Text style={[styles.titleTurkish, { color: theme.secondaryColor }]}>
{locale === 'tr' ? cachedStory.storytitleturkish : cachedStory.storytitleenglish}
</Text>
</View>
</View>
</>
)}
initialNumToRender={10}
maxToRenderPerBatch={5}
windowSize={10}
/>
{hasQuiz && (
<TouchableOpacity
style={[styles.quizButton, { backgroundColor: theme.primaryColor }]}
onPress={openQuizModal}
>
<Text style={styles.quizButtonText}>{t('startQuiz')}</Text>
</TouchableOpacity>
)}
<BottomSheetModal
ref={bottomSheetModalRef}
index={0}
snapPoints={['45%', '90%']}
handleStyle={{ backgroundColor: theme.backgroundColorForWordBox }}
onDismiss={() => setActiveModal(null)}
>
<BottomSheetScrollView contentContainerStyle={styles.bottomSheetContent}>
<WordExplanationBox
word={selectedWord || selectedSentence}
storyId={cachedStory.id}
onClose={() => bottomSheetModalRef.current?.dismiss()}
/>
</BottomSheetScrollView>
</BottomSheetModal>
<BottomSheetModal
ref={settingsBottomSheetModalRef}
index={0}
snapPoints={['85%']}
handleStyle={{ backgroundColor: theme.backgroundColorForWordBox }}
onDismiss={() => setActiveModal(null)}
>
<BottomSheetScrollView
contentContainerStyle={[
styles.settingsContent,
{ backgroundColor: theme.backgroundColorForWordBox }
]}
>
<View style={styles.exampleCard}>
<Text style={[styles.exampleText, { fontSize: fontSize * 1.4, fontFamily: arabicFont }]}>
(هذا مثال على الكتابة بالعربية)
</Text>
</View>
<View style={styles.fontSizeControls}>
<TouchableOpacity onPress={increaseFontSize} style={styles.fontSizeButton}>
<Ionicons name="add-circle-outline" size={40} color={theme.primaryColor} />
<Text style={styles.fontSizeButtonText}>{t('increaseFontSize')}</Text>
</TouchableOpacity>
<TouchableOpacity onPress={decreaseFontSize} style={styles.fontSizeButton}>
<Ionicons name="remove-circle-outline" size={40} color={theme.primaryColor} />
<Text style={styles.fontSizeButtonText}>{t('decreaseFontSize')}</Text>
</TouchableOpacity>
</View>
<View style={styles.fontOptionsContainer}>
{Object.keys(ARABIC_FONTS).map((font) => (
<TouchableOpacity
key={font}
style={styles.fontOption}
onPress={() => setFontFamily(font)}
>
<Text style={styles.fontOptionText}>{font}</Text>
<Text style={[styles.fontOptionSample, { fontFamily: font }]}>
(اقرأ العربية)
</Text>
</TouchableOpacity>
))}
</View>
</BottomSheetScrollView>
</BottomSheetModal>
{hasQuiz && (
<BottomSheetModal
ref={quizBottomSheetModalRef}
index={0}
snapPoints={['90%']}
handleStyle={{ backgroundColor: theme.backgroundColorForWordBox }}
onDismiss={() => setActiveModal(null)}
>
<QuizScreen
story={cachedStory}
onClose={() => {
quizBottomSheetModalRef.current?.dismiss();
setActiveModal(null);
}}
/>
</BottomSheetModal>
)}
</View>
</BottomSheetModalProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
knownWord: {
backgroundColor: 'rgba(0, 255, 0, 0.1)',
borderRadius: 10,
},
loadingContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
thumbnail: {
width: '100%',
aspectRatio:1/1,
},
content: {
padding: 5,
},
header: {
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
},
titleArabic: {
fontSize: 26,
},
titleTurkish: {
fontSize: 20,
marginTop: 4,
textAlign: 'center',
},
fontSizeControl: {
marginHorizontal: 5,
},
sentenceContainer: {
flexDirection: 'row',
alignItems: 'flex-start',
marginBottom: 10,
paddingLeft: 10,
paddingRight: 10,
},
arabicTextWrapper: {
flex: 1,
flexDirection: 'row-reverse',
flexWrap: 'wrap',
paddingRight: 15,
},
descriptionArabic: {
padding: 1,
},
selectedSentence: {
backgroundColor: 'rgba(255, 215, 0, 0.3)',
},
headerContainer: {
marginVertical: 10,
backgroundColor: 'rgba(0, 0, 0, 0.03)',
borderRightWidth: 5,
width: '97%',
},
subHeaderContainer: {
marginVertical: 10,
backgroundColor: 'rgba(0, 0, 0, 0.03)',
borderRightWidth: 3,
width: '97%',
},
imageStyle: {
width: "90%",
alignSelf: "center",
marginBottom: 10,
aspectRatio: 1 / 1,
elevation:1,
borderRadius:15,
},
emojiButton: {
fontSize: 18,
marginHorizontal: 5,
},
bottomSheetContent: {
flexGrow: 1,
},
settingsContent: {
flexGrow: 1,
paddingHorizontal: 20,
paddingBottom: 20,
alignItems: 'center',
},
exampleCard: {
backgroundColor: 'white',
borderRadius: 10,
padding: 15,
marginVertical: 20,
width: '90%',
alignItems: 'center',
elevation: 4,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 3.84,
},
exampleText: {
textAlign: 'center',
},
fontSizeControls: {
flexDirection: 'row',
justifyContent: 'space-around',
width: '100%',
marginBottom: 20,
},
fontSizeButton: {
alignItems: 'center',
},
fontSizeButtonText: {
marginTop: 5,
fontSize: 12,
color: 'gray',
textAlign: 'center',
},
fontOptionsContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between',
width: '100%',
},
fontOption: {
width: '48%',
backgroundColor: 'white',
borderRadius: 10,
padding: 10,
marginBottom: 15,
alignItems: 'center',
elevation: 2,
shadowColor: '#000',
shadowOffset: { width: 0, height: 1 },
shadowOpacity: 0.22,
shadowRadius: 2.22,
},
fontOptionText: {
fontSize: 16,
marginBottom: 5,
},
fontOptionSample: {
fontSize: 18,
},
quizButton: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
padding: 10,
position: 'absolute',
bottom: 20,
right: 20,
borderRadius: 20,
},
quizButtonText: {
color: 'white',
fontWeight: 'bold',
},
});
Açıklamalar:
Sentence Bileşeninde Değişiklikler:
TouchableOpacity içerisindeki Ionicons bileşenini kaldırdık ve yerine bir emoji ekledik (🗨️).
TouchableOpacity bileşenini arabicTextWrapper içinde cümlenin sonuna yerleştirdik. Bu sayede emoji, cümlenin hemen arkasında, aynı satırda görünecektir.
flexDirection'u row-reverse olarak ayarlayarak RTL düzenini koruduk.
Style Güncellemeleri:
emojiButton stili ekledik ve emoji boyutunu ayarladık.
sentenceContainer stilini flexDirection: 'row' yerine flexDirection: 'row-reverse' olarak değiştirdik ve hizalamaları düzelttik.
arabicTextWrapper içinde flexDirection'u row-reverse olarak ayarlayarak Türkçe ve İngilizce metinlerin doğru hizalanmasını sağladık.
Diğer Düzenlemeler:
quizButton stiline position: 'absolute' ekleyerek butonun ekranın sağ alt köşesinde sabitlenmesini sağladık. Bu isteğe bağlıdır ve projeye göre düzenlenebilir.
RTL düzenini korumak için metin hizalamasını ve esnek yönlendirmeleri dikkatlice ayarladık.
Bu değişikliklerle, her cümlenin sonuna tıklanabilir bir emoji eklendi ve metin paragrafı gibi akıcı bir şekilde görüntülendi. Umarım ihtiyacınızı karşılar. Başka herhangi bir değişiklik veya ekleme ihtiyacınız olursa lütfen belirtin.
Copy first response