This commit is contained in:
azizziy
2025-08-28 10:05:01 +05:00
parent c1cefc0133
commit 03c8ba8540
5 changed files with 55 additions and 67 deletions

2
.env
View File

@@ -1 +1 @@
API_URL=http://141.105.64.233:7723/api/v1 API_URL=https://api.cpcargo.uz/api/v1

View File

@@ -1,4 +1,4 @@
export const BASE_URL = 'http://141.105.64.233:7723/api/v1'; export const BASE_URL = 'https://api.cpcargo.uz/api/v1';
export const REGISTER = '/mobile/auth/register'; export const REGISTER = '/mobile/auth/register';
export const LOGIN = '/mobile/auth/login'; export const LOGIN = '/mobile/auth/login';

View File

@@ -3,7 +3,7 @@ import axios, { AxiosError } from 'axios';
import { navigate } from 'components/NavigationRef'; import { navigate } from 'components/NavigationRef';
const axiosInstance = axios.create({ const axiosInstance = axios.create({
baseURL: 'http://141.105.64.233:7723/api/v1', baseURL: 'https://api.cpcargo.uz/api/v1',
timeout: 10000, timeout: 10000,
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View File

@@ -94,13 +94,13 @@ const styles = StyleSheet.create({
wrapper: { wrapper: {
bottom: 0, bottom: 0,
width: '100%', width: '100%',
height: 60, height: 70,
}, },
container: { container: {
height: '100%', height: '100%',
backgroundColor: '#fff', backgroundColor: '#fff',
borderTopLeftRadius: 30, borderTopLeftRadius: 20,
borderTopRightRadius: 30, borderTopRightRadius: 20,
flexDirection: 'row', flexDirection: 'row',
shadowColor: '#000', shadowColor: '#000',
shadowOpacity: 0.1, shadowOpacity: 0.1,

View File

@@ -1,12 +1,6 @@
import { Dispatch, SetStateAction, useCallback, useMemo } from 'react'; import { Dispatch, SetStateAction, useMemo } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { import { Image, Text, TouchableOpacity, View } from 'react-native';
FlatList,
Image,
Text,
TouchableOpacity,
useWindowDimensions,
} from 'react-native';
import LinearGradient from 'react-native-linear-gradient'; import LinearGradient from 'react-native-linear-gradient';
import AviaLogo from 'screens/../../assets/bootsplash/Avia.png'; import AviaLogo from 'screens/../../assets/bootsplash/Avia.png';
import AutoLogo from 'screens/../../assets/bootsplash/auto.png'; import AutoLogo from 'screens/../../assets/bootsplash/auto.png';
@@ -19,8 +13,6 @@ interface Props {
const Tabs = ({ activeTab, setActiveTab }: Props) => { const Tabs = ({ activeTab, setActiveTab }: Props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { width: screenWidth } = useWindowDimensions();
const cardWidth = screenWidth * 0.95;
const styles = useMemo(() => HomeStyle(), []); const styles = useMemo(() => HomeStyle(), []);
const gradientStyle = useMemo( const gradientStyle = useMemo(
@@ -29,9 +21,7 @@ const Tabs = ({ activeTab, setActiveTab }: Props) => {
borderRadius: 8, borderRadius: 8,
flexDirection: 'row' as const, flexDirection: 'row' as const,
alignItems: 'center' as const, alignItems: 'center' as const,
paddingHorizontal: 12,
height: 80, height: 80,
gap: 8,
}), }),
[], [],
); );
@@ -53,57 +43,55 @@ const Tabs = ({ activeTab, setActiveTab }: Props) => {
[t], [t],
); );
const renderItem = useCallback(
({ item }: { item: (typeof tabsData)[number] }) => {
const isActive = activeTab === item.type;
const gradientColors = isActive
? ['#28A7E8', '#28A7E8']
: ['#28a8e82d', '#28A7E8'];
return (
<TouchableOpacity
onPress={() => setActiveTab(item.type)}
style={{ flex: 1 }}
>
<LinearGradient
colors={gradientColors}
start={{ x: 0, y: 0 }}
end={{ x: 1, y: 0 }}
style={gradientStyle}
>
<Image source={item.logo} style={styles.tabsLogo} />
<Text
style={[styles.tabsText, { color: isActive ? '#fff' : '#000' }]}
>
{item.label}
</Text>
</LinearGradient>
</TouchableOpacity>
);
},
[activeTab, styles, gradientStyle, setActiveTab],
);
return ( return (
<FlatList <View style={{ flexDirection: 'row', paddingHorizontal: 10, gap: 12 }}>
data={tabsData} {tabsData.map(item => {
numColumns={2} const isActive = activeTab === item.type;
keyExtractor={(_, idx) => idx.toString()} const gradientColors = isActive
renderItem={renderItem} ? ['#28A7E8', '#28A7E8']
showsHorizontalScrollIndicator={false} : ['#28a8e82d', '#28A7E8'];
scrollEnabled={false}
columnWrapperStyle={{ return (
gap: 8, <TouchableOpacity
}} onPress={() => setActiveTab(item.type)}
contentContainerStyle={{ style={{ flex: 1 }}
paddingHorizontal: (screenWidth - cardWidth) / 2, >
}} <LinearGradient
getItemLayout={(_, index) => ({ colors={gradientColors}
length: cardWidth, start={{ x: 0, y: 0 }}
offset: cardWidth * index, end={{ x: 1, y: 0 }}
index, style={gradientStyle}
>
<Image source={item.logo} style={styles.tabsLogo} />
<Text
style={[styles.tabsText, { color: isActive ? '#fff' : '#000' }]}
>
{item.label}
</Text>
</LinearGradient>
</TouchableOpacity>
);
})} })}
/> </View>
// <FlatList
// data={tabsData}
// numColumns={2}
// keyExtractor={(_, idx) => idx.toString()}
// renderItem={renderItem}
// showsHorizontalScrollIndicator={false}
// scrollEnabled={false}
// columnWrapperStyle={{
// gap: 8,
// }}
// contentContainerStyle={{
// paddingHorizontal: (screenWidth - cardWidth) / 2,
// }}
// getItemLayout={(_, index) => ({
// length: cardWidth,
// offset: cardWidth * index,
// index,
// })}
// />
); );
}; };