adding close button to contact screen

This commit is contained in:
balzack 2022-09-24 23:15:58 -07:00
parent 7f0f9240e1
commit 559c5f7d27
3 changed files with 26 additions and 0 deletions

View File

@ -14,6 +14,13 @@ export function Contact({ contact, closeContact }) {
return (
<ScrollView>
<SafeAreaView style={styles.container} edges={['top', 'bottom', 'right']}>
{ state.tabbed && (
<View style={styles.close}>
<TouchableOpacity onPress={closeContact}>
<Ionicons name={'close'} size={24} color={Colors.text} />
</TouchableOpacity>
</View>
)}
<View style={styles.header}>
<Text style={styles.headerText}>{ `${state.handle}@${state.node}` }</Text>
</View>

View File

@ -11,6 +11,12 @@ export const styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
close: {
width: '100%',
display: 'flex',
alignItems: 'flex-end',
paddingRight: 32,
},
header: {
paddingBottom: 32,
paddingTop: 16,

View File

@ -1,10 +1,13 @@
import { useState, useEffect, useRef, useContext } from 'react';
import { useNavigate } from 'react-router-dom';
import { CardContext } from 'context/CardContext';
import { useWindowDimensions } from 'react-native'
import config from 'constants/Config';
export function useContact(contact) {
const [state, setState] = useState({
tabbed: null,
name: null,
handle: null,
node: null,
@ -14,12 +17,22 @@ export function useContact(contact) {
status: null,
});
const dimensions = useWindowDimensions();
const card = useContext(CardContext);
const updateState = (value) => {
setState((s) => ({ ...s, ...value }));
}
useEffect(() => {
if (dimensions.width > config.tabbedWidth) {
updateState({ tabbed: false });
}
else {
updateState({ tabbed: true });
}
}, [dimensions]);
useEffect(() => {
let stateSet = false;
if (contact?.card) {