mirror of
https://github.com/balzack/databag.git
synced 2025-03-13 00:50:03 +00:00
hide base instructions once set
This commit is contained in:
parent
04f9a26621
commit
f120524531
@ -16,13 +16,19 @@ export function Base() {
|
||||
<Text style={styles.title}>Databag</Text>
|
||||
<Text style={styles.description}>{ state.strings.communication }</Text>
|
||||
<Image style={styles.image} source={theme.colors.name == 'light' ? light : dark} resizeMode="contain" />
|
||||
<View style={styles.steps}>
|
||||
<Text style={styles.step}>{ state.strings.setupProfile }</Text>
|
||||
<Icon size={14} source="chevron-right" color={Colors.placeholder} />
|
||||
<Text style={styles.step}>{ state.strings.connectPeople }</Text>
|
||||
<Icon size={14} source="chevron-right" color={Colors.placeholder} />
|
||||
<Text style={styles.step}>{ state.strings.startConversation }</Text>
|
||||
</View>
|
||||
{ (state.profileSet === false || state.cardSet === false || state.channelSet === false) && (
|
||||
<View style={styles.steps}>
|
||||
{ state.profileSet === false && (
|
||||
<Text style={styles.step}>{ state.strings.setupProfile }</Text>
|
||||
)}
|
||||
<Icon size={14} source="chevron-right" color={Colors.placeholder} />
|
||||
{ (state.profileSet === false || state.cardSet === false) && (
|
||||
<Text style={styles.step}>{ state.strings.connectPeople }</Text>
|
||||
)}
|
||||
<Icon size={14} source="chevron-right" color={Colors.placeholder} />
|
||||
<Text style={styles.step}>{ state.strings.startConversation }</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
@ -1,11 +1,16 @@
|
||||
import { useState, useContext, useEffect } from 'react'
|
||||
import { DisplayContext } from '../context/DisplayContext';
|
||||
import { AppContext } from '../context/AppContext';
|
||||
import { ContextType } from '../context/ContextType'
|
||||
|
||||
export function useBase() {
|
||||
const app = useContext(AppContext) as ContextType
|
||||
const display = useContext(DisplayContext) as ContextType
|
||||
const [state, setState] = useState({
|
||||
strings: display.state.strings,
|
||||
profileSet: null as null | boolean,
|
||||
cardSet: null as null | boolean,
|
||||
channelSet: null as null | boolean,
|
||||
})
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@ -13,6 +18,29 @@ export function useBase() {
|
||||
setState((s) => ({ ...s, ...value }))
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const setProfile = (profile: Profile) => {
|
||||
updateState({ profileSet: Boolean(profile.name) });
|
||||
}
|
||||
const setCards = (cards: Card[]) => {
|
||||
updateState({ cardSet: cards.length > 0 });
|
||||
}
|
||||
const setChannels = ({ channels, cardId }: { channels: Channel[]; cardId: string | null }) => {
|
||||
updateState({ channelSet: channels.length > 0 });
|
||||
}
|
||||
|
||||
const { identity, contact, content } = app.state.session
|
||||
identity.addProfileListener(setProfile)
|
||||
contact.addCardListener(setCards)
|
||||
content.addChannelListener(setChannels)
|
||||
|
||||
return () => {
|
||||
identity.removeProfileListener(setProfile);
|
||||
contact.removeCardListener(setCards);
|
||||
content.removeChannelListener(setChannels);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const actions = {
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user