From ed10c5b32e1941e117242a4f2ec59f733173f25c Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Wed, 21 Sep 2022 11:12:46 -0700 Subject: [PATCH] making channel screen responsive --- app/mobile/src/session/Session.jsx | 26 +++++------ app/mobile/src/session/Session.styled.js | 7 +++ app/mobile/src/session/channels/Channels.jsx | 37 ++++++++++++--- .../src/session/channels/Channels.styled.js | 46 +++++++++++++++++-- .../src/session/channels/useChannels.hook.js | 13 +++++- 5 files changed, 104 insertions(+), 25 deletions(-) diff --git a/app/mobile/src/session/Session.jsx b/app/mobile/src/session/Session.jsx index 4b7efb77..9d40a0ee 100644 --- a/app/mobile/src/session/Session.jsx +++ b/app/mobile/src/session/Session.jsx @@ -57,9 +57,7 @@ export function Session() { } const ChannelsTabScreen = ({ navigation }) => { return ( - - openConversation(navigation, cardId, channelId)} /> - + openConversation(navigation, cardId, channelId)} /> ) } const ConversationTabScreen = ({ navigation }) => { @@ -135,8 +133,8 @@ export function Session() { const HomeScreen = ({ cardNav, detailNav, contactNav, profileNav }) => { return ( - - + + openProfile(profileNav)}> Profile @@ -145,11 +143,11 @@ export function Session() { Contacts - - + + openConversation(null, cardId, channelId)} /> - - + + { state.conversationId && ( closeConversation(null)} openDetails={() => openDetails(detailNav)} /> @@ -208,7 +206,7 @@ export function Session() { } return ( - <> + { state.tabbed === false && ( }> @@ -237,14 +235,16 @@ export function Session() { tabBarActiveTintColor: Colors.white, tabBarInactiveTintColor: Colors.disabled, })}> - + + {(props) => ()} + - {(props) => ()} + {(props) => ()} )} - + ); } diff --git a/app/mobile/src/session/Session.styled.js b/app/mobile/src/session/Session.styled.js index 6a1814d1..7d8c5d3f 100644 --- a/app/mobile/src/session/Session.styled.js +++ b/app/mobile/src/session/Session.styled.js @@ -2,6 +2,10 @@ import { StyleSheet } from 'react-native'; import { Colors } from 'constants/Colors'; export const styles = StyleSheet.create({ + container: { + width: '100%', + height: '100%', + }, tabBar: { backgroundColor: Colors.primary, }, @@ -26,6 +30,7 @@ export const styles = StyleSheet.create({ flexDirection: 'row', paddingTop: 8, paddingBottom: 4, + paddingRight: 8, }, option: { width: '50%', @@ -40,6 +45,8 @@ export const styles = StyleSheet.create({ }, channels: { flexGrow: 1, + flexShrink: 1, + position: 'relative', }, tabframe: { width: '100%', diff --git a/app/mobile/src/session/channels/Channels.jsx b/app/mobile/src/session/channels/Channels.jsx index bf45de0f..4e1f5ca2 100644 --- a/app/mobile/src/session/channels/Channels.jsx +++ b/app/mobile/src/session/channels/Channels.jsx @@ -4,22 +4,47 @@ import { styles } from './Channels.styled'; import { useChannels } from './useChannels.hook'; import Ionicons from '@expo/vector-icons/AntDesign'; import { ChannelItem } from './channelItem/ChannelItem'; +import Colors from 'constants/Colors'; export function Channels() { const { state, actions } = useChannels(); return ( - - - - - + { state.tabbed && ( + + + + + + + + + New + + + )} + { !state.tabbed && ( + + + + + + + + )} } keyExtractor={item => (`${item.cardId}:${item.channelId}`)} /> + { !state.tabbed && ( + + + New Topic + + )} ); } diff --git a/app/mobile/src/session/channels/Channels.styled.js b/app/mobile/src/session/channels/Channels.styled.js index fbc32e49..44664974 100644 --- a/app/mobile/src/session/channels/Channels.styled.js +++ b/app/mobile/src/session/channels/Channels.styled.js @@ -8,20 +8,33 @@ export const styles = StyleSheet.create({ display: 'flex', flexDirection: 'column', }, + topbar: { + borderTopWidth: 1, + borderBottomWidth: 1, + borderColor: Colors.divider, + paddingTop: 6, + paddingBottom: 6, + paddingLeft: 16, + paddingRight: 16, + display: 'flex', + flexDirection: 'row', + }, + searchbar: { + paddingRight: 8, + }, inputwrapper: { display: 'flex', flexDirection: 'row', borderRadius: 4, - backgroundColor: Colors.background, + backgroundColor: Colors.white, alignItems: 'center', - marginRight: 8, - marginLeft: 8, + flexGrow: 1, }, inputfield: { flex: 1, textAlign: 'center', padding: 4, - color: Colors.white, + color: Colors.text, fontSize: 16, }, icon: { @@ -32,6 +45,29 @@ export const styles = StyleSheet.create({ width: '100%', paddingLeft: 16, paddingRight: 16, - }, + }, + addbottom: { + backgroundColor: Colors.primary, + marginRight: 8, + display: 'flex', + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'center', + padding: 8, + borderRadius: 4, + }, + add: { + backgroundColor: Colors.primary, + marginLeft: 16, + display: 'flex', + flexDirection: 'row', + alignItems: 'center', + padding: 8, + borderRadius: 4, + }, + newtext: { + paddingLeft: 8, + color: Colors.white, + } }) diff --git a/app/mobile/src/session/channels/useChannels.hook.js b/app/mobile/src/session/channels/useChannels.hook.js index b681e903..dda4bf24 100644 --- a/app/mobile/src/session/channels/useChannels.hook.js +++ b/app/mobile/src/session/channels/useChannels.hook.js @@ -11,7 +11,8 @@ export function useChannels() { const [state, setState] = useState({ topic: null, - channels: [] + channels: [], + tabbed: null, }); const items = useRef([]); @@ -19,11 +20,21 @@ export function useChannels() { const card = useContext(CardContext); const profile = useContext(ProfileContext); const app = useContext(AppContext); + const dimensions = useWindowDimensions(); const updateState = (value) => { setState((s) => ({ ...s, ...value })); } + useEffect(() => { + if (dimensions.width > config.tabbedWidth) { + updateState({ tabbed: false }); + } + else { + updateState({ tabbed: true }); + } + }, [dimensions]); + const getCard = (guid) => { let contact = null card.state.cards.forEach((card, cardId, map) => {