mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-18 19:19:33 +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 enableAddButton by contactsViewModel.enableAddButton.collectAsStateWithLifecycle()
|
||||
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
AppBar(
|
||||
@ -51,7 +52,10 @@ fun ContactsScreen(contactsViewModel: ContactsViewModel, uiState: ContactsUiStat
|
||||
onUpdateAutocompleteUsers = {
|
||||
contactsViewModel.getContactsFromSearchParams()
|
||||
},
|
||||
enableAddButton = enableAddButton
|
||||
enableAddButton = enableAddButton,
|
||||
clickAddButton = {
|
||||
contactsViewModel.modifyClickAddButton(it)
|
||||
}
|
||||
)
|
||||
},
|
||||
content = {
|
||||
|
@ -41,6 +41,8 @@ class ContactsViewModel @Inject constructor(
|
||||
|
||||
private val _selectedContacts = MutableStateFlow<List<AutocompleteUser>>(emptyList())
|
||||
|
||||
private val _clickAddButton = MutableStateFlow(false)
|
||||
|
||||
private var hideAlreadyAddedParticipants: Boolean = false
|
||||
|
||||
init {
|
||||
@ -51,6 +53,10 @@ class ContactsViewModel @Inject constructor(
|
||||
_searchQuery.value = query
|
||||
}
|
||||
|
||||
fun modifyClickAddButton(value:Boolean){
|
||||
_clickAddButton.value = value
|
||||
}
|
||||
|
||||
fun selectContact(contact: AutocompleteUser) {
|
||||
val updatedParticipants = selectedParticipants.value + contact
|
||||
selectedParticipants.value = updatedParticipants
|
||||
@ -101,10 +107,9 @@ class ContactsViewModel @Inject constructor(
|
||||
)
|
||||
val contactsList: MutableList<AutocompleteUser>? = contacts.ocs!!.data?.toMutableList()
|
||||
|
||||
if (hideAlreadyAddedParticipants) {
|
||||
if (hideAlreadyAddedParticipants && !_clickAddButton.value) {
|
||||
contactsList?.removeAll(selectedParticipants.value)
|
||||
}
|
||||
|
||||
_contactsViewState.value = ContactsUiState.Success(contactsList)
|
||||
} catch (exception: Exception) {
|
||||
_contactsViewState.value = ContactsUiState.Error(exception.message ?: "")
|
||||
|
@ -43,7 +43,8 @@ fun AppBar(
|
||||
onDisableSearch: () -> Unit,
|
||||
onUpdateSearchQuery: (String) -> Unit,
|
||||
onUpdateAutocompleteUsers: () -> Unit,
|
||||
enableAddButton: Boolean
|
||||
enableAddButton: Boolean,
|
||||
clickAddButton:(Boolean) -> Unit
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
|
||||
@ -97,6 +98,7 @@ fun AppBar(
|
||||
onClick = {
|
||||
onDisableSearch()
|
||||
onUpdateSearchQuery("")
|
||||
clickAddButton(true)
|
||||
onUpdateAutocompleteUsers()
|
||||
},
|
||||
enabled = enableAddButton
|
||||
|
Loading…
Reference in New Issue
Block a user