| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- import Svg, { Path, Rect } from 'react-native-svg';
- import * as React from 'react';
- import {
- View,
- Text,
- useWindowDimensions,
- StyleSheet,
- Image,
- ImageSourcePropType,
- Pressable
- } from 'react-native';
- import { TabView, SceneMap, TabBar } from 'react-native-tab-view';
- import { FlashList } from '@shopify/flash-list';
- import { SafeAreaView } from 'react-native-safe-area-context';
- import { router } from 'expo-router';
- import { CheckMarkLogoSvg, CrossLogoSvg } from '../global/SVG';
- interface TabItem {
- imgURL: ImageSourcePropType;
- date: string;
- time: string;
- chargeStationName: string;
- chargeStationAddress: string;
- distance: string;
- }
- interface TabViewComponentProps {
- titles: string[];
- tabItems: TabItem[];
- }
- const dummyTabItems: TabItem[] = [
- {
- imgURL: require('../../assets/dummyStationPicture.png'),
- date: '今天',
- time: '16:30',
- chargeStationName: '上環街市充電站',
- chargeStationAddress: '香港上環皇后大道中345號',
- distance: '400米'
- },
- {
- imgURL: require('../../assets/dummyStationPicture2.png'),
- date: '3月15',
- time: '17:45',
- chargeStationName: '中環IFC充電站',
- chargeStationAddress: '香港中環皇后大道中999號',
- distance: '680米'
- },
- {
- imgURL: require('../../assets/dummyStationPicture2.png'),
- date: '4月20',
- time: '12:30',
- chargeStationName: '中環IFC充電站',
- chargeStationAddress: '香港中環皇后大道中999號',
- distance: '680米'
- },
- {
- imgURL: require('../../assets/dummyStationPicture.png'),
- date: '今天',
- time: '16:30',
- chargeStationName: '上環街市充電站',
- chargeStationAddress: '香港上環皇后大道中345號',
- distance: '400米'
- },
- {
- imgURL: require('../../assets/dummyStationPicture.png'),
- date: '今天',
- time: '16:30',
- chargeStationName: '上環街市充電站',
- chargeStationAddress: '香港上環皇后大道中345號',
- distance: '400米'
- }
- ];
- const LocationTabComponent: React.FC<TabViewComponentProps> = ({
- titles,
- tabItems
- }) => {
- const layout = useWindowDimensions();
- const FirstRoute = () => (
- <View style={{ flex: 1, backgroundColor: 'white' }}>
- <FlashList
- data={tabItems}
- renderItem={({ item }) => {
- return (
- <Pressable
- // onPress={() => console.log('clicked')}
- onPress={() => router.push('resultDetailPage')}
- style={({ pressed }) => [
- styles.container,
- {
- backgroundColor: pressed
- ? '#e7f2f8'
- : '#ffffff'
- }
- ]}
- >
- <View style={styles.container}>
- <Image
- style={styles.image}
- source={item.imgURL}
- />
- <View style={styles.textContainer}>
- <Text
- style={{
- fontWeight: 400,
- fontSize: 18,
- color: '#222222'
- }}
- >
- {item.chargeStationName}
- </Text>
- <Text
- style={{
- fontWeight: 400,
- fontSize: 14,
- color: '#888888'
- }}
- >
- {item.chargeStationAddress}
- </Text>
- <View className=" flex-row space-x-2 items-center">
- <CheckMarkLogoSvg />
- <Text
- style={{
- fontWeight: 400,
- fontSize: 14,
- color: '#222222'
- }}
- >
- Walk-in
- </Text>
- </View>
- </View>
- <Text
- style={{
- fontWeight: 400,
- fontSize: 16,
- color: '#888888',
- marginTop: 22
- }}
- >
- {item.distance}
- </Text>
- </View>
- </Pressable>
- );
- }}
- estimatedItemSize={10}
- />
- </View>
- );
- //tab 2
- const SecondRoute = () => (
- <View style={{ flex: 1, backgroundColor: 'white' }}>
- <FlashList
- data={tabItems}
- renderItem={({ item }) => {
- return (
- <Pressable
- // onPress={() => console.log('clicked')}
- onPress={() => router.push('resultDetailPage')}
- style={({ pressed }) => [
- styles.container,
- {
- backgroundColor: pressed
- ? '#e7f2f8'
- : '#ffffff'
- }
- ]}
- >
- <View style={styles.container}>
- <Image
- style={styles.image}
- source={item.imgURL}
- />
- <View style={styles.textContainer}>
- <Text
- style={{
- fontWeight: 400,
- fontSize: 18,
- color: '#222222'
- }}
- >
- {item.chargeStationName}
- </Text>
- <Text
- style={{
- fontWeight: 400,
- fontSize: 14,
- color: '#888888'
- }}
- >
- {item.chargeStationAddress}
- </Text>
- <View className=" flex-row space-x-2 items-center">
- <CheckMarkLogoSvg />
- <Text
- style={{
- fontWeight: 400,
- fontSize: 14,
- color: '#222222'
- }}
- >
- Walk-in
- </Text>
- </View>
- </View>
- <Text
- style={{
- fontWeight: 400,
- fontSize: 16,
- color: '#888888',
- marginTop: 22
- }}
- >
- {item.distance}
- </Text>
- </View>
- </Pressable>
- );
- }}
- estimatedItemSize={10}
- />
- </View>
- );
- const renderScene = SceneMap({
- firstRoute: FirstRoute,
- secondRoute: SecondRoute
- });
- const [routes] = React.useState([
- { key: 'firstRoute', title: titles[0] },
- { key: 'secondRoute', title: titles[1] }
- ]);
- const [index, setIndex] = React.useState(0);
- const renderTabBar = (props: any) => (
- <TabBar
- {...props}
- renderLabel={({ route, focused }) => (
- <Text
- style={{
- color: focused ? '#025c72' : '#888888',
- fontWeight: focused ? '900' : 'thin',
- fontSize: 20
- }}
- >
- {route.title}
- </Text>
- )}
- indicatorStyle={{
- backgroundColor: '#025c72'
- }}
- style={{
- backgroundColor: 'white',
- borderColor: '#DBE4E8',
- elevation: 0,
- borderBottomWidth: 0.5
- }}
- />
- );
- return (
- <TabView
- navigationState={{ index, routes }}
- renderScene={renderScene}
- onIndexChange={setIndex}
- initialLayout={{ width: layout.width }}
- renderTabBar={renderTabBar}
- />
- );
- };
- const styles = StyleSheet.create({
- container: { flexDirection: 'row' },
- image: {
- width: 100,
- height: 100,
- marginTop: 15,
- marginRight: 15,
- borderRadius: 10
- },
- textContainer: { flexDirection: 'column', gap: 8, marginTop: 22 }
- });
- const ReservationLocationPage = () => {
- return (
- <SafeAreaView
- className="flex-1 bg-white"
- edges={['top', 'left', 'right']}
- >
- <View className="flex-1 mx-[5%] ">
- <View className="min-h-[250px] flex-column">
- <View className="flex-1 justify-center">
- <View className="pt-5 pl-4">
- <Pressable
- onPress={() => {
- if (router.canGoBack()) {
- router.back();
- } else {
- router.replace('/');
- }
- }}
- >
- <CrossLogoSvg />
- </Pressable>
- </View>
- </View>
- <View className="flex-1 justify-center ">
- <Text className="text-[50px] font-normal ">
- 預約地點
- </Text>
- </View>
- <View className="flex-1 justify-center ">
- <Pressable onPress={() => router.push('searchPage')}>
- <View
- style={{
- borderWidth: 1,
- padding: 24,
- borderRadius: 12,
- borderColor: '#bbbbbb',
- maxWidth: '100%'
- }}
- >
- <Text
- style={{ color: '#888888', fontSize: 16 }}
- >
- 搜尋充電站或地區..
- </Text>
- </View>
- </Pressable>
- </View>
- </View>
- <View className="flex-1 mt-2">
- <LocationTabComponent
- titles={['附近的充電站', '所有的充電站']}
- tabItems={dummyTabItems}
- />
- </View>
- </View>
- </SafeAreaView>
- );
- };
- export default ReservationLocationPage;
|