Refactor ServicesScreen to use a dynamic services array and improve layout

- Introduced a services array to dynamically render service cards with localized titles and icons.
- Updated layout styles for a grid display of service cards, enhancing visual organization.
- Added new localization keys for services in English, Russian, and Turkmen.
This commit is contained in:
2025-08-20 18:43:05 +05:00
parent b5d3133c24
commit f796f832a8
5 changed files with 52 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
import { StyleSheet, SafeAreaView, View, TouchableOpacity } from 'react-native'; import { StyleSheet, SafeAreaView, View, TouchableOpacity, Dimensions } from 'react-native';
import { Text } from '@/components/Themed'; import { Text } from '@/components/Themed';
import i18n from '@/i18n'; import i18n from '@/i18n';
import { FontAwesome5 } from '@expo/vector-icons'; import { FontAwesome5 } from '@expo/vector-icons';
@@ -9,18 +9,36 @@ import CurrencyConverterModal from '@/components/CurrencyConverterModal';
export default function ServicesScreen() { export default function ServicesScreen() {
const [modalVisible, setModalVisible] = useState(false); const [modalVisible, setModalVisible] = useState(false);
const services = [
{
title: 'currencyConverter',
icon: <FontAwesome5 name="dollar-sign" size={24} color="#D4AF37" />,
onPress: () => setModalVisible(true),
},
{
title: 'hotelCard',
icon: <FontAwesome5 name="hotel" size={24} color="#D4AF37" />,
},
{
title: 'lostKey',
icon: <FontAwesome5 name="key" size={24} color="#D4AF37" />,
},
{
title: 'translator',
icon: <FontAwesome5 name="language" size={24} color="#D4AF37" />,
},
];
return ( return (
<SafeAreaView style={styles.container}> <SafeAreaView style={styles.container}>
<Text style={styles.title}>{i18n.t('services')}</Text> <Text style={styles.title}>{i18n.t('services')}</Text>
<View style={styles.row}> <View style={styles.grid}>
<TouchableOpacity onPress={() => setModalVisible(true)}> {services.map((service, index) => (
<ServiceCard title="Real Manat hasaplama" icon={<FontAwesome5 name="dollar-sign" size={24} color="#D4AF37" />} /> <TouchableOpacity key={index} style={styles.cardContainer} onPress={service.onPress}>
</TouchableOpacity> <ServiceCard title={i18n.t(service.title)} icon={service.icon} />
</TouchableOpacity>
<ServiceCard title="Oteliň wizitkasy" icon={<FontAwesome5 name="hotel" size={24} color="#D4AF37" />} /> ))}
<ServiceCard title="Oteliň açary içinde galsa" icon={<FontAwesome5 name="key" size={24} color="#D4AF37" />} />
<ServiceCard title="Terjimeçi" icon={<FontAwesome5 name="language" size={24} color="#D4AF37" />} />
</View> </View>
<CurrencyConverterModal <CurrencyConverterModal
visible={modalVisible} visible={modalVisible}
@@ -33,7 +51,6 @@ export default function ServicesScreen() {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
paddingHorizontal: 15,
}, },
title: { title: {
fontSize: 22, fontSize: 22,
@@ -41,11 +58,13 @@ const styles = StyleSheet.create({
marginVertical: 15, marginVertical: 15,
marginLeft: 15, marginLeft: 15,
}, },
row: { grid: {
flex: 1,
justifyContent: 'space-around',
flexDirection: 'row', flexDirection: 'row',
flexWrap: 'wrap', flexWrap: 'wrap',
rowGap: 0, marginLeft: 15,
},
cardContainer: {
width: '50%',
marginBottom: 15,
}, },
}); });

View File

@@ -25,14 +25,14 @@ const styles = StyleSheet.create({
borderRadius: 15, borderRadius: 15,
padding: 15, padding: 15,
marginVertical: 10, marginVertical: 10,
width: '45%',
aspectRatio: 1,
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
aspectRatio: 1,
}, },
content: { content: {
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
flex: 1,
}, },
iconContainer: { iconContainer: {
marginBottom: 10, marginBottom: 10,

View File

@@ -14,7 +14,11 @@
"servicesToEnrich": "Services to Enrich Your Spiritual Experience", "servicesToEnrich": "Services to Enrich Your Spiritual Experience",
"quran": "Qur'an", "quran": "Qur'an",
"hadith": "Hadith", "hadith": "Hadith",
"dua": "Du'a", "dua": "Dua",
"currencyConverter": "Currency Converter",
"hotelCard": "Hotel Card",
"lostKey": "Lost Key?",
"translator": "Translator",
"adhkar": "Adhkar", "adhkar": "Adhkar",
"hisnAlMuslim": "Hisn Al-Muslim", "hisnAlMuslim": "Hisn Al-Muslim",
"morningEveningThikr": "Thikr said in the morning and evening", "morningEveningThikr": "Thikr said in the morning and evening",
@@ -27,6 +31,5 @@
"sneezingSupplication": "Supplication upon sneezing", "sneezingSupplication": "Supplication upon sneezing",
"sarToTmt": "SAR to TMT", "sarToTmt": "SAR to TMT",
"hotelBusinessCard": "Hotel Business Card", "hotelBusinessCard": "Hotel Business Card",
"masterkeyBox": "Masterkey Box", "masterkeyBox": "Masterkey Box"
"translator": "Translator"
} }

View File

@@ -12,8 +12,12 @@
"leftOnPrayer": "Осталось до молитвы {{prayerName}}", "leftOnPrayer": "Осталось до молитвы {{prayerName}}",
"servicesToEnrich": "Услуги для обогащения вашего духовного опыта", "servicesToEnrich": "Услуги для обогащения вашего духовного опыта",
"quran": "Коран", "quran": "Коран",
"hadith": "Хадисы", "hadith": "Хадис",
"dua": "Дуа", "dua": "Дуа",
"currencyConverter": "Конвертер валют",
"hotelCard": "Карта отеля",
"lostKey": "Потеряли ключ?",
"translator": "Переводчик",
"adhkar": "Азкар", "adhkar": "Азкар",
"hisnAlMuslim": "Крепость мусульманина", "hisnAlMuslim": "Крепость мусульманина",
"morningEveningThikr": "Зикр, читаемый утром и вечером", "morningEveningThikr": "Зикр, читаемый утром и вечером",
@@ -26,6 +30,5 @@
"sneezingSupplication": "Мольба при чихании", "sneezingSupplication": "Мольба при чихании",
"sarToTmt": "SAR в TMT", "sarToTmt": "SAR в TMT",
"hotelBusinessCard": "Визитная карточка отеля", "hotelBusinessCard": "Визитная карточка отеля",
"masterkeyBox": "Ящик для мастер-ключей", "masterkeyBox": "Ящик для мастер-ключей"
"translator": "Переводчик"
} }

View File

@@ -15,6 +15,10 @@
"quran": "Kuran", "quran": "Kuran",
"hadith": "Hadys", "hadith": "Hadys",
"dua": "Doga", "dua": "Doga",
"currencyConverter": "Walýuta hasaplaýjy",
"hotelCard": "Myhmanhana kartasy",
"lostKey": "Açaryňyzy ýitirdiňizmi?",
"translator": "Terjimeçi",
"adhkar": "Zikir", "adhkar": "Zikir",
"hisnAlMuslim": "Musulmanyň goragy", "hisnAlMuslim": "Musulmanyň goragy",
"Makkah": "Mekke", "Makkah": "Mekke",
@@ -34,9 +38,5 @@
"insultedWhileFasting": "Orazaly wagtyň kemsidilende", "insultedWhileFasting": "Orazaly wagtyň kemsidilende",
"seeingFruitSupplication": "Irki ýa-da bişmedik miwäni göreniňde aýdylýan doga", "seeingFruitSupplication": "Irki ýa-da bişmedik miwäni göreniňde aýdylýan doga",
"sneezingSupplication": "Asgyranyňda aýdylýan doga", "sneezingSupplication": "Asgyranyňda aýdylýan doga",
"sarToTmt": "SAR-dan TMT-a", "sarToTmt": "SAR-dan TMT-a"
"hotelBusinessCard": "Myhmanhananyň wizit karty",
"masterkeyBox": "Masterkey gutusy",
"translator": "Terjimeçi",
"currencyConverter": "Walýuta hasaplama"
} }