mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-25 02:05:40 +00:00
android, desktop: align address and requests UI (#6024)
* android, desktop: align address and requests UI * align business * align accept * cleanup imports
This commit is contained in:
@@ -461,7 +461,7 @@ struct UserAddressSettingsView: View {
|
||||
}
|
||||
|
||||
// TODO v6.4.1 move auto-reply editor here
|
||||
messageEditor(placeholder: NSLocalizedString("Enter welcome message… (optional)", comment: "placeholder"), text: $settings.autoReply)
|
||||
// messageEditor(placeholder: NSLocalizedString("Enter welcome message… (optional)", comment: "placeholder"), text: $settings.autoReply)
|
||||
|
||||
if settings.autoAccept {
|
||||
autoAcceptSection()
|
||||
|
||||
+52
-48
@@ -1,6 +1,7 @@
|
||||
package chat.simplex.common.views.chat
|
||||
|
||||
import SectionItemView
|
||||
import TextIconSpaced
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
@@ -16,6 +17,7 @@ import chat.simplex.common.views.chatlist.acceptContactRequest
|
||||
import chat.simplex.common.views.chatlist.rejectContactRequest
|
||||
import chat.simplex.common.views.helpers.*
|
||||
import chat.simplex.res.MR
|
||||
import dev.icerock.moko.resources.compose.painterResource
|
||||
import dev.icerock.moko.resources.compose.stringResource
|
||||
|
||||
@Composable
|
||||
@@ -35,7 +37,7 @@ fun ComposeContextContactRequestActionsView(
|
||||
.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly,
|
||||
) {
|
||||
Column(
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.fillMaxHeight()
|
||||
@@ -43,23 +45,39 @@ fun ComposeContextContactRequestActionsView(
|
||||
.clickable {
|
||||
showRejectRequestAlert(rhId, contactRequestId)
|
||||
},
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.Center
|
||||
) {
|
||||
Icon(
|
||||
painterResource(MR.images.ic_close),
|
||||
contentDescription = null,
|
||||
tint = Color.Red,
|
||||
)
|
||||
TextIconSpaced(false)
|
||||
Text(stringResource(MR.strings.reject_contact_button), color = Color.Red)
|
||||
}
|
||||
|
||||
Column(
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.fillMaxHeight()
|
||||
.weight(1F)
|
||||
.clickable {
|
||||
showAcceptRequestAlert(rhId, contactRequestId)
|
||||
if (chatModel.addressShortLinkDataSet) {
|
||||
acceptContactRequest(rhId, incognito = false, contactRequestId, isCurrentUser = true, chatModel)
|
||||
} else {
|
||||
showAcceptRequestAlert(rhId, contactRequestId)
|
||||
}
|
||||
},
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.Center
|
||||
) {
|
||||
Icon(
|
||||
painterResource(MR.images.ic_check),
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colors.primary,
|
||||
)
|
||||
TextIconSpaced(false)
|
||||
Text(stringResource(MR.strings.accept_contact_button), color = MaterialTheme.colors.primary)
|
||||
}
|
||||
}
|
||||
@@ -81,46 +99,32 @@ fun showRejectRequestAlert(rhId: Long?, contactRequestId: Long) {
|
||||
}
|
||||
|
||||
fun showAcceptRequestAlert(rhId: Long?, contactRequestId: Long) {
|
||||
// Show 2 buttons in a row
|
||||
if (chatModel.addressShortLinkDataSet) {
|
||||
AlertManager.shared.showAlertDialog(
|
||||
title = generalGetString(MR.strings.accept_contact_request),
|
||||
confirmText = generalGetString(MR.strings.accept_contact_button),
|
||||
onConfirm = {
|
||||
AlertManager.shared.hideAlert()
|
||||
acceptContactRequest(rhId, incognito = false, contactRequestId, isCurrentUser = true, chatModel)
|
||||
},
|
||||
hostDevice = hostDevice(rhId),
|
||||
)
|
||||
// Show 3 buttons in a column
|
||||
} else {
|
||||
AlertManager.shared.showAlertDialogButtonsColumn(
|
||||
title = generalGetString(MR.strings.accept_contact_request),
|
||||
buttons = {
|
||||
Column {
|
||||
// Accept
|
||||
SectionItemView({
|
||||
AlertManager.shared.hideAlert()
|
||||
acceptContactRequest(rhId, incognito = false, contactRequestId, isCurrentUser = true, chatModel)
|
||||
}) {
|
||||
Text(generalGetString(MR.strings.accept_contact_button), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.primary)
|
||||
}
|
||||
// Accept incognito
|
||||
SectionItemView({
|
||||
AlertManager.shared.hideAlert()
|
||||
acceptContactRequest(rhId, incognito = true, contactRequestId, isCurrentUser = true, chatModel)
|
||||
}) {
|
||||
Text(generalGetString(MR.strings.accept_contact_incognito_button), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.primary)
|
||||
}
|
||||
// Cancel
|
||||
SectionItemView({
|
||||
AlertManager.shared.hideAlert()
|
||||
}) {
|
||||
Text(stringResource(MR.strings.cancel_verb), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.primary)
|
||||
}
|
||||
AlertManager.shared.showAlertDialogButtonsColumn(
|
||||
title = generalGetString(MR.strings.accept_contact_request),
|
||||
buttons = {
|
||||
Column {
|
||||
// Accept
|
||||
SectionItemView({
|
||||
AlertManager.shared.hideAlert()
|
||||
acceptContactRequest(rhId, incognito = false, contactRequestId, isCurrentUser = true, chatModel)
|
||||
}) {
|
||||
Text(generalGetString(MR.strings.accept_contact_button), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.primary)
|
||||
}
|
||||
},
|
||||
hostDevice = hostDevice(rhId),
|
||||
)
|
||||
}
|
||||
// Accept incognito
|
||||
SectionItemView({
|
||||
AlertManager.shared.hideAlert()
|
||||
acceptContactRequest(rhId, incognito = true, contactRequestId, isCurrentUser = true, chatModel)
|
||||
}) {
|
||||
Text(generalGetString(MR.strings.accept_contact_incognito_button), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.primary)
|
||||
}
|
||||
// Cancel
|
||||
SectionItemView({
|
||||
AlertManager.shared.hideAlert()
|
||||
}) {
|
||||
Text(stringResource(MR.strings.cancel_verb), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.primary)
|
||||
}
|
||||
}
|
||||
},
|
||||
hostDevice = hostDevice(rhId),
|
||||
)
|
||||
}
|
||||
|
||||
+4
-5
@@ -549,8 +549,7 @@ fun ComposeView(
|
||||
}
|
||||
}
|
||||
|
||||
// TODO [short links] different messages for business
|
||||
fun showSendConnectPreparedContactAlert(sendConnect: () -> Unit) {
|
||||
fun showSendConnectPreparedContactAlert() {
|
||||
val empty = composeState.value.whitespaceOnly
|
||||
AlertManager.shared.showAlertDialogStacked(
|
||||
title = generalGetString(MR.strings.compose_view_send_contact_request_alert_question),
|
||||
@@ -561,7 +560,7 @@ fun ComposeView(
|
||||
else
|
||||
generalGetString(MR.strings.compose_view_send_request)
|
||||
),
|
||||
onConfirm = { sendConnect() },
|
||||
onConfirm = { withApi { sendConnectPreparedContact() } },
|
||||
dismissText = (
|
||||
if (empty)
|
||||
generalGetString(MR.strings.compose_view_add_message)
|
||||
@@ -1405,7 +1404,7 @@ fun ComposeView(
|
||||
SendContactRequestView(
|
||||
disableSendButton = disableSendButton,
|
||||
icon = MR.images.ic_work_filled,
|
||||
sendRequest = { showSendConnectPreparedContactAlert(sendConnect = { withApi { connectPreparedGroup() } }) }
|
||||
sendRequest = { withApi { connectPreparedGroup() } }
|
||||
)
|
||||
}
|
||||
} else if (nextSendGrpInv.value) {
|
||||
@@ -1436,7 +1435,7 @@ fun ComposeView(
|
||||
SendContactRequestView(
|
||||
disableSendButton = disableSendButton,
|
||||
icon = MR.images.ic_person_add_filled,
|
||||
sendRequest = { showSendConnectPreparedContactAlert(sendConnect = { withApi { sendConnectPreparedContact() } }) }
|
||||
sendRequest = { showSendConnectPreparedContactAlert() }
|
||||
)
|
||||
}
|
||||
} else if (
|
||||
|
||||
+16
-18
@@ -396,16 +396,19 @@ private fun ModalData.UserAddressSettings(
|
||||
SectionView {
|
||||
ShareWithContactsButton(shareViaProfile, setProfileAddress)
|
||||
AutoAcceptToggle(addressSettingsState) { saveAddressSettings(addressSettingsState.value, savedAddressSettingsState) }
|
||||
if (!chatModel.addressShortLinkDataSet && !addressSettingsState.value.businessAddress) {
|
||||
AcceptIncognitoToggle(addressSettingsState)
|
||||
}
|
||||
}
|
||||
SectionDividerSpaced()
|
||||
|
||||
SectionView(stringResource(MR.strings.address_welcome_message).uppercase()) {
|
||||
AutoReplyEditor(addressSettingsState)
|
||||
// TODO v6.4.1 move auto-reply editor here
|
||||
// SectionView(stringResource(MR.strings.address_welcome_message).uppercase()) {
|
||||
// AutoReplyEditor(addressSettingsState)
|
||||
// }
|
||||
// SectionDividerSpaced(maxTopPadding = true, maxBottomPadding = false)
|
||||
|
||||
if (addressSettingsState.value.autoAccept) {
|
||||
AutoAcceptSection(addressSettingsState = addressSettingsState)
|
||||
SectionDividerSpaced(maxTopPadding = true, maxBottomPadding = false)
|
||||
}
|
||||
SectionDividerSpaced(maxTopPadding = true, maxBottomPadding = false)
|
||||
|
||||
saveAddressSettingsButton(addressSettingsState.value == savedAddressSettingsState.value) {
|
||||
saveAddressSettings(addressSettingsState.value, savedAddressSettingsState)
|
||||
@@ -492,15 +495,15 @@ private fun AutoAcceptToggle(addressSettingsState: MutableState<AddressSettingsS
|
||||
AddressSettingsState(
|
||||
businessAddress = addressSettingsState.value.businessAddress,
|
||||
autoAccept = true,
|
||||
autoAcceptIncognito = addressSettingsState.value.autoAcceptIncognito,
|
||||
autoReply = addressSettingsState.value.autoReply
|
||||
autoAcceptIncognito = false,
|
||||
autoReply = ""
|
||||
)
|
||||
else
|
||||
AddressSettingsState(
|
||||
businessAddress = false,
|
||||
autoAccept = false,
|
||||
autoAcceptIncognito = addressSettingsState.value.autoAcceptIncognito,
|
||||
autoReply = addressSettingsState.value.autoReply
|
||||
autoAcceptIncognito = false,
|
||||
autoReply = ""
|
||||
)
|
||||
saveAddressSettings(addressSettingsState.value)
|
||||
}
|
||||
@@ -570,19 +573,14 @@ private class AddressSettingsState {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AutoAcceptSection(
|
||||
addressSettingsState: MutableState<AddressSettingsState>,
|
||||
savedAddressSettingsStatee: MutableState<AddressSettingsState>,
|
||||
saveAddressSettings: (AddressSettingsState, MutableState<AddressSettingsState>) -> Unit
|
||||
) {
|
||||
private fun AutoAcceptSection(addressSettingsState: MutableState<AddressSettingsState>) {
|
||||
SectionView(stringResource(MR.strings.auto_accept_contact).uppercase()) {
|
||||
if (!chatModel.addressShortLinkDataSet && !addressSettingsState.value.businessAddress) {
|
||||
AcceptIncognitoToggle(addressSettingsState)
|
||||
}
|
||||
// TODO v6.4.1 show this message editor even with auto-accept disabled
|
||||
AutoReplyEditor(addressSettingsState)
|
||||
saveAddressSettingsButton(addressSettingsState.value == savedAddressSettingsStatee.value) {
|
||||
saveAddressSettings(addressSettingsState.value, savedAddressSettingsStatee)
|
||||
}
|
||||
SectionTextFooter(stringResource(MR.strings.sent_to_your_contact_after_connection))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1071,6 +1071,7 @@
|
||||
<string name="stop_sharing_address">Stop sharing address?</string>
|
||||
<string name="stop_sharing">Stop sharing</string>
|
||||
<string name="auto_accept_contact">Auto-accept</string>
|
||||
<string name="sent_to_your_contact_after_connection">Sent to your contact after connection.</string>
|
||||
<string name="address_welcome_message">Welcome message</string>
|
||||
<string name="enter_welcome_message_optional">Enter welcome message… (optional)</string>
|
||||
<string name="save_settings_question">Save settings?</string>
|
||||
|
||||
Reference in New Issue
Block a user