jsx Copy code
// app.jsx
import React, { useState, useEffect } from 'react';
import {
View,
Text,
StyleSheet,
ScrollView,
TouchableOpacity,
Image,
TextInput,
Modal,
Button,
Platform,
} from 'react-native';
import { useColorScheme } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import Constants from 'expo-constants';
// Dummy data for testing
const doctorInfo = {
name: 'د. أحمد يوسف',
specialty: 'طبيب أسنان',
address: 'بغداد، شارع 14 رمضان',
workingHours: '9 صباحًا - 5 مساءً',
};
const specialties = [
{
id: 1,
title: 'قلع سن',
price: '15000 د.ع',
image: 'https://via.placeholder.com/150',
},
{
id: 2,
title: 'حشوة سن',
price: '10000 د.ع',
image: 'https://via.placeholder.com/150',
},
// Add more specialties as needed
];
const activeBookings = [
{
id: 1,
date: '2023-10-18',
type: 'حشوة سن',
},
// Add more active bookings
];
const previousBookings = [
{
id: 1,
date: '2023-09-15',
type: 'قلع سن',
},
// Add more than 10 previous bookings
{
id: 2,
date: '2023-09-10',
type: 'تنظيف أسنان',
},
{
id: 3,
date: '2023-08-25',
type: 'علاج عصب',
},
{
id: 4,
date: '2023-08-15',
type: 'تبيض أسنان',
},
{
id: 5,
date: '2023-08-05',
type: 'تركيب تقويم',
},
{
id: 6,
date: '2023-07-25',
type: 'حشوة تجميلية',
},
{
id: 7,
date: '2023-07-15',
type: 'خلع ضرس العقل',
},
{
id: 8,
date: '2023-07-05',
type: 'تركيب جسر',
},
{
id: 9,
date: '2023-06-25',
type: 'تلبيس سن',
},
{
id: 10,
date: '2023-06-15',
type: 'زراعة سن',
},
{
id: 11,
date: '2023-06-05',
type: 'تقويم شفاف',
},
];
export default function App() {
const colorScheme = useColorScheme();
const [selectedTab, setSelectedTab] = useState('home');
const [showBookingModal, setShowBookingModal] = useState(false);
const [bookingType, setBookingType] = useState('');
const [formData, setFormData] = useState({
name: '',
phone: '',
date: '',
type: '',
});
const styles = createStyles(colorScheme === 'dark');
const handleBooking = (type) => {
setBookingType(type);
setFormData({ ...formData, type });
setShowBookingModal(true);
};
const submitBooking = () => {
// Here you can integrate with your API
// For now, we'll just close the modal
setShowBookingModal(false);
};
return (
<View style={styles.container}>
{selectedTab === 'home' && (
<ScrollView contentContainerStyle={styles.contentContainer}>
{/* Header with Doctor Info */}
<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>
<TouchableOpacity
style={styles.headerButton}
onPress={() => handleBooking('')}
>
<Ionicons name="calendar-outline" size={20} color="#fff" />
<Text style={styles.headerButtonText}>حجز</Text>
</TouchableOpacity>
</View>
{/* Active Bookings */}
<View style={styles.section}>
<Text style={styles.sectionTitle}>
<Ionicons name="time-outline" size={18} /> الحجوزات النشطة
</Text>
{activeBookings.map((booking) => (
<View key={booking.id} style={styles.bookingCard}>
<Text style={styles.bookingText}>
{booking.type} - {booking.date}
</Text>
</View>
))}
</View>
{/* Doctor Specialties */}
<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}
/>
<View style={styles.specialtyInfo}>
<Text style={styles.specialtyTitle}>{specialty.title}</Text>
<View style={styles.specialtyFooter}>
<Text style={styles.specialtyPrice}>{specialty.price}</Text>
<TouchableOpacity
style={styles.specialtyButton}
onPress={() => handleBooking(specialty.title)}
>
<Ionicons
name="calendar-outline"
size={16}
color="#fff"
/>
<Text style={styles.specialtyButtonText}>حجز</Text>
</TouchableOpacity>
</View>
</View>
</View>
))}
</View>
</ScrollView>
)}
{selectedTab === 'bookings' && (
<ScrollView contentContainerStyle={styles.contentContainer}>
{/* Active Bookings */}
<View style={styles.section}>
<Text style={styles.sectionTitle}>
<Ionicons name="time-outline" size={18} /> المراجعات النشطة
</Text>
{activeBookings.map((booking) => (
<View key={booking.id} style={styles.bookingCard}>
<Text style={styles.bookingText}>
{booking.type} - {booking.date}
</Text>
</View>
))}
</View>
{/* Previous Bookings */}
<View style={styles.section}>
<Text style={styles.sectionTitle}>
<Ionicons name="stopwatch-outline" size={18} /> المراجعات السابقة
</Text>
{previousBookings.map((booking) => (
<View key={booking.id} style={styles.bookingCard}>
<Text style={styles.bookingText}>
{booking.type} - {booking.date}
</Text>
</View>
))}
</View>
</ScrollView>
)}
{/* Booking Modal */}
<Modal
visible={showBookingModal}
animationType="slide"
transparent={true}
onRequestClose={() => setShowBookingModal(false)}
>
<View style={styles.modalContainer}>
<View style={styles.modalContent}>
<Text style={styles.modalTitle}>حجز موعد</Text>
<TextInput
style={styles.input}
placeholder="الاسم"
placeholderTextColor="#888"
value={formData.name}
onChangeText={(text) => setFormData({ ...formData, name: text })}
/>
<TextInput
style={styles.input}
placeholder="رقم الهاتف"
placeholderTextColor="#888"
keyboardType="phone-pad"
value={formData.phone}
onChangeText={(text) => setFormData({ ...formData, phone: text })}
/>
<TextInput
style={styles.input}
placeholder="تاريخ الحجز (YYYY-MM-DD)"
placeholderTextColor="#888"
value={formData.date}
onChangeText={(text) => setFormData({ ...formData, date: text })}
/>
<TextInput
style={styles.input}
placeholder="نوع الحجز"
placeholderTextColor="#888"
value={formData.type}
onChangeText={(text) => setFormData({ ...formData, type: text })}
/>
<View style={styles.modalButtons}>
<Button title="إلغاء" onPress={() => setShowBookingModal(false)} />
<Button title="تأكيد" onPress={submitBooking} />
</View>
</View>
</View>
</Modal>
{/* Bottom Navigation */}
<View style={styles.bottomNav}>
<TouchableOpacity
style={styles.navItem}
onPress={() => setSelectedTab('home')}
>
<Ionicons
name="home-outline"
size={24}
color={selectedTab === 'home' ? '#007AFF' : '#888'}
/>
<Text
style={[
styles.navText,
{ color: selectedTab === 'home' ? '#007AFF' : '#888' },
]}
>
الرئيسية
</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.navItem}
onPress={() => setSelectedTab('bookings')}
>
<Ionicons
name="albums-outline"
size={24}
color={selectedTab === 'bookings' ? '#007AFF' : '#888'}
/>
<Text
style={[
styles.navText,
{ color: selectedTab === 'bookings' ? '#007AFF' : '#888' },
]}
>
حجز
</Text>
</TouchableOpacity>
</View>
</View>
);
}
const createStyles = (isDarkMode) =>
StyleSheet.create({
container: {
flex: 1,
backgroundColor: isDarkMode ? '#000' : '#fff',
paddingTop: Constants.statusBarHeight,
},
contentContainer: {
paddingBottom: 80,
},
header: {
backgroundColor: isDarkMode ? '#1c1c1e' : '#f2f2f7',
padding: 20,
alignItems: 'flex-start',
},
doctorName: {
fontSize: 24,
fontWeight: 'bold',
color: isDarkMode ? '#fff' : '#000',
},
doctorDetails: {
fontSize: 16,
color: isDarkMode ? '#ccc' : '#333',
marginTop: 4,
},
headerButton: {
marginTop: 10,
flexDirection: 'row',
alignItems: 'center',
backgroundColor: '#007AFF',
paddingVertical: 8,
paddingHorizontal: 12,
borderRadius: 8,
},
headerButtonText: {
color: '#fff',
marginLeft: 5,
},
section: {
marginTop: 20,
paddingHorizontal: 20,
},
sectionTitle: {
fontSize: 20,
fontWeight: 'bold',
color: isDarkMode ? '#fff' : '#000',
marginBottom: 10,
},
bookingCard: {
backgroundColor: isDarkMode ? '#1c1c1e' : '#f2f2f7',
padding: 15,
borderRadius: 8,
marginBottom: 10,
},
bookingText: {
color: isDarkMode ? '#fff' : '#000',
},
specialtyCard: {
flexDirection: 'row',
backgroundColor: isDarkMode ? '#1c1c1e' : '#f2f2f7',
padding: 10,
borderRadius: 8,
marginBottom: 10,
},
specialtyImage: {
width: 100,
height: 100,
borderRadius: 8,
},
specialtyInfo: {
flex: 1,
marginLeft: 10,
justifyContent: 'space-between',
},
specialtyTitle: {
fontSize: 18,
fontWeight: 'bold',
color: isDarkMode ? '#fff' : '#000',
},
specialtyFooter: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
specialtyPrice: {
fontSize: 16,
color: isDarkMode ? '#fff' : '#000',
},
specialtyButton: {
flexDirection: 'row',
alignItems: 'center',
backgroundColor: '#007AFF',
paddingVertical: 6,
paddingHorizontal: 10,
borderRadius: 8,
},
specialtyButtonText: {
color: '#fff',
marginLeft: 5,
},
modalContainer: {
flex: 1,
backgroundColor: 'rgba(0,0,0,0.5)',
justifyContent: 'center',
paddingHorizontal: 20,
},
modalContent: {
backgroundColor: isDarkMode ? '#1c1c1e' : '#fff',
borderRadius: 8,
padding: 20,
},
modalTitle: {
fontSize: 20,
fontWeight: 'bold',
color: isDarkMode ? '#fff' : '#000',
marginBottom: 20,
textAlign: 'center',
},
input: {
borderWidth: 1,
borderColor: '#ccc',
padding: 10,
borderRadius: 8,
marginBottom: 10,
color: isDarkMode ? '#fff' : '#000',
},
modalButtons: {
flexDirection: 'row',
justifyContent: 'space-between',
marginTop: 20,
},
bottomNav: {
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
height: 60,
flexDirection: 'row',
backgroundColor: isDarkMode ? '#1c1c1e' : '#f2f2f7',
borderTopWidth: 1,
borderTopColor: '#ccc',
},
navItem: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
navText: {
fontSize: 12,
marginTop: 2,
},
});