2022-09-16 20:06:52 +00:00
|
|
|
import { View, TouchableOpacity, Text } from 'react-native';
|
2022-09-16 22:00:29 +00:00
|
|
|
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
|
|
|
|
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
2022-09-18 06:24:37 +00:00
|
|
|
import { createDrawerNavigator } from '@react-navigation/drawer';
|
2022-09-17 06:54:57 +00:00
|
|
|
import { createStackNavigator } from '@react-navigation/stack';
|
2022-09-16 20:06:52 +00:00
|
|
|
import { NavigationContainer } from '@react-navigation/native';
|
2022-09-16 22:00:29 +00:00
|
|
|
import Ionicons from '@expo/vector-icons/AntDesign';
|
2022-09-16 20:06:52 +00:00
|
|
|
import { useSession } from './useSession.hook';
|
2022-09-16 22:00:29 +00:00
|
|
|
import { styles } from './Session.styled';
|
|
|
|
import Colors from 'constants/Colors';
|
2022-09-17 06:54:57 +00:00
|
|
|
import { Profile } from './profile/Profile';
|
|
|
|
import { Channels } from './channels/Channels';
|
|
|
|
import { Cards } from './cards/Cards';
|
2022-09-19 00:04:17 +00:00
|
|
|
import { Contact } from './contact/Contact';
|
|
|
|
import { Details } from './details/Details';
|
|
|
|
import { Conversation } from './conversation/Conversation';
|
2022-09-12 22:18:27 +00:00
|
|
|
|
2022-09-07 07:32:06 +00:00
|
|
|
export function Session() {
|
2022-09-12 22:18:27 +00:00
|
|
|
|
2022-09-16 20:06:52 +00:00
|
|
|
const { state, actions } = useSession();
|
|
|
|
|
|
|
|
const Tab = createBottomTabNavigator();
|
|
|
|
|
2022-09-19 00:04:17 +00:00
|
|
|
const openCards = (nav) => {}
|
|
|
|
const closeCards = (nav) => {}
|
|
|
|
const openProfile = (nav) => {}
|
|
|
|
const closeProfile = (nav) => {}
|
|
|
|
const openContact = (nav, cardId) => {}
|
|
|
|
const closeContact = (nav) => {}
|
|
|
|
const openConversation = (nav, channelId) => {}
|
|
|
|
const closeConversation = (nav) => {}
|
|
|
|
|
|
|
|
|
|
|
|
// tabbed containers
|
2022-09-17 06:54:57 +00:00
|
|
|
const ConversationStack = createStackNavigator();
|
|
|
|
const ConversationStackScreen = () => {
|
|
|
|
return (
|
|
|
|
<ConversationStack.Navigator screenOptions={({ route }) => ({ headerShown: false })}>
|
2022-09-19 00:04:17 +00:00
|
|
|
<ConversationStack.Screen name="channels" component={ChannelsTabScreen} />
|
|
|
|
<ConversationStack.Screen name="details" component={DetailsTabScreen} />
|
2022-09-17 06:54:57 +00:00
|
|
|
</ConversationStack.Navigator>
|
|
|
|
);
|
|
|
|
}
|
2022-09-19 00:04:17 +00:00
|
|
|
const ChannelsTabScreen = ({ navigation }) => {
|
|
|
|
return <Channels
|
|
|
|
openConversation={(channelId) => openConversation(navigation, channelId)}
|
|
|
|
openProfile={() => openProfile(navigation)}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
const DetailsTabScreen = ({ navigation }) => {
|
|
|
|
return <Details closeDetails={() => closeDetails(navigation)} />
|
|
|
|
}
|
2022-09-17 06:54:57 +00:00
|
|
|
const ProfileStack = createStackNavigator();
|
|
|
|
const ProfileStackScreen = () => {
|
|
|
|
return (
|
|
|
|
<ProfileStack.Navigator screenOptions={({ route }) => ({ headerShown: false })}>
|
2022-09-19 00:04:17 +00:00
|
|
|
<ProfileStack.Screen name="profile" component={Profile} />
|
2022-09-17 06:54:57 +00:00
|
|
|
</ProfileStack.Navigator>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
const ContactStack = createStackNavigator();
|
|
|
|
const ContactStackScreen = () => {
|
|
|
|
return (
|
|
|
|
<ContactStack.Navigator screenOptions={({ route }) => ({ headerShown: false })}>
|
2022-09-19 00:04:17 +00:00
|
|
|
<ContactStack.Screen name="cards" component={ContactsTabScreen} />
|
|
|
|
<ContactStack.Screen name="card" component={ContactTabScreen} />
|
2022-09-17 06:54:57 +00:00
|
|
|
</ContactStack.Navigator>
|
|
|
|
);
|
|
|
|
}
|
2022-09-19 00:04:17 +00:00
|
|
|
const ContactsTabScreen = ({ navigation }) => {
|
|
|
|
return <Cards openContact={(cardId) => openContact(navigation, cardId)} />
|
|
|
|
}
|
|
|
|
const ContactTabScreen = ({ navigation }) => {
|
|
|
|
return <Contact closeContact={() => closeContact(navigation)} />
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// drawered containers
|
|
|
|
|
|
|
|
|
|
|
|
const CardDrawer = createDrawerNavigator();
|
|
|
|
const CardDrawerContent = ({ otherNav, navigation }) => {
|
|
|
|
return (
|
|
|
|
<SafeAreaView><TouchableOpacity onPress={() => otherNav.openDrawer()}><Text>CARD DRAWER</Text></TouchableOpacity></SafeAreaView>
|
|
|
|
)
|
|
|
|
}
|
2022-09-12 22:18:27 +00:00
|
|
|
|
2022-09-19 00:04:17 +00:00
|
|
|
const ContactDrawer = createDrawerNavigator();
|
|
|
|
const ContactDrawerContent = ({ navigation }) => {
|
2022-09-18 06:24:37 +00:00
|
|
|
return (
|
2022-09-19 00:04:17 +00:00
|
|
|
<SafeAreaView><Text>Contact DRAWER</Text></SafeAreaView>
|
2022-09-18 06:24:37 +00:00
|
|
|
)
|
|
|
|
}
|
2022-09-19 00:04:17 +00:00
|
|
|
const HomeScreen = ({ otherNav, navigation }) => {
|
2022-09-18 06:24:37 +00:00
|
|
|
return (
|
|
|
|
<SafeAreaView>
|
|
|
|
<TouchableOpacity onPress={() => navigation.openDrawer()}>
|
|
|
|
<Text>OPEN</Text>
|
|
|
|
</TouchableOpacity>
|
2022-09-19 00:04:17 +00:00
|
|
|
<TouchableOpacity onPress={() => otherNav.openDrawer()}>
|
|
|
|
<Text>OTHER</Text>
|
|
|
|
</TouchableOpacity>
|
2022-09-18 06:24:37 +00:00
|
|
|
</SafeAreaView>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-09-19 00:04:17 +00:00
|
|
|
const CardDrawerScreen = ({ navigation }) => {
|
|
|
|
return (
|
|
|
|
<CardDrawer.Navigator screenOptions={{
|
|
|
|
drawerPosition: 'right',
|
|
|
|
headerShown: false,
|
|
|
|
swipeEnabled: false,
|
|
|
|
drawerType: 'front',
|
|
|
|
drawerStyle: {
|
|
|
|
width: state.cardWidth,
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
drawerContent={(props) => <CardDrawerContent otherNav={navigation} {...props} />}>
|
|
|
|
<CardDrawer.Screen name="Root">
|
|
|
|
{(props) => <HomeScreen otherNav={navigation} {...props} />}
|
|
|
|
</CardDrawer.Screen>
|
|
|
|
</CardDrawer.Navigator>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-09-12 22:18:27 +00:00
|
|
|
return (
|
2022-09-16 22:00:29 +00:00
|
|
|
<SafeAreaProvider>
|
|
|
|
<NavigationContainer>
|
2022-09-18 06:24:37 +00:00
|
|
|
{ state.tabbed === false && (
|
2022-09-19 00:04:17 +00:00
|
|
|
<ContactDrawer.Navigator
|
|
|
|
screenOptions={{
|
2022-09-18 06:24:37 +00:00
|
|
|
headerShown: false,
|
|
|
|
swipeEnabled: false,
|
|
|
|
drawerType: 'front',
|
|
|
|
drawerPosition: 'right',
|
2022-09-19 00:04:17 +00:00
|
|
|
drawerStyle: {
|
|
|
|
width: state.profileWidth,
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
drawerContent={(props) => <ContactDrawerContent {...props} />}>
|
|
|
|
<ContactDrawer.Screen name="Home" component={CardDrawerScreen} />
|
|
|
|
</ContactDrawer.Navigator>
|
2022-09-18 06:24:37 +00:00
|
|
|
)}
|
|
|
|
{ state.tabbed === true && (
|
2022-09-17 07:22:12 +00:00
|
|
|
<Tab.Navigator
|
|
|
|
screenOptions={({ route }) => ({
|
|
|
|
tabBarStyle: styles.tabBar,
|
|
|
|
headerShown: false,
|
|
|
|
tabBarIcon: ({ focused, color, size }) => {
|
|
|
|
if (route.name === 'Profile') {
|
|
|
|
return <Ionicons name={'user'} size={size} color={color} />;
|
|
|
|
}
|
|
|
|
if (route.name === 'Conversation') {
|
|
|
|
return <Ionicons name={'message1'} size={size} color={color} />;
|
|
|
|
}
|
|
|
|
if (route.name === 'Contacts') {
|
|
|
|
return <Ionicons name={'contacts'} size={size} color={color} />;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tabBarShowLabel: false,
|
|
|
|
tabBarActiveTintColor: Colors.white,
|
|
|
|
tabBarInactiveTintColor: Colors.disabled,
|
2022-09-18 06:24:37 +00:00
|
|
|
})}>
|
2022-09-17 07:22:12 +00:00
|
|
|
<Tab.Screen name="Conversation" component={ConversationStackScreen} />
|
|
|
|
<Tab.Screen name="Profile" component={ProfileStackScreen} />
|
|
|
|
<Tab.Screen name="Contacts" component={ContactStackScreen} />
|
|
|
|
</Tab.Navigator>
|
|
|
|
)}
|
2022-09-16 22:00:29 +00:00
|
|
|
</NavigationContainer>
|
|
|
|
</SafeAreaProvider>
|
2022-09-12 22:18:27 +00:00
|
|
|
);
|
2022-09-07 07:32:06 +00:00
|
|
|
}
|
|
|
|
|
2022-09-16 20:06:52 +00:00
|
|
|
|