update icon, info trip

This commit is contained in:
2025-10-30 19:43:19 +07:00
parent f9ca9542c4
commit 5c6758d2c2
5 changed files with 108 additions and 35 deletions

View File

@@ -1,22 +1,22 @@
import { ThemedText } from "@/components/themed-text"; import { ThemedText } from "@/components/themed-text";
import { ThemedView } from "@/components/themed-view";
import TripCostTable from "@/components/tripInfo/TripCostTable"; import TripCostTable from "@/components/tripInfo/TripCostTable";
import { StyleSheet } from "react-native"; import { StyleSheet, View } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
export default function TripInfoScreen() { export default function TripInfoScreen() {
return ( return (
<ThemedView style={styles.container}> <SafeAreaView>
<ThemedText type="title">Thông Tin Chuyến Đi</ThemedText> <View style={styles.container}>
<TripCostTable /> <ThemedText type="title">Thông Tin Chuyến Đi</ThemedText>
</ThemedView> <TripCostTable />
</View>
</SafeAreaView>
); );
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1,
alignItems: "center", alignItems: "center",
justifyContent: "center",
padding: 20, padding: 20,
}, },
}); });

View File

@@ -1,6 +1,16 @@
import React from "react"; import { IconSymbol } from "@/components/ui/icon-symbol";
import { FlatList, ListRenderItem, Text, View } from "react-native"; import React, { useRef, useState } from "react";
import styles from "./TripCostTable.styles"; import {
Animated,
FlatList,
ListRenderItem,
Platform,
Text,
TouchableOpacity,
UIManager,
View,
} from "react-native";
import styles from "./style/TripCostTable.styles";
// --------------------------- // ---------------------------
// 🧩 Interface // 🧩 Interface
@@ -55,7 +65,18 @@ const data: CostItem[] = [
// --------------------------- // ---------------------------
// 💰 Component chính // 💰 Component chính
// --------------------------- // ---------------------------
const TripCostTable: React.FC = () => { const TripCostTable: React.FC = () => {
// Enable LayoutAnimation for Android
if (
Platform.OS === "android" &&
UIManager.setLayoutAnimationEnabledExperimental
) {
UIManager.setLayoutAnimationEnabledExperimental(true);
}
const [collapsed, setCollapsed] = useState(true);
const animatedHeight = useRef(new Animated.Value(0)).current;
const tongCong = data.reduce((sum, item) => sum + item.tongChiPhi, 0); const tongCong = data.reduce((sum, item) => sum + item.tongChiPhi, 0);
const renderItem: ListRenderItem<CostItem> = ({ item }) => ( const renderItem: ListRenderItem<CostItem> = ({ item }) => (
@@ -67,32 +88,80 @@ const TripCostTable: React.FC = () => {
</View> </View>
); );
const contentHeight = 220; // Chiều cao cố định cho bảng, có thể điều chỉnh
const handleToggle = () => {
if (collapsed) {
Animated.timing(animatedHeight, {
toValue: contentHeight,
duration: 350,
useNativeDriver: false,
}).start();
} else {
Animated.timing(animatedHeight, {
toValue: 0,
duration: 350,
useNativeDriver: false,
}).start();
}
setCollapsed((prev) => !prev);
};
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Text style={styles.title}>Chi phí chuyến đi</Text> <TouchableOpacity
activeOpacity={0.7}
onPress={handleToggle}
style={{
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
marginBottom: collapsed ? 0 : 12,
}}
>
<Text style={styles.title}>Chi phí chuyến đi</Text>
{collapsed && (
<Text
style={[
styles.title,
{ color: "#ff6600", fontWeight: "bold", marginLeft: 8 },
]}
>
{tongCong.toLocaleString()}
</Text>
)}
<IconSymbol
name={collapsed ? "arrowshape.down.fill" : "arrowshape.up.fill"}
size={15}
color="#000000"
/>
</TouchableOpacity>
{/* Header */} <Animated.View style={{ height: animatedHeight, overflow: "hidden" }}>
<View style={[styles.row, styles.header]}> {/* Header */}
<Text style={[styles.cell, styles.left, styles.headerText]}>Loại</Text> <View style={[styles.row, styles.header]}>
<Text style={[styles.cell, styles.headerText]}>Tổng chi phí</Text> <Text style={[styles.cell, styles.left, styles.headerText]}>
</View> Loại
</Text>
<Text style={[styles.cell, styles.headerText]}>Tổng chi phí</Text>
</View>
{/* Body */} {/* Body */}
<FlatList <FlatList
data={data} data={data}
renderItem={renderItem} renderItem={renderItem}
keyExtractor={(item) => item.id} keyExtractor={(item) => item.id}
/> />
{/* Footer */} {/* Footer */}
<View style={[styles.row, styles.footer]}> <View style={[styles.row]}>
<Text style={[styles.cell, styles.left, styles.footerText]}> <Text style={[styles.cell, styles.left, styles.footerText]}>
Tổng cộng Tổng cộng
</Text> </Text>
<Text style={[styles.cell, styles.total]}> <Text style={[styles.cell, styles.total]}>
{tongCong.toLocaleString()} {tongCong.toLocaleString()}
</Text> </Text>
</View> </View>
</Animated.View>
</View> </View>
); );
}; };

View File

@@ -12,11 +12,14 @@ const styles = StyleSheet.create({
shadowRadius: 4, shadowRadius: 4,
elevation: 2, elevation: 2,
}, },
icon: {
fontSize: 10,
},
title: { title: {
fontSize: 18, fontSize: 18,
fontWeight: "700", fontWeight: "700",
textAlign: "center", textAlign: "center",
marginBottom: 12, // marginBottom: 12,
}, },
row: { row: {
flexDirection: "row", flexDirection: "row",
@@ -52,7 +55,7 @@ const styles = StyleSheet.create({
color: "#007bff", color: "#007bff",
}, },
total: { total: {
color: "#007bff", color: "#ff6600",
fontWeight: "700", fontWeight: "700",
}, },
}); });

View File

@@ -23,6 +23,8 @@ const MAPPING = {
"chevron.right": "chevron-right", "chevron.right": "chevron-right",
"ferry.fill": "directions-boat", "ferry.fill": "directions-boat",
"map.fill": "map", "map.fill": "map",
"arrowshape.down.fill": "arrow-drop-down",
"arrowshape.up.fill": "arrow-drop-up",
} as IconMapping; } as IconMapping;
/** /**

View File

@@ -53,7 +53,6 @@ api.interceptors.response.use(
return response; return response;
}, },
(error) => { (error) => {
if (!error.response) { if (!error.response) {
const networkErrorMsg = const networkErrorMsg =
error.message || "Network error - please check connection"; error.message || "Network error - please check connection";