You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

381 lines
11 KiB

2 months ago
import React, { useState, useEffect } from 'react';
import { View, Text, Image, TouchableOpacity, StyleSheet, ImageBackground, ActivityIndicator } from 'react-native';
import BackIcon from '../../components/BackIcon';
import fontSize from '../../utils/fontsizeUtils';
import widthUtils from '../../utils/widthUtils';
2 months ago
import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
type RootStackParamList = {
Home: undefined;
ShippingDetails: undefined;
Main: undefined;
// Add other screens as needed
};
type NavigationProp = NativeStackNavigationProp<RootStackParamList>;
2 months ago
export const ShippingDetailsSection = () => {
2 months ago
const [shippingMethod, setShippingMethod] = useState('maritime'); // 'maritime' or 'airway'
const [isLoading, setIsLoading] = useState(true);
const navigation = useNavigation<NavigationProp>();
useEffect(() => {
// Preload images
const preloadImages = async () => {
try {
await Promise.all([
Image.prefetch(Image.resolveAssetSource(require('../../../assets/img/image_f67fe9bc.png')).uri),
Image.prefetch(Image.resolveAssetSource(require('../../../assets/img/feijiback.png')).uri)
2 months ago
]);
setIsLoading(false);
} catch (error) {
console.error('Error preloading images:', error);
setIsLoading(false);
}
};
preloadImages();
}, []);
const handleShippingMethodChange = (method: 'maritime' | 'airway') => {
setShippingMethod(method);
};
// Get background image based on shipping method
const getBackgroundImage = () => {
return shippingMethod === 'maritime'
? require('../../../assets/img/image_f67fe9bc.png')
: require('../../../assets/img/feijiback.png');
2 months ago
};
2 months ago
return (
<View style={styles.container}>
2 months ago
{isLoading ? (
<View style={styles.loadingContainer}>
<ActivityIndicator size="large" color="#005EE4" />
</View>
) : (
<ImageBackground
source={getBackgroundImage()}
style={styles.backgroundImage}
>
<View style={styles.contentContainer}>
<View style={styles.timeShippingSection}>
<View style={styles.shippingCostContainer}>
<View style={styles.svgContainer}>
<TouchableOpacity
style={styles.backButton}
onPress={() => {
navigation.goBack();
}}
>
<BackIcon size={fontSize(18)} color="#ffffff"/>
</TouchableOpacity>
</View>
<Text style={styles.shippingCostLabelTextStyle}>Frais d'expédition</Text>
2 months ago
</View>
</View>
2 months ago
{/* Calculator Form */}
<View style={styles.shippingCalculatorContainer}>
<View style={styles.flexColumnCenteredWithSelect}>
{/* Shipping Method Selection */}
<View style={styles.shippingMethodContainer}>
{/* Maritime Option */}
<TouchableOpacity
style={[
styles.maritimeInfoBox,
shippingMethod === 'maritime' ? styles.activeShippingMethod : {}
]}
onPress={() => handleShippingMethodChange('maritime')}
>
<View style={styles.svgContainer1}>
<Image
source={require('../../../assets/img/海运 (1) 1.png')}
2 months ago
style={{width: widthUtils(24, 24).width, height: widthUtils(24, 24).height,
tintColor: shippingMethod === 'maritime' ? '#fff' : '#747474'}}
/>
</View>
<Text style={[
styles.maritimeHeadingStyle,
shippingMethod === 'maritime' ? {} : {color: '#747474'}
]}>Par voie maritime</Text>
</TouchableOpacity>
2 months ago
2 months ago
{/* Airway Option */}
<TouchableOpacity
style={[
styles.airwayInfoContainer,
shippingMethod === 'airway' ? styles.activeShippingMethod : {}
]}
onPress={() => handleShippingMethodChange('airway')}
>
<View style={styles.svgContainer2}>
<Image
source={require('../../../assets/img/空运 1.png')}
2 months ago
style={{width: widthUtils(24, 24).width, height: widthUtils(24, 24).height, tintColor: shippingMethod === 'airway' ? '#fff' : '#747474'}}
/>
</View>
<Text style={[
styles.flightModeLabel,
shippingMethod === 'airway' ? {color: '#fff'} : {}
]}>Par voie aérienne</Text>
</TouchableOpacity>
</View>
2 months ago
2 months ago
{/* Parcel Volume Form */}
<View style={styles.parcelVolumeFormContainer}>
{/* Dropdown Select - Replace with actual picker component */}
<View style={styles.parcelVolumeContainer}>
<Text style={styles.parcelVolumeLabel}>Volume de colis</Text>
<View style={styles.volumeInputContainer}>
<Text style={styles.volumePromptTextStyle}>Veuillez saisir le volume du colis</Text>
<Text style={styles.volumeLabel}>{shippingMethod === 'maritime' ? 'm³' : 'kg'}</Text>
</View>
2 months ago
</View>
2 months ago
<View style={styles.parcelVolumeContainer}>
<Text style={styles.parcelVolumeLabel}>Volume de colis</Text>
<View style={styles.volumeInputContainer}>
<Text style={styles.volumePromptTextStyle}>Veuillez saisir le volume du colis</Text>
<Text style={styles.volumeLabel}>{shippingMethod === 'maritime' ? 'm³' : 'kg'}</Text>
</View>
2 months ago
</View>
</View>
2 months ago
{/* Submit Button */}
<TouchableOpacity style={styles.primaryButton}>
<Text style={{color: 'white', fontSize: fontSize(16), fontFamily: 'PingFang SC', fontWeight: '600'}}>
Calculer les frais d'expédition
</Text>
</TouchableOpacity>
</View>
2 months ago
</View>
</View>
2 months ago
</ImageBackground>
)}
2 months ago
</View>
);
};
const styles = StyleSheet.create({
container: {
width: '100%',
flex: 1,
},
backgroundImage: {
width: '100%',
height: '100%',
resizeMode: 'cover',
},
contentContainer: {
flex: 1,
padding: 15,
2 months ago
},
timeShippingSection: {
flexDirection: 'column',
},
timeAndImageContainer: {
flexDirection: 'row',
gap: 8,
alignItems: 'center',
justifyContent: 'space-between',
paddingLeft: 36,
},
timeDisplay: {
2 months ago
width: widthUtils(42, 42).width,
fontSize: fontSize(17),
2 months ago
fontFamily: 'SF Pro',
fontWeight: '600',
color: 'white',
textAlign: 'center',
},
timeImageContainer: {
2 months ago
width: widthUtils(54, 154).width,
height: widthUtils(54, 154).height,
2 months ago
},
shippingCostContainer: {
flexDirection: 'row',
alignItems: 'center',
marginTop: 20,
2 months ago
justifyContent: 'center',
2 months ago
},
svgContainer: {
2 months ago
width: widthUtils(18, 18).width,
height: widthUtils(18, 18).height,
position: 'absolute',
left: 0,
2 months ago
},
shippingCostLabelTextStyle: {
2 months ago
fontSize: fontSize(20),
2 months ago
lineHeight: 22,
fontFamily: 'Microsoft YaHei UI',
fontWeight: '700',
color: 'white',
textAlign: 'center',
textTransform: 'capitalize',
2 months ago
width: '100%',
2 months ago
},
shippingCalculatorContainer: {
2 months ago
marginTop: widthUtils(100,100).height,
2 months ago
paddingTop: 18,
paddingRight: 20,
paddingBottom: 28,
paddingLeft: 20,
backgroundColor: 'white',
borderRadius: 5,
justifyContent: 'center',
},
flexColumnCenteredWithSelect: {
flexDirection: 'column',
justifyContent: 'center',
},
shippingMethodContainer: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
2 months ago
height: widthUtils(80, 80).height,
2 months ago
paddingRight: 10,
paddingLeft: 10,
backgroundColor: '#f2f6ff',
borderRadius: 5,
},
maritimeInfoBox: {
2 months ago
height: widthUtils(60, 60).height,
2 months ago
paddingRight: 19,
paddingLeft: 20,
2 months ago
backgroundColor: '#f2f6ff',
2 months ago
borderRadius: 5,
justifyContent: 'center',
alignItems: 'center',
},
2 months ago
airwayInfoContainer: {
height: widthUtils(60, 60).height,
paddingRight: 24,
paddingLeft: 25,
marginLeft: 10,
backgroundColor: '#f2f6ff',
borderRadius: 5,
justifyContent: 'center',
alignItems: 'center',
},
activeShippingMethod: {
backgroundColor: '#005EE4',
},
2 months ago
svgContainer1: {
2 months ago
width: widthUtils(32, 32).width,
height: widthUtils(32, 32).height,
2 months ago
},
maritimeHeadingStyle: {
marginTop: -5,
2 months ago
fontSize: fontSize(14),
2 months ago
fontFamily: 'Segoe UI',
fontWeight: '700',
color: 'white',
textTransform: 'capitalize',
},
svgContainer2: {
2 months ago
width: widthUtils(24, 24).width,
height: widthUtils(24, 24).height,
2 months ago
},
flightModeLabel: {
marginTop: -2,
2 months ago
fontSize: fontSize(14),
2 months ago
fontFamily: 'Segoe UI',
fontWeight: '400',
color: '#747474',
textTransform: 'capitalize',
},
parcelVolumeFormContainer: {
marginTop: 16,
backgroundColor: 'white',
borderWidth: 1,
borderColor: '#dbdce0',
},
optionContainer: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
2 months ago
height: widthUtils(60, 60).height,
2 months ago
paddingRight: 6,
paddingLeft: 8,
backgroundColor: 'white',
borderWidth: 1,
borderColor: '#dbdce0',
borderTopLeftRadius: 5,
borderTopRightRadius: 5,
},
pingfangTextSelect: {
2 months ago
fontSize: fontSize(12),
2 months ago
fontFamily: 'PingFang SC',
fontWeight: '500',
color: '#646472',
},
iconSelectDropdown: {
2 months ago
width: widthUtils(24, 24).width,
height: widthUtils(24, 24).height,
2 months ago
marginLeft: 10,
},
parcelVolumeContainer: {
width: '100%',
paddingTop: 6,
paddingRight: 8,
paddingBottom: 10,
paddingLeft: 8,
marginTop: -1,
backgroundColor: 'white',
borderWidth: 1,
borderColor: '#dbdce0',
borderBottomLeftRadius: 5,
borderBottomRightRadius: 5,
},
parcelVolumeLabel: {
2 months ago
fontSize: fontSize(12),
2 months ago
fontFamily: 'PingFang SC',
fontWeight: '600',
color: '#646472',
},
volumeInputContainer: {
flexDirection: 'row',
gap: 8,
alignItems: 'center',
justifyContent: 'space-between',
width: '100%',
},
volumePromptTextStyle: {
2 months ago
fontSize: fontSize(16),
2 months ago
lineHeight: 22,
fontFamily: 'PingFang SC',
fontWeight: '400',
color: '#807e7e',
},
volumeLabel: {
2 months ago
fontSize: fontSize(16),
2 months ago
lineHeight: 22,
fontFamily: 'PingFang SC',
fontWeight: '600',
color: '#1c284e',
},
primaryButton: {
2 months ago
width:'100%',
height: widthUtils(50, 50).height,
2 months ago
marginTop: 34,
backgroundColor: '#002fa7',
borderRadius: 25,
justifyContent: 'center',
alignItems: 'center',
},
2 months ago
backButton: {
padding: 10,
borderRadius: 20,
zIndex: 10,
},
loadingContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f2f6ff',
},
2 months ago
});