diff --git a/app/mobile/src/session/Session.jsx b/app/mobile/src/session/Session.jsx index d373553b..5b3f3063 100644 --- a/app/mobile/src/session/Session.jsx +++ b/app/mobile/src/session/Session.jsx @@ -34,128 +34,134 @@ const CardDrawer = createDrawerNavigator(); const RegistryDrawer = createDrawerNavigator(); const Tab = createBottomTabNavigator(); +function ConversationStackScreen() { + const stackParams = { headerStyle: { backgroundColor: Colors.titleBackground }, headerBackTitleVisible: false }; + const screenParams = { headerShown: true, headerTintColor: Colors.primary }; + + const conversation = useContext(ConversationContext); + const [cardId, setCardId] = useState(); + const [channelId, setChannelId] = useState(); + + const openConversation = (navigation, card, channel) => { + (async () => { + conversation.actions.setConversation(card, channel); + setCardId(card); + setChannelId(channel); + navigation.navigate('conversation'); + })(); + }; + const clearConversation = (navigation) => { + conversation.actions.clearConversation(); + setCardId(null); + setChannelId(null); + navigation.popToTop(); + }; + const closeConversation = () => { + conversation.actions.clearConversation(); + setCardId(null); + setChannelId(null); + } + + const openDetails = (navigation) => { + navigation.navigate('details'); + } + + return ( + + (screenParams)} > + + + {(props) => openConversation(props.navigation, cardId, channelId)} />} + + + + {(props) => openDetails(props.navigation)} closeConversation={(pop) => closeConversation(props.navigation, pop)} /> } + + + ( + Details + )}}> + {(props) =>
clearConversation(props.navigation)} />} + + + + + ); +} + +function ProfileStackScreen() { + const stackParams = { headerStyle: { backgroundColor: Colors.titleBackground }, headerBackTitleVisible: false }; + const screenParams = { headerShown: true, headerTintColor: Colors.primary }; + + return ( + + (screenParams)}> + }}> + {(props) => } + + + + ); +} + +function ContactStackScreen() { + const stackParams = { headerStyle: { backgroundColor: Colors.titleBackground }, headerBackTitleVisible: false }; + const screenParams = { headerShown: true, headerTintColor: Colors.primary }; + + const profile = useContext(ProfileContext); + + const [contact, setContact] = useState(null); + + const [search, setSearch] = useState(null); + const [handle, setHandle] = useState(); + const [server, setServer] = useState(); + + const [filter, setFilter] = useState(); + const [sort, setSort] = useState(false); + + const openContact = (navigation, contact) => { + setContact(contact); + navigation.navigate('contact') + } + const openRegistry = (navigation) => { + setServer(profile.state.identity.node); + setHandle(null); + setSearch(false); + navigation.navigate('registry'); + } + + return ( + + (screenParams)} initialRouteName="cards"> + + ( + + )}}> + {(props) => openContact(props.navigation, contact)} />} + + + ( + + )}}> + {(props) => } + + + ( + + )}}> + {(props) => openContact(props.navigation, contact)} />} + + + + + ); +} + export function Session() { const { state, actions } = useSession(); const drawerParams = { drawerPosition: 'right', headerShown: false, swipeEnabled: false, drawerType: 'front' }; - const stackParams = { headerStyle: { backgroundColor: Colors.titleBackground }, headerBackTitleVisible: false }; - const screenParams = { headerShown: true, headerTintColor: Colors.primary }; - - const ConversationStackScreen = () => { - const conversation = useContext(ConversationContext); - const [cardId, setCardId] = useState(); - const [channelId, setChannelId] = useState(); - -console.log("REnDER CONVERSATION STACK"); - const openConversation = (navigation, card, channel) => { - (async () => { - conversation.actions.setConversation(card, channel); - setCardId(card); - setChannelId(channel); - navigation.navigate('conversation'); - })(); - }; - const clearConversation = (navigation) => { - conversation.actions.clearConversation(); - setCardId(null); - setChannelId(null); - navigation.popToTop(); - }; - const closeConversation = () => { - conversation.actions.clearConversation(); - setCardId(null); - setChannelId(null); - } - - const openDetails = (navigation) => { - navigation.navigate('details'); - } - - return ( - - (screenParams)} > - - - {(props) => openConversation(props.navigation, cardId, channelId)} />} - - - - {(props) => openDetails(props.navigation)} closeConversation={(pop) => closeConversation(props.navigation, pop)} /> } - - - ( - Details - )}}> - {(props) =>
clearConversation(props.navigation)} />} - - - - - ); - } - - const ProfileStackScreen = () => { - return ( - - (screenParams)}> - }}> - {(props) => } - - - - ); - } - - const ContactStackScreen = () => { - const profile = useContext(ProfileContext); - - const [contact, setContact] = useState(null); - - const [search, setSearch] = useState(null); - const [handle, setHandle] = useState(); - const [server, setServer] = useState(); - - const [filter, setFilter] = useState(); - const [sort, setSort] = useState(false); - - const openContact = (navigation, contact) => { - setContact(contact); - navigation.navigate('contact') - } - const openRegistry = (navigation) => { - setServer(profile.state.identity.node); - setHandle(null); - setSearch(false); - navigation.navigate('registry'); - } - - return ( - - (screenParams)} initialRouteName="cards"> - - ( - - )}}> - {(props) => openContact(props.navigation, contact)} />} - - - ( - - )}}> - {(props) => } - - - ( - - )}}> - {(props) => openContact(props.navigation, contact)} />} - - - - - ); - } const HomeScreen = ({ navParams }) => { @@ -304,8 +310,6 @@ console.log("REnDER CONVERSATION STACK"); ); } -console.log("RENDER ROOT", state.tabbed); - return ( diff --git a/app/mobile/src/session/conversation/Conversation.jsx b/app/mobile/src/session/conversation/Conversation.jsx index ba164770..28d7dd58 100644 --- a/app/mobile/src/session/conversation/Conversation.jsx +++ b/app/mobile/src/session/conversation/Conversation.jsx @@ -49,7 +49,6 @@ export function Conversation({ navigation, cardId, channelId, closeConversation, }, [navigation, state.subject, state.loaded]); useEffect(() => { -console.log("RESET CONVERSATION!"); return () => { closeConversation(); }; }, []); diff --git a/app/mobile/src/session/useSession.hook.js b/app/mobile/src/session/useSession.hook.js index 4e039f08..887f7f30 100644 --- a/app/mobile/src/session/useSession.hook.js +++ b/app/mobile/src/session/useSession.hook.js @@ -38,12 +38,10 @@ export function useSession() { if (dimensions.width > config.tabbedWidth) { const width = Math.floor((dimensions.width * 33) / 100); tabbed.current = false; -console.log("SET TABBED: false"); updateState({ tabbed: false, baseWidth: width + 50, subWidth: width }); } else { tabbed.current = true; -console.log("SET TABBED: true"); updateState({ tabbed: true }); } }