jsx Copy code
// app.jsx
import React, { useState, useEffect } from 'react';
import {
View,
Text,
StyleSheet,
ScrollView,
Image,
TouchableOpacity,
useColorScheme,
TextInput,
FlatList,
} from 'react-native';
import { Provider as PaperProvider, DefaultTheme, DarkTheme, Button } from 'react-native-paper';
import { Ionicons } from '@expo/vector-icons';
import { useNavigation, NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
const doctorInfo = {
name: 'د. أحمد العلي',
specialty: 'طبيب أسنان',
address: 'بغداد، شارع السعدون',
workingHours: '9 صباحاً - 5 مساءً',
};
const specialties = [
{
id: 1,
title: 'قلع سن',
price: '50000 د.ع',
image: 'https://via.placeholder.com/150',
},
{
id: 2,
title: 'حشوة سن',
price: '75000 د.ع',
image: 'https://via.placeholder.com/150',
},
// أضف المزيد من التخصصات هنا...
];
const activeBookings = [
{
id: 1,
date: '2023-10-01',
type: 'حشوة سن',
},
// أضف المزيد من الحجوزات النشطة هنا...
];
const previousBookings = Array.from({ length: 10 }, (_, i) => ({
id: i + 1,
date: `2023-09-${i + 1}`,
type: 'قلع سن',
}));
function HomeScreen() {
const navigation = useNavigation();
return (
<ScrollView contentContainerStyle={styles.container}>
<View style={styles.header}>
<Text style={styles.doctorName}>{doctorInfo.name}</Text>
<Text style={styles.doctorDetails}>{doctorInfo.specialty}</Text>
<Text style={styles.doctorDetails}>{doctorInfo.address}</Text>
<Text style={styles.doctorDetails}>ساعات العمل: {doctorInfo.workingHours}</Text>
<Button
icon="calendar-plus"
mode="contained"
onPress={() => navigation.navigate('Booking')}
style={styles.headerButton}
>
حجز موعد
</Button>
</View>
<View style={styles.section}>
<Text style={styles.sectionTitle}>حجوزاتي النشطة</Text>
{activeBookings.map((booking) => (
<View key={booking.id} style={styles.bookingCard}>
<Ionicons name="time" size={24} color={styles.iconColor.color} />
<View style={styles.bookingInfo}>
<Text style={styles.bookingText}>تاريخ: {booking.date}</Text>
<Text style={styles.bookingText}>نوع الحجز: {booking.type}</Text>
</View>
</View>
))}
</View>
<View style={styles.section}>
<Text style={styles.sectionTitle}>تخصصات الطبيب</Text>
{specialties.map((specialty) => (
<View key={specialty.id} style={styles.specialtyCard}>
<Image source={{ uri: specialty.image }} style={styles.specialtyImage} />
<Text style={styles.specialtyTitle}>{specialty.title}</Text>
<View style={styles.specialtyFooter}>
<Text style={styles.specialtyPrice}>{specialty.price}</Text>
<Button
icon="calendar-plus"
mode="contained"
onPress={() => navigation.navigate('Booking', { type: specialty.title })}
>
حجز
</Button>
</View>
</View>
))}
</View>
</ScrollView>
);
}
function BookingScreen({ route }) {
const [name, setName] = useState('');
const [phone, setPhone] = useState('');
const [bookingDate, setBookingDate] = useState('');
const [bookingType, setBookingType] = useState(route.params?.type || '');
const [bookingTypes, setBookingTypes] = useState([]);
useEffect(() => {
// هنا يمكنك جلب بيانات الأنواع من API إذا توفر
setBookingTypes(specialties.map((spec) => spec.title));
}, []);
const handleSubmit = () => {
// من هنا يمكنك إرسال البيانات إلى API
alert('تم إرسال طلب الحجز بنجاح');
};
return (
<ScrollView contentContainerStyle={styles.container}>
<View style={styles.formGroup}>
<Text style={styles.label}>الاسم:</Text>
<TextInput style={styles.input} value={name} onChangeText={setName} placeholder="أدخل اسمك" />
</View>
<View style={styles.formGroup}>
<Text style={styles.label}>رقم الهاتف:</Text>
<TextInput style={styles.input} value={phone} onChangeText={setPhone} placeholder="أدخل رقم الهاتف" keyboardType="phone-pad" />
</View>
<View style={styles.formGroup}>
<Text style={styles.label}>تاريخ الحجز المطلوب:</Text>
<TextInput style={styles.input} value={bookingDate} onChangeText={setBookingDate} placeholder="YYYY-MM-DD" />
</View>
<View style={styles.formGroup}>
<Text style={styles.label}>نوع الحجز:</Text>
<TextInput
style={styles.input}
value={bookingType}
onChangeText={setBookingType}
placeholder="اختر نوع الحجز"
/>
</View>
<Button mode="contained" onPress={handleSubmit}>
إرسال
</Button>
</ScrollView>
);
}
function ReviewsScreen() {
return (
<ScrollView contentContainerStyle={styles.container}>
<View style={styles.section}>
<View style={styles.sectionHeader}>
<Text style={styles.sectionTitle}>المراجعات النشطة</Text>
<Ionicons name="time" size={24} color={styles.iconColor.color} />
</View>
{/* هنا يمكنك عرض المراجعات النشطة */}
{activeBookings.map((review) => (
<View key={review.id} style={styles.reviewCard}>
<Text style={styles.reviewText}>تاريخ: {review.date}</Text>
<Text style={styles.reviewText}>نوع المراجعة: {review.type}</Text>
</View>
))}
</View>
<View style={styles.section}>
<View style={styles.sectionHeader}>
<Text style={styles.sectionTitle}>المراجعات السابقة</Text>
<Ionicons name="arrow-redo-circle-outline" size={24} color={styles.iconColor.color} />
</View>
{/* عرض المراجعات السابقة */}
{previousBookings.map((review) => (
<View key={review.id} style={styles.reviewCard}>
<Text style={styles.reviewText}>تاريخ: {review.date}</Text>
<Text style={styles.reviewText}>نوع المراجعة: {review.type}</Text>
</View>
))}
</View>
</ScrollView>
);
}
const Tab = createBottomTabNavigator();
export default function App() {
const scheme = useColorScheme();
const theme = scheme === 'dark' ? DarkTheme : DefaultTheme;
return (
<PaperProvider theme={theme}>
<NavigationContainer theme={theme}>
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ color, size }) => {
let iconName;
if (route.name === 'Home') {
iconName = 'home';
} else if (route.name === 'Booking') {
iconName = 'calendar';
} else if (route.name === 'Reviews') {
iconName = 'list';
}
return <Ionicons name={iconName} size={size} color={color} />;
},
})}
>
<Tab.Screen name="Home" component={HomeScreen} options={{ title: 'الرئيسية' }} />
<Tab.Screen name="Booking" component={BookingScreen} options={{ title: 'حجز' }} />
<Tab.Screen name="Reviews" component={ReviewsScreen} options={{ title: 'المراجعات' }} />
</Tab.Navigator>
</NavigationContainer>
</PaperProvider>
);
}
const styles = StyleSheet.create({
container: {
padding: 16,
},
header: {
alignItems: 'center',
marginBottom: 24,
},
doctorName: {
fontSize: 24,
fontWeight: 'bold',
},
doctorDetails: {
fontSize: 16,
marginTop: 4,
},
headerButton: {
marginTop: 16,
},
section: {
marginBottom: 24,
},
sectionTitle: {
fontSize: 20,
fontWeight: 'bold',
},
bookingCard: {
flexDirection: 'row',
alignItems: 'center',
marginVertical: 8,
},
bookingInfo: {
marginLeft: 8,
},
bookingText: {
fontSize: 16,
},
specialtyCard: {
marginVertical: 16,
},
specialtyImage: {
width: '100%',
height: 150,
},
specialtyTitle: {
fontSize: 18,
fontWeight: 'bold',
marginVertical: 8,
},
specialtyFooter: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
specialtyPrice: {
fontSize: 16,
fontWeight: 'bold',
},
formGroup: {
marginVertical: 12,
},
label: {
fontSize: 16,
marginBottom: 4,
},
input: {
borderWidth: 1,
borderColor: '#ccc',
borderRadius: 5,
padding: 8,
},
reviewCard: {
backgroundColor: '#f5f5f5',
padding: 12,
borderRadius: 5,
marginVertical: 8,
},
reviewText: {
fontSize: 16,
},
sectionHeader: {
flexDirection: 'row',
alignItems: 'center',
},
iconColor: {
color: '#000',
},
});
أتمنى أن يكون هذا التطبيق مفيداً ويلبي احتياجاتك. إذا كان لديك أي استفسارات أو تعديلات ترغب في إجرائها، فلا تتردد في السؤال.