Hier ist der konvertierte React Native Code inklusive StyleSheet:
import React, { useState } from 'react';
import { View, Text, TouchableOpacity, StyleSheet, ScrollView } from 'react-native';
const BookingOverview = ({ nextSlide }) => {
const [bookingData, setBookingData] = useState({
date: 'Montag, 24. Juni, 2024',
time: '09:00 - 14 Uhr',
duration: '5 Stunden',
participants: '1-5 Personen',
pricePerHour: 80,
hours: 2,
serviceCharge: 16,
});
const totalPrice = bookingData.pricePerHour * bookingData.hours + bookingData.serviceCharge;
return (
<View style={styles.container}>
<ScrollView contentContainerStyle={{ paddingBottom: 150 }}>
<View style={styles.dateTime}>
<Text style={styles.titleSemibold3}>Datum & Uhrzeit</Text>
<View style={styles.dateTimeDetails}>
<View style={styles.dateTimeDetailsLeft}>
<Text style={styles.regularLarge}>{bookingData.date}</Text>
<Text style={styles.regularLarge}>{bookingData.time}</Text>
</View>
<TouchableOpacity style={styles.editButton}>
<Text style={styles.edit}>Bearbeiten</Text>
</TouchableOpacity>
</View>
<View style={styles.durationContainer}>
<TouchableOpacity style={styles.addDayButton}>
<Text style={styles.addDay}>Ein Tag mehr hinzufügen</Text>
</TouchableOpacity>
<Text style={styles.regularXxs}>Dauer: {bookingData.duration}</Text>
</View>
</View>
<View style={styles.horizontalLine} />
<View style={styles.participants}>
<Text style={styles.titleSemibold3}>Teilnehmer</Text>
<View style={styles.participantsDetails}>
<Text style={styles.regularLarge}>{bookingData.participants}</Text>
<TouchableOpacity style={styles.editButton}>
<Text style={styles.edit}>Bearbeiten</Text>
</TouchableOpacity>
</View>
</View>
<View style={styles.horizontalLine} />
<View style={styles.price}>
<Text style={styles.titleSemibold3}>Preis</Text>
<View style={styles.priceDetails}>
<Text style={styles.priceText}>
{bookingData.pricePerHour} € x {bookingData.hours} Stunden
</Text>
<Text style={styles.priceText}>
{bookingData.pricePerHour * bookingData.hours} €
</Text>
</View>
<View style={styles.priceDetails}>
<Text style={styles.priceText}>Servicegebühr</Text>
<Text style={styles.priceText}>{bookingData.serviceCharge} €</Text>
</View>
</View>
<View style={styles.horizontalLine} />
<View style={styles.total}>
<Text style={styles.titleSemibold3}>Gesamtbetrag</Text>
<Text style={styles.titleSemibold3}>{totalPrice} €</Text>
</View>
<View style={styles.horizontalLine} />
<View style={styles.nextStepContainer}>
<Text style={styles.nextStep}>
Als Nächstes: Auf der nächsten Seite kannst du einen Fotografen für dein Projekt engagieren
und zusätzliches Equipment buchen.
</Text>
</View>
</ScrollView>
<View style={styles.bookingTotal}>
<TouchableOpacity style={styles.weiterButton} onPress={nextSlide}>
<Text style={styles.weiterButtonText}>Weiter</Text>
</TouchableOpacity>
</View>
</View>
);
};
export default BookingOverview;
const colors = {
darkGrey3: '#4F4F4F',
lightGrey1: '#F2F2F2',
lightGrey2: '#E0E0E0',
darkGrey: '#1F1F1F',
lightBlack: '#333333',
stuRot: '#E71D36',
primaryFont: 'System',
};
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 24,
paddingHorizontal: 24,
backgroundColor: '#FFFFFF',
},
dateTime: {
width: '100%',
marginBottom: 26,
},
titleSemibold3: {
fontFamily: colors.primaryFont,
fontSize: 20,
fontWeight: '600',
color: colors.darkGrey,
},
dateTimeDetails: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginTop: 18,
marginBottom: 33,
},
dateTimeDetailsLeft: {
flex: 1,
},
regularLarge: {
fontFamily: colors.primaryFont,
fontSize: 16,
color: colors.darkGrey3,
marginBottom: 5,
},
editButton: {
backgroundColor: 'transparent',
},
edit: {
color: colors.darkGrey,
fontFamily: colors.primaryFont,
fontSize: 14,
textDecorationLine: 'underline',
},
durationContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginBottom: 27,
},
addDayButton: {
backgroundColor: 'transparent',
},
addDay: {
color: colors.stuRot,
fontFamily: colors.primaryFont,
fontSize: 14,
textDecorationLine: 'underline',
},
regularXxs: {
fontFamily: colors.primaryFont,
fontSize: 12,
color: colors.darkGrey3,
},
horizontalLine: {
width: '100%',
height: 1,
backgroundColor: colors.lightGrey1,
},
participants: {
width: '100%',
marginTop: 26,
marginBottom: 16,
},
participantsDetails: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginTop: 16,
},
price: {
width: '100%',
marginTop: 26,
marginBottom: 29,
},
priceDetails: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginTop: 16,
},
priceText: {
fontFamily: colors.primaryFont,
fontSize: 16,
color: colors.darkGrey3,
},
total: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginVertical: 23,
},
nextStepContainer: {
width: '100%',
},
nextStep: {
marginVertical: 23,
color: colors.darkGrey3,
fontFamily: colors.primaryFont,
fontSize: 12,
},
bookingTotal: {
position: 'absolute',
bottom: 0,
left: 0,
width: '100%',
padding: 24,
backgroundColor: '#FFFFFF',
borderTopWidth: 1,
borderTopColor: colors.lightGrey2,
},
weiterButton: {
width: '100%',
borderRadius: 12,
backgroundColor: colors.lightBlack,
paddingVertical: 17,
alignItems: 'center',
justifyContent: 'center',
},
weiterButtonText: {
color: '#FAFAFA',
fontFamily: colors.primaryFont,
fontSize: 16,
},
});
Anmerkungen zur Konvertierung:
- HTML-Tags zu React Native Komponenten:
<div> wurde zu <View>, <p> und <h2> zu <Text>.
- Klassenname zu StyleSheet: Die CSS-Klassen wurden in ein React Native
StyleSheet überführt und angepasst.
- CSS-Eigenschaften: Einige CSS-Eigenschaften wie
margin-bottom, padding etc. wurden in das entsprechende React Native Format konvertiert (z.B. marginBottom, paddingHorizontal).
- Farben und Schriftarten: Die CSS-Variablen wie
var(--dark-grey-3) wurden in einem colors-Objekt definiert und im StyleSheet verwendet.
- Interaktive Elemente:
<button> wurde zu <TouchableOpacity>, um Touch-Events in React Native zu ermöglichen.
- Positionierung: Das Footer-Element
bookingTotal wurde mit position: 'absolute' am unteren Bildschirmrand fixiert.
- ScrollView: Um sicherzustellen, dass der Inhalt scrollbar ist und nicht vom Footer verdeckt wird, wurde der Inhalt in einen
<ScrollView> eingebettet.
Hinweis:
- Einige CSS-spezifische Eigenschaften wie
font-feature-settings, die in React Native nicht unterstützt werden, wurden ignoriert oder angepasst.
- Stellen Sie sicher, dass Sie alle notwendigen Importe (z.B.
ScrollView, TouchableOpacity) aus react-native einbeziehen.
- Die Schriftfamilie
var(--primary-font) wurde als System gesetzt. Sie können diese entsprechend anpassen, wenn Sie eine benutzerdefinierte Schriftart verwenden.
Beispiel für die Nutzung der Component:
import React from 'react';
import { SafeAreaView } from 'react-native';
import BookingOverview from './BookingOverview';
const App = () => {
const handleNextSlide = () => {
// Logik für den nächsten Schritt
};
return (
<SafeAreaView style={{ flex: 1 }}>
<BookingOverview nextSlide={handleNextSlide} />
</SafeAreaView>
);
};
export default App;
Dieser Code sollte Ihnen ein genaues React Native Äquivalent Ihres ursprünglichen React-Codes liefern.