Initial commit

This commit is contained in:
Samandar Turgunboyev
2025-08-26 16:26:59 +05:00
commit fd95422447
318 changed files with 38301 additions and 0 deletions

175
src/components/Navbar.tsx Normal file
View File

@@ -0,0 +1,175 @@
import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import React, { useCallback, useMemo, useState } from 'react';
import {
Dimensions,
Image,
Linking,
Platform,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import AppLink from 'react-native-app-link';
import Fontisto from 'react-native-vector-icons/Fontisto';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import Logo from 'screens/../../assets/bootsplash/logo.png';
import InAppBrowser from './InAppBrowser';
const { width } = Dimensions.get('window');
const isSmallScreen = width < 360;
const Navbar = () => {
const [browserUrl, setBrowserUrl] = useState('');
const [modalVisible, setModalVisible] = useState(false);
const navigation = useNavigation<NativeStackNavigationProp<any>>();
const iconSizes = useMemo(
() => ({
telegram: isSmallScreen ? 20 : 24,
instagram: isSmallScreen ? 18 : 22,
facebook: isSmallScreen ? 22 : 26,
bell: isSmallScreen ? 20 : 24,
}),
[],
);
const openTelegram = useCallback(async () => {
try {
await AppLink.maybeOpenURL('tg://resolve?domain=cpostuz', {
appName: 'Telegram',
appStoreId: 686449807,
appStoreLocale: 'us',
playStoreId: 'org.telegram.messenger',
});
} catch (err) {
// Agar ilovani ham, storeni ham ochib bolmasa, fallback URL
Linking.openURL('https://t.me/cpostuz');
}
}, []);
const openInstagram = useCallback(async () => {
try {
await AppLink.maybeOpenURL('instagram://user?username=cpost_cargo', {
appName: 'Instagram',
appStoreId: 389801252,
appStoreLocale: 'us',
playStoreId: 'com.instagram.android',
});
} catch (err) {
// Agar ilovani ham, storeni ham ochib bolmasa, fallback URL
Linking.openURL('instagram://user?username=cpost_cargo');
}
}, []);
const openFacebook = useCallback(async () => {
try {
await AppLink.maybeOpenURL('fb://user?username=cpost_cargo', {
appName: 'Facebook',
appStoreId: 284882215,
appStoreLocale: 'us',
playStoreId: 'com.facebook.katana',
});
} catch (err) {
Linking.openURL('https://facebook.com/');
}
}, []);
const handleCloseBrowser = useCallback(() => {
setModalVisible(false);
}, []);
return (
<>
<View style={styles.header}>
<View style={styles.logo}>
<Image source={Logo} style={styles.logoImage} />
<Text style={styles.title}>CPOST</Text>
</View>
<View style={styles.links}>
<TouchableOpacity onPress={openTelegram}>
<Fontisto name="telegram" color="#fff" size={iconSizes.telegram} />
</TouchableOpacity>
<TouchableOpacity onPress={openInstagram}>
<Fontisto
name="instagram"
color="#fff"
size={iconSizes.instagram}
/>
</TouchableOpacity>
{/* <TouchableOpacity onPress={openFacebook}>
<MaterialIcons
name="facebook"
color="#fff"
size={iconSizes.facebook}
/>
</TouchableOpacity> */}
{Platform.OS === 'android' && (
<TouchableOpacity
onPress={() => navigation.navigate('Notifications')}
>
<MaterialCommunityIcons
name="bell-outline"
color="#fff"
size={iconSizes.bell}
/>
{/* <View style={styles.bellDot} /> */}
</TouchableOpacity>
)}
</View>
</View>
<InAppBrowser
visible={modalVisible}
url={browserUrl}
onClose={handleCloseBrowser}
/>
</>
);
};
const styles = StyleSheet.create({
header: {
backgroundColor: '#28A7E8',
height: 80,
paddingHorizontal: 10,
paddingVertical: 10,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
},
title: {
color: '#fff',
fontSize: 20,
fontWeight: 'bold',
},
logo: {
flexDirection: 'row',
alignItems: 'center',
gap: 5,
},
logoImage: {
width: 40,
height: 40,
resizeMode: 'contain',
},
links: {
flexDirection: 'row',
alignItems: 'center',
gap: 10,
},
bellDot: {
width: 10,
height: 10,
position: 'absolute',
backgroundColor: 'red',
right: 2,
borderRadius: 100,
},
});
export default Navbar;