From 3efa83f1c6beaea7f499d48a11cc85946ec2caff Mon Sep 17 00:00:00 2001 From: balzack Date: Sat, 25 Feb 2023 16:48:05 -0800 Subject: [PATCH] merging back channels screen in mobile app --- app/mobile/src/session/Session.jsx | 6 +- app/mobile/src/session/channels/Channels.jsx | 65 ++++++++++++--- .../src/session/channels/Channels.styled.js | 79 +++++++++++++++++++ .../src/session/channels/useChannels.hook.js | 13 ++- 4 files changed, 147 insertions(+), 16 deletions(-) create mode 100644 app/mobile/src/session/channels/Channels.styled.js diff --git a/app/mobile/src/session/Session.jsx b/app/mobile/src/session/Session.jsx index 339b64ac..06effb2f 100644 --- a/app/mobile/src/session/Session.jsx +++ b/app/mobile/src/session/Session.jsx @@ -16,7 +16,7 @@ import { ContactHeader, ContactBody, Contact } from './contact/Contact'; import { Details, DetailsHeader, DetailsBody } from './details/Details'; import { Conversation, ConversationHeader, ConversationBody } from './conversation/Conversation'; import { Welcome } from './welcome/Welcome'; -import { ChannelsTitle, ChannelsBody, Channels } from './channels/Channels'; +import { Channels } from './channels/Channels'; import { CommonActions } from '@react-navigation/native'; import { ConversationContext } from 'context/ConversationContext'; import { ProfileContext } from 'context/ProfileContext'; @@ -65,8 +65,8 @@ export function Session() { screenOptions={({ route }) => (screenParams)} screenListeners={{ state: (e) => { if (e?.data?.state?.index === 0) { conversation.actions.clearConversation() }} }}> - }}> - {(props) => setConversation(props.navigation, cardId, channelId)} />} + + {(props) => setConversation(props.navigation, cardId, channelId)} />} }}> diff --git a/app/mobile/src/session/channels/Channels.jsx b/app/mobile/src/session/channels/Channels.jsx index 5f75d0a3..08478e92 100644 --- a/app/mobile/src/session/channels/Channels.jsx +++ b/app/mobile/src/session/channels/Channels.jsx @@ -1,14 +1,57 @@ -import { Text } from 'react-native'; +import { useEffect } from 'react'; +import { View, Text, TextInput, TouchableOpacity } from 'react-native'; +import Ionicons from 'react-native-vector-icons/AntDesign'; +import { styles } from './Channels.styled'; +import { useChannels } from './useChannels.hook'; +import { Colors } from 'constants/Colors'; -export function ChannelsTitle({ state, actions }) { - return ChannelsTitle -} - -export function ChannelsBody({ state, actions, openConversation }) { - return ChannelsBody -} - -export function Channels({ openConversation }) { - return Channels; +export function Channels({ navigation, openConversation }) { + + const { state, actions } = useChannels(); + + useEffect(() => { + if (navigation) { + navigation.setOptions({ + headerTitle: () => ( + + + + + + + + New + + + ), + }); + } + }, [navigation]); + + return ( + + { !navigation && ( + + + + + + + )} + + Channels + + { !navigation && ( + + + + New Topic + + + )} + + ); } diff --git a/app/mobile/src/session/channels/Channels.styled.js b/app/mobile/src/session/channels/Channels.styled.js new file mode 100644 index 00000000..42db3601 --- /dev/null +++ b/app/mobile/src/session/channels/Channels.styled.js @@ -0,0 +1,79 @@ +import { StyleSheet } from 'react-native'; +import { Colors } from 'constants/Colors'; + +export const styles = StyleSheet.create({ + container: { + width: '100%', + height: '100%', + display: 'flex', + flexDirection: 'column', + }, + title: { + display: 'flex', + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'center', + }, + inputwrapper: { + display: 'flex', + flexDirection: 'row', + borderRadius: 4, + backgroundColor: Colors.white, + alignItems: 'center', + flexGrow: 1, + flexShrink: 1, + paddingTop: 4, + paddingBottom: 4, + }, + inputfield: { + flex: 1, + flexGrow: 1, + textAlign: 'center', + padding: 4, + color: Colors.text, + fontSize: 14, + }, + icon: { + paddingLeft: 8, + }, + addbottom: { + backgroundColor: Colors.primary, + display: 'flex', + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'center', + padding: 8, + borderRadius: 4, + }, + addtop: { + backgroundColor: Colors.primary, + marginLeft: 16, + display: 'flex', + flexDirection: 'row', + alignItems: 'center', + padding: 8, + borderRadius: 4, + }, + addtext: { + paddingLeft: 8, + color: Colors.white, + }, + content: { + flexGrow: 1, + }, + columnbottom: { + paddingLeft: 24, + paddingRight: 16, + paddingTop: 8, + borderTopWidth: 1, + borderColor: Colors.divider, + }, + columntop: { + paddingLeft: 24, + paddingRight: 16, + paddingBottom: 8, + borderBottomWidth: 1, + borderColor: Colors.divider, + }, +}); + diff --git a/app/mobile/src/session/channels/useChannels.hook.js b/app/mobile/src/session/channels/useChannels.hook.js index bfd57822..f66d6ec3 100644 --- a/app/mobile/src/session/channels/useChannels.hook.js +++ b/app/mobile/src/session/channels/useChannels.hook.js @@ -1,9 +1,18 @@ import { useState } from 'react'; export function useChannels() { - const [state, setState] = useState({}); + const [state, setState] = useState({ + filter: null, + }); - const actions = {}; + const updateState = (value) => { + setState((s) => ({ ...s, ...value })); + } + + const actions = { + setFilter: () => { + }, + }; return { state, actions }; }