mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
MultiSelect contacts
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
b5f7556b3d
commit
e57c13efed
@ -17,6 +17,7 @@ import androidx.compose.foundation.clickable
|
|||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
@ -41,9 +42,11 @@ import androidx.compose.runtime.getValue
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.res.vectorResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
@ -73,6 +76,17 @@ class ContactsActivityCompose : BaseActivity() {
|
|||||||
contactsViewModel = ViewModelProvider(this, viewModelFactory)[ContactsViewModel::class.java]
|
contactsViewModel = ViewModelProvider(this, viewModelFactory)[ContactsViewModel::class.java]
|
||||||
val isAddParticipants = intent.getBooleanExtra("isAddParticipants", false)
|
val isAddParticipants = intent.getBooleanExtra("isAddParticipants", false)
|
||||||
contactsViewModel.updateIsAddParticipants(isAddParticipants)
|
contactsViewModel.updateIsAddParticipants(isAddParticipants)
|
||||||
|
if (isAddParticipants) {
|
||||||
|
contactsViewModel.updateShareTypes(
|
||||||
|
listOf(
|
||||||
|
ShareType.Group.shareType,
|
||||||
|
ShareType.Email.shareType,
|
||||||
|
ShareType
|
||||||
|
.Circle.shareType
|
||||||
|
)
|
||||||
|
)
|
||||||
|
contactsViewModel.getContactsFromSearchParams()
|
||||||
|
}
|
||||||
setContent {
|
setContent {
|
||||||
val colorScheme = viewThemeUtils.getColorScheme(this)
|
val colorScheme = viewThemeUtils.getColorScheme(this)
|
||||||
val uiState = contactsViewModel.contactsViewState.collectAsState()
|
val uiState = contactsViewModel.contactsViewState.collectAsState()
|
||||||
@ -105,19 +119,32 @@ class ContactsActivityCompose : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ContactItemRow(contact: AutocompleteUser, contactsViewModel: ContactsViewModel, context: Context) {
|
fun ContactItemRow(
|
||||||
|
contact: AutocompleteUser,
|
||||||
|
contactsViewModel: ContactsViewModel,
|
||||||
|
context: Context,
|
||||||
|
selectedContacts: MutableList<String>
|
||||||
|
) {
|
||||||
|
val isSelected = contact.id?.let { it in selectedContacts } ?: false
|
||||||
val roomUiState by contactsViewModel.roomViewState.collectAsState()
|
val roomUiState by contactsViewModel.roomViewState.collectAsState()
|
||||||
|
val isAddParticipants = contactsViewModel.isAddParticipantsView.value
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable {
|
.clickable {
|
||||||
if (!contactsViewModel.isAddParticipantsView.value) {
|
if (!isAddParticipants) {
|
||||||
contactsViewModel.createRoom(
|
contactsViewModel.createRoom(
|
||||||
CompanionClass.ROOM_TYPE_ONE_ONE,
|
CompanionClass.ROOM_TYPE_ONE_ONE,
|
||||||
contact.source!!,
|
contact.source!!,
|
||||||
contact.id!!,
|
contact.id!!,
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
if (isSelected) {
|
||||||
|
selectedContacts.remove(contact.id!!)
|
||||||
|
} else {
|
||||||
|
selectedContacts.add(contact.id!!)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
@ -131,6 +158,17 @@ fun ContactItemRow(contact: AutocompleteUser, contactsViewModel: ContactsViewMod
|
|||||||
modifier = Modifier.size(width = 45.dp, height = 45.dp)
|
modifier = Modifier.size(width = 45.dp, height = 45.dp)
|
||||||
)
|
)
|
||||||
Text(modifier = Modifier.padding(16.dp), text = contact.label!!)
|
Text(modifier = Modifier.padding(16.dp), text = contact.label!!)
|
||||||
|
if (isAddParticipants) {
|
||||||
|
if (isSelected) {
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
Icon(
|
||||||
|
imageVector = ImageVector.vectorResource(id = R.drawable.ic_check_circle),
|
||||||
|
contentDescription = "Selected",
|
||||||
|
tint = Color.Blue,
|
||||||
|
modifier = Modifier.padding(end = 8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
when (roomUiState) {
|
when (roomUiState) {
|
||||||
is RoomUiState.Success -> {
|
is RoomUiState.Success -> {
|
||||||
@ -176,9 +214,17 @@ fun AppBar(title: String, context: Context, contactsViewModel: ContactsViewModel
|
|||||||
}) {
|
}) {
|
||||||
Icon(Icons.Filled.Search, contentDescription = stringResource(R.string.search_icon))
|
Icon(Icons.Filled.Search, contentDescription = stringResource(R.string.search_icon))
|
||||||
}
|
}
|
||||||
|
if (contactsViewModel.isAddParticipantsView.value) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(id = R.string.nc_contacts_done),
|
||||||
|
modifier = Modifier.clickable {
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if (searchState.value) {
|
if (searchState.value) {
|
||||||
|
Row {
|
||||||
DisplaySearch(
|
DisplaySearch(
|
||||||
text = searchQuery,
|
text = searchQuery,
|
||||||
onTextChange = { searchQuery ->
|
onTextChange = { searchQuery ->
|
||||||
@ -187,6 +233,14 @@ fun AppBar(title: String, context: Context, contactsViewModel: ContactsViewModel
|
|||||||
},
|
},
|
||||||
contactsViewModel = contactsViewModel
|
contactsViewModel = contactsViewModel
|
||||||
)
|
)
|
||||||
|
if (contactsViewModel.isAddParticipantsView.value) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(id = R.string.nc_contacts_done),
|
||||||
|
modifier = Modifier.clickable {
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ class ContactsViewModel @Inject constructor(
|
|||||||
_searchState.value = searchState
|
_searchState.value = searchState
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateShareTypes(value: String) {
|
fun updateShareTypes(value: List<String>) {
|
||||||
shareTypes.add(value)
|
shareTypes.addAll(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateIsAddParticipants(value: Boolean) {
|
fun updateIsAddParticipants(value: Boolean) {
|
||||||
|
@ -25,6 +25,8 @@ import androidx.compose.material3.HorizontalDivider
|
|||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.mutableStateListOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
@ -72,6 +74,7 @@ fun ContactsItem(contacts: List<AutocompleteUser>, contactsViewModel: ContactsVi
|
|||||||
}
|
}
|
||||||
).toString()
|
).toString()
|
||||||
}
|
}
|
||||||
|
val selectedContacts = remember { mutableStateListOf<String>() }
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
@ -89,7 +92,12 @@ fun ContactsItem(contacts: List<AutocompleteUser>, contactsViewModel: ContactsVi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
items(contactsForInitial) { contact ->
|
items(contactsForInitial) { contact ->
|
||||||
ContactItemRow(contact = contact, contactsViewModel = contactsViewModel, context = context)
|
ContactItemRow(
|
||||||
|
contact = contact,
|
||||||
|
contactsViewModel = contactsViewModel,
|
||||||
|
context = context,
|
||||||
|
selectedContacts = selectedContacts
|
||||||
|
)
|
||||||
Log.d(CompanionClass.TAG, "Contacts:$contact")
|
Log.d(CompanionClass.TAG, "Contacts:$contact")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import androidx.compose.foundation.text.KeyboardOptions
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Close
|
||||||
import androidx.compose.material3.Button
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
@ -93,10 +92,4 @@ fun DisplaySearch(text: String, onTextChange: (String) -> Unit, contactsViewMode
|
|||||||
),
|
),
|
||||||
maxLines = 1
|
maxLines = 1
|
||||||
)
|
)
|
||||||
if (isAddParticipants.value) {
|
|
||||||
Button(onClick = {
|
|
||||||
}, modifier = Modifier.fillMaxWidth(0.2f)) {
|
|
||||||
Text(text = "Done")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ package com.nextcloud.talk.contacts
|
|||||||
enum class ShareType(val shareType: String) {
|
enum class ShareType(val shareType: String) {
|
||||||
User("0"),
|
User("0"),
|
||||||
Group("1"),
|
Group("1"),
|
||||||
Email(""),
|
Email("4"),
|
||||||
Circle(""),
|
Remote("5"),
|
||||||
Federated("")
|
Circle("7")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user