mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
show selected participants when clicking on add button
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
c3ebeebcb0
commit
b9e9d0ccd1
@ -31,6 +31,7 @@ fun ContactsScreen(contactsViewModel: ContactsViewModel, uiState: ContactsUiStat
|
|||||||
val autocompleteUsers by contactsViewModel.selectedParticipantsList.collectAsStateWithLifecycle()
|
val autocompleteUsers by contactsViewModel.selectedParticipantsList.collectAsStateWithLifecycle()
|
||||||
val enableAddButton by contactsViewModel.enableAddButton.collectAsStateWithLifecycle()
|
val enableAddButton by contactsViewModel.enableAddButton.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
AppBar(
|
AppBar(
|
||||||
@ -51,7 +52,10 @@ fun ContactsScreen(contactsViewModel: ContactsViewModel, uiState: ContactsUiStat
|
|||||||
onUpdateAutocompleteUsers = {
|
onUpdateAutocompleteUsers = {
|
||||||
contactsViewModel.getContactsFromSearchParams()
|
contactsViewModel.getContactsFromSearchParams()
|
||||||
},
|
},
|
||||||
enableAddButton = enableAddButton
|
enableAddButton = enableAddButton,
|
||||||
|
clickAddButton = {
|
||||||
|
contactsViewModel.modifyClickAddButton(it)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
content = {
|
content = {
|
||||||
|
@ -41,6 +41,8 @@ class ContactsViewModel @Inject constructor(
|
|||||||
|
|
||||||
private val _selectedContacts = MutableStateFlow<List<AutocompleteUser>>(emptyList())
|
private val _selectedContacts = MutableStateFlow<List<AutocompleteUser>>(emptyList())
|
||||||
|
|
||||||
|
private val _clickAddButton = MutableStateFlow(false)
|
||||||
|
|
||||||
private var hideAlreadyAddedParticipants: Boolean = false
|
private var hideAlreadyAddedParticipants: Boolean = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -51,6 +53,10 @@ class ContactsViewModel @Inject constructor(
|
|||||||
_searchQuery.value = query
|
_searchQuery.value = query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun modifyClickAddButton(value:Boolean){
|
||||||
|
_clickAddButton.value = value
|
||||||
|
}
|
||||||
|
|
||||||
fun selectContact(contact: AutocompleteUser) {
|
fun selectContact(contact: AutocompleteUser) {
|
||||||
val updatedParticipants = selectedParticipants.value + contact
|
val updatedParticipants = selectedParticipants.value + contact
|
||||||
selectedParticipants.value = updatedParticipants
|
selectedParticipants.value = updatedParticipants
|
||||||
@ -101,10 +107,9 @@ class ContactsViewModel @Inject constructor(
|
|||||||
)
|
)
|
||||||
val contactsList: MutableList<AutocompleteUser>? = contacts.ocs!!.data?.toMutableList()
|
val contactsList: MutableList<AutocompleteUser>? = contacts.ocs!!.data?.toMutableList()
|
||||||
|
|
||||||
if (hideAlreadyAddedParticipants) {
|
if (hideAlreadyAddedParticipants && !_clickAddButton.value) {
|
||||||
contactsList?.removeAll(selectedParticipants.value)
|
contactsList?.removeAll(selectedParticipants.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
_contactsViewState.value = ContactsUiState.Success(contactsList)
|
_contactsViewState.value = ContactsUiState.Success(contactsList)
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
_contactsViewState.value = ContactsUiState.Error(exception.message ?: "")
|
_contactsViewState.value = ContactsUiState.Error(exception.message ?: "")
|
||||||
|
@ -43,7 +43,8 @@ fun AppBar(
|
|||||||
onDisableSearch: () -> Unit,
|
onDisableSearch: () -> Unit,
|
||||||
onUpdateSearchQuery: (String) -> Unit,
|
onUpdateSearchQuery: (String) -> Unit,
|
||||||
onUpdateAutocompleteUsers: () -> Unit,
|
onUpdateAutocompleteUsers: () -> Unit,
|
||||||
enableAddButton: Boolean
|
enableAddButton: Boolean,
|
||||||
|
clickAddButton:(Boolean) -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
@ -97,6 +98,7 @@ fun AppBar(
|
|||||||
onClick = {
|
onClick = {
|
||||||
onDisableSearch()
|
onDisableSearch()
|
||||||
onUpdateSearchQuery("")
|
onUpdateSearchQuery("")
|
||||||
|
clickAddButton(true)
|
||||||
onUpdateAutocompleteUsers()
|
onUpdateAutocompleteUsers()
|
||||||
},
|
},
|
||||||
enabled = enableAddButton
|
enabled = enableAddButton
|
||||||
|
Loading…
Reference in New Issue
Block a user