added status message to registry screen

This commit is contained in:
Roland Osborne 2022-10-28 12:31:54 -07:00
parent 8484b4212e
commit 493621e7ed
3 changed files with 52 additions and 19 deletions

View File

@ -55,11 +55,20 @@ export function RegistryTitle({ state, actions }) {
export function RegistryBody({ state, actions, openContact }) { export function RegistryBody({ state, actions, openContact }) {
return ( return (
<FlatList style={styles.accounts} <View style={styles.accounts}>
data={state.accounts} { state.accounts.length === 0 && state.searcheg && (
renderItem={({ item }) => <RegistryItem item={item} openContact={openContact} />} <View style={styles.empty}>
keyExtractor={item => item.guid} <Text style={styles.emptyText}>No Contacts Found</Text>
/> </View>
)}
{ state.accounts.length !== 0 && (
<FlatList
data={state.accounts}
renderItem={({ item }) => <RegistryItem item={item} openContact={openContact} />}
keyExtractor={item => item.guid}
/>
)}
</View>
); );
} }
@ -104,11 +113,18 @@ export function Registry({ closeRegistry, openContact }) {
<Ionicons name={'close'} size={24} color={Colors.text} /> <Ionicons name={'close'} size={24} color={Colors.text} />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<FlatList style={styles.accounts} { state.accounts.length === 0 && state.searched && (
data={state.accounts} <View style={styles.empty}>
renderItem={({ item }) => <RegistryItem item={item} openContact={openContact} />} <Text style={styles.emptyText}>No Contacts Found</Text>
keyExtractor={item => item.guid} </View>
/> )}
{ state.accounts.length !== 0 && (
<FlatList style={styles.accounts}
data={state.accounts}
renderItem={({ item }) => <RegistryItem item={item} openContact={openContact} />}
keyExtractor={item => item.guid}
/>
)}
</> </>
)} )}
{ !state.tabbed && ( { !state.tabbed && (
@ -134,11 +150,18 @@ export function Registry({ closeRegistry, openContact }) {
</SafeAreaView> </SafeAreaView>
</View> </View>
<SafeAreaView edges={['right']}> <SafeAreaView edges={['right']}>
<FlatList style={styles.accounts} { state.accounts.length === 0 && state.searched && (
data={state.accounts} <View style={style.empty}>
renderItem={({ item }) => <RegistryItem item={item} openContact={openContact} />} <Text style={styles.emptyText}>No Contacts Found</Text>
keyExtractor={item => item.guid} </View>
/> )}
{ state.accounts.length !== 0 && (
<FlatList style={styles.accounts}
data={state.accounts}
renderItem={({ item }) => <RegistryItem item={item} openContact={openContact} />}
keyExtractor={item => item.guid}
/>
)}
</SafeAreaView> </SafeAreaView>
</> </>
)} )}

View File

@ -79,9 +79,19 @@ export const styles = StyleSheet.create({
flexShrink: 1, flexShrink: 1,
width: '100%', width: '100%',
paddingLeft: 16, paddingLeft: 16,
paddingRight: 16,
minHeight: 0, minHeight: 0,
}, },
empty: {
flexGrow: 1,
width: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
emptyText: {
color: Colors.grey,
fontSize: 16,
},
addbottom: { addbottom: {
marginRight: 8, marginRight: 8,
display: 'flex', display: 'flex',

View File

@ -14,6 +14,7 @@ export function useRegistry() {
server: null, server: null,
filter: false, filter: false,
username: null, username: null,
searched: false,
busy: false, busy: false,
}); });
@ -63,8 +64,7 @@ export function useRegistry() {
return true; return true;
}); });
const items = filtered.map(setAccountItem); const items = filtered.map(setAccountItem);
items.push({guid:''}); updateState({ busy: false, searched: true, accounts: items });
updateState({ busy: false, accounts: items });
} }
catch (err) { catch (err) {
console.log(err); console.log(err);
@ -78,7 +78,7 @@ export function useRegistry() {
const actions = { const actions = {
setServer: (server) => { setServer: (server) => {
updateState({ server, accounts: [] }); updateState({ server, searched: false, accounts: [] });
}, },
search: async () => { search: async () => {
await getAccounts(state.server, false); await getAccounts(state.server, false);