diff --git a/app/mobile/src/context/useConversationContext.hook.js b/app/mobile/src/context/useConversationContext.hook.js index 0c9fb41c..68430efb 100644 --- a/app/mobile/src/context/useConversationContext.hook.js +++ b/app/mobile/src/context/useConversationContext.hook.js @@ -3,6 +3,7 @@ import { StoreContext } from 'context/StoreContext'; import { CardContext } from 'context/CardContext'; import { ChannelContext } from 'context/ChannelContext'; import { ProfileContext } from 'context/ProfileContext'; +import moment from 'moment'; export function useConversationContext() { const [state, setState] = useState({ @@ -11,6 +12,8 @@ export function useConversationContext() { revision: null, contacts: [], topics: new Map(), + createed: null, + host: null, }); const store = useContext(StoreContext); const card = useContext(CardContext); @@ -208,6 +211,20 @@ export function useConversationContext() { let logo = null; let subject = null; + let timestamp; + const date = new Date(item.detail.created * 1000); + const now = new Date(); + const offset = now.getTime() - date.getTime(); + if(offset < 86400000) { + timestamp = moment(date).format('h:mma'); + } + else if (offset < 31449600000) { + timestamp = moment(date).format('M/DD'); + } + else { + timestamp = moment(date).format('M/DD/YYYY'); + } + if (!item) { updateState({ contacts, logo, subject }); return; @@ -267,7 +284,7 @@ export function useConversationContext() { } } - updateState({ subject, logo, contacts }); + updateState({ subject, logo, contacts, host: item.cardId, created: timestamp }); } useEffect(() => { diff --git a/app/mobile/src/session/Session.jsx b/app/mobile/src/session/Session.jsx index bc6abaa9..2512d2e1 100644 --- a/app/mobile/src/session/Session.jsx +++ b/app/mobile/src/session/Session.jsx @@ -71,6 +71,7 @@ export function Session() { return ( ({ headerShown: true, headerTintColor: Colors.primary })} screenListeners={{ state: (e) => { if (e?.data?.state?.index === 0 && selected) { setSelected(null); }}, }}> ({ headerShow: true, headerTintColor: Colors.primary })}> + ({ headerShow: true, headerTintColor: Colors.primary })} + initialRouteName="cards"> Details +export function DetailsHeader() { + return Topic Settings } export function DetailsBody({ channel, clearConversation }) { + + const { state, actions } = useDetails(); + +console.log(state); + return ( - - CLEAR - + + + + + { state.subject } + { state.mode === 'host' && ( + + )} + + { state.created } + { state.mode } + + ) } @@ -17,15 +36,7 @@ export function Details({ channel, clearConversation }) { return ( DETAILS - { channel && ( - <> - { channel.cardId } - { channel.channelId } - - )} - - CLEAR - + ) } diff --git a/app/mobile/src/session/details/Details.styled.js b/app/mobile/src/session/details/Details.styled.js index 32276520..792b3db6 100644 --- a/app/mobile/src/session/details/Details.styled.js +++ b/app/mobile/src/session/details/Details.styled.js @@ -2,27 +2,34 @@ import { StyleSheet } from 'react-native'; import { Colors } from 'constants/Colors'; export const styles = StyleSheet.create({ - container: { - width: '100%', - height: '100%', - display: 'flex', - flexDirection: 'column', - borderLeftWidth: 1, - borderColor: Colors.divider, - }, - header: { - width: '100%', + details: { display: 'flex', flexDirection: 'row', - borderBottomWidth: 1, - borderColor: Colors.divider, - padding: 8, + justifyContent: 'center', + paddingTop: 16, }, - body: { - width: '100%', + info: { + paddingLeft: 8, + display: 'flex', + flexDirection: 'column', + }, + subject: { + fontSize: 18, + display: 'flex', + flexDirection: 'row', + paddingRight: 8, + color: Colors.text, + }, + created: { + fontSize: 16, + color: Colors.text, + }, + mode: { + fontSize: 16, + color: Colors.text, }, title: { - fontSize: 18, - }, + fontSize: 20, + } }) diff --git a/app/mobile/src/session/details/useDetails.hook.js b/app/mobile/src/session/details/useDetails.hook.js new file mode 100644 index 00000000..49b30e45 --- /dev/null +++ b/app/mobile/src/session/details/useDetails.hook.js @@ -0,0 +1,31 @@ +import { useState, useEffect, useRef, useContext } from 'react'; +import { useNavigate } from 'react-router-dom'; +import { ConversationContext } from 'context/ConversationContext'; + +export function useDetails() { + + const [state, setState] = useState({ + subject: null, + created: null, + logo: null, + mode: null, + }); + + const conversation = useContext(ConversationContext); + const navigate = useNavigate(); + + const updateState = (value) => { + setState((s) => ({ ...s, ...value })); + } + + useEffect(() => { + const { subject, created, logo, host } = conversation.state; + updateState({ subject, created, logo, mode: host ? 'guest' : 'host' }); + }, [conversation]); + + const actions = { + }; + + return { state, actions }; +} +