mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-13 03:01:05 +00:00
Add change password dialog
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
381804c892
commit
31c0d74356
@ -445,7 +445,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM
|
||||
val isOpenForGuestAppUsers = conversationCreationViewModel.openForGuestAppUsers.value
|
||||
|
||||
val isPasswordSet = conversationCreationViewModel.isPasswordEnabled.value
|
||||
val isPasswordChanged = conversationCreationViewModel.isPasswordChanged.value
|
||||
|
||||
Text(
|
||||
text = stringResource(id = R.string.nc_new_conversation_visibility).uppercase(),
|
||||
@ -463,7 +462,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM
|
||||
}
|
||||
)
|
||||
},
|
||||
showDialog = false,
|
||||
conversationCreationViewModel = conversationCreationViewModel
|
||||
)
|
||||
|
||||
@ -471,7 +469,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM
|
||||
ConversationOptions(
|
||||
icon = R.drawable.ic_lock_grey600_24px,
|
||||
text = R.string.nc_set_password,
|
||||
showDialog = true,
|
||||
conversationCreationViewModel = conversationCreationViewModel
|
||||
)
|
||||
}
|
||||
@ -480,7 +477,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM
|
||||
ConversationOptions(
|
||||
icon = R.drawable.ic_lock_grey600_24px,
|
||||
text = R.string.nc_change_password,
|
||||
showDialog = false,
|
||||
conversationCreationViewModel = conversationCreationViewModel
|
||||
)
|
||||
}
|
||||
@ -496,7 +492,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM
|
||||
}
|
||||
)
|
||||
},
|
||||
showDialog = false,
|
||||
conversationCreationViewModel = conversationCreationViewModel
|
||||
)
|
||||
|
||||
@ -511,7 +506,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM
|
||||
}
|
||||
)
|
||||
},
|
||||
showDialog = false,
|
||||
conversationCreationViewModel = conversationCreationViewModel
|
||||
)
|
||||
}
|
||||
@ -522,19 +516,23 @@ fun ConversationOptions(
|
||||
icon: Int? = null,
|
||||
text: Int,
|
||||
switch: @Composable (() -> Unit)? = null,
|
||||
showDialog: Boolean,
|
||||
conversationCreationViewModel: ConversationCreationViewModel
|
||||
) {
|
||||
var showPasswordDialog by rememberSaveable { mutableStateOf(false) }
|
||||
var showPasswordChangeDialog by rememberSaveable { mutableStateOf(false) }
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 16.dp, end = 16.dp, bottom = 8.dp)
|
||||
.then(
|
||||
if (showDialog) {
|
||||
if (!conversationCreationViewModel.isPasswordEnabled.value) {
|
||||
Modifier.clickable {
|
||||
showPasswordDialog = true
|
||||
}
|
||||
} else if (conversationCreationViewModel.isPasswordEnabled.value) {
|
||||
Modifier.clickable {
|
||||
showPasswordChangeDialog = true
|
||||
}
|
||||
} else {
|
||||
Modifier
|
||||
}
|
||||
@ -565,9 +563,10 @@ fun ConversationOptions(
|
||||
conversationCreationViewModel = conversationCreationViewModel
|
||||
)
|
||||
}
|
||||
if (conversationCreationViewModel.isPasswordChanged.value) {
|
||||
if (showPasswordChangeDialog) {
|
||||
ShowChangePassword(
|
||||
onDismiss = {
|
||||
showPasswordChangeDialog = false
|
||||
},
|
||||
conversationCreationViewModel = conversationCreationViewModel
|
||||
)
|
||||
@ -578,17 +577,15 @@ fun ConversationOptions(
|
||||
@Composable
|
||||
fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: ConversationCreationViewModel) {
|
||||
var changedPassword by rememberSaveable { mutableStateOf("") }
|
||||
Dialog(onDismissRequest = { }) {
|
||||
Dialog(onDismissRequest = {
|
||||
onDismiss()
|
||||
}) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(375.dp)
|
||||
.padding(16.dp)
|
||||
.background(color = colorResource(id = R.color.appbar))
|
||||
.clickable {
|
||||
if (conversationCreationViewModel.isPasswordEnabled.value) {
|
||||
}
|
||||
},
|
||||
.background(color = colorResource(id = R.color.appbar)),
|
||||
shape = RoundedCornerShape(16.dp)
|
||||
) {
|
||||
Column(
|
||||
@ -606,21 +603,32 @@ fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: Con
|
||||
label = { Text(text = stringResource(id = R.string.nc_set_new_password)) },
|
||||
singleLine = true
|
||||
)
|
||||
|
||||
TextButton(
|
||||
onClick = { },
|
||||
modifier = Modifier.padding(8.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.nc_change_password))
|
||||
if (changedPassword.isNotEmpty() && changedPassword.isNotBlank()) {
|
||||
TextButton(
|
||||
onClick = {
|
||||
conversationCreationViewModel.updatePassword(changedPassword)
|
||||
conversationCreationViewModel.isPasswordEnabled.value = true
|
||||
onDismiss()
|
||||
},
|
||||
modifier = Modifier.padding(8.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.nc_change_password))
|
||||
}
|
||||
}
|
||||
TextButton(
|
||||
onClick = { },
|
||||
onClick = {
|
||||
conversationCreationViewModel.isPasswordEnabled.value = true
|
||||
onDismiss()
|
||||
},
|
||||
modifier = Modifier.padding(8.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.nc_remove_password))
|
||||
}
|
||||
TextButton(
|
||||
onClick = { },
|
||||
onClick = {
|
||||
conversationCreationViewModel.isPasswordEnabled.value = true
|
||||
onDismiss()
|
||||
},
|
||||
modifier = Modifier.padding(8.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.nc_cancel))
|
||||
@ -633,18 +641,18 @@ fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: Con
|
||||
@Composable
|
||||
fun ShowPasswordDialog(onDismiss: () -> Unit, conversationCreationViewModel: ConversationCreationViewModel) {
|
||||
var password by rememberSaveable { mutableStateOf("") }
|
||||
|
||||
AlertDialog(
|
||||
containerColor = colorResource(id = R.color.dialog_background),
|
||||
onDismissRequest = onDismiss,
|
||||
confirmButton = {
|
||||
Button(onClick = {
|
||||
if (password.isNotEmpty()) {
|
||||
conversationCreationViewModel.updatePassword(password)
|
||||
conversationCreationViewModel.isPasswordEnabled(true)
|
||||
Button(
|
||||
onClick = {
|
||||
if (password.isNotEmpty() && password.isNotBlank()) {
|
||||
conversationCreationViewModel.updatePassword(password)
|
||||
conversationCreationViewModel.isPasswordEnabled(true)
|
||||
}
|
||||
}
|
||||
onDismiss()
|
||||
}) {
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.save))
|
||||
}
|
||||
},
|
||||
|
@ -41,17 +41,15 @@ class ConversationCreationViewModel @Inject constructor(
|
||||
private val _isPasswordEnabled = mutableStateOf(false)
|
||||
val isPasswordEnabled = _isPasswordEnabled
|
||||
|
||||
private val _isPasswordChanged = mutableStateOf(false)
|
||||
val isPasswordChanged = _isPasswordChanged
|
||||
|
||||
fun updateSelectedParticipants(participants: List<AutocompleteUser>) {
|
||||
_selectedParticipants.value = participants
|
||||
}
|
||||
|
||||
fun isPasswordEnabled(value: Boolean) {
|
||||
isPasswordEnabled.value = value
|
||||
fun updateSelectedImageUri(uri: Uri?) {
|
||||
_selectedImageUri.value = uri
|
||||
}
|
||||
|
||||
private val _roomName = MutableStateFlow("")
|
||||
val roomName: StateFlow<String> = _roomName
|
||||
private val _password = MutableStateFlow("")
|
||||
|
Loading…
Reference in New Issue
Block a user