mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 08:18:27 +00:00
Dialogs do not have a 'x' button by default
This commit is contained in:
parent
af1c39b88c
commit
5061d3724b
@ -79,6 +79,7 @@ internal fun LandingScreen(
|
|||||||
onDismissRequest = { isUrlDialogVisible = false },
|
onDismissRequest = { isUrlDialogVisible = false },
|
||||||
title = stringResource(R.string.urlOpen),
|
title = stringResource(R.string.urlOpen),
|
||||||
text = stringResource(R.string.urlOpenBrowser),
|
text = stringResource(R.string.urlOpenBrowser),
|
||||||
|
showCloseButton = true, // display the 'x' button
|
||||||
buttons = listOf(
|
buttons = listOf(
|
||||||
DialogButtonModel(
|
DialogButtonModel(
|
||||||
text = GetString(R.string.activity_landing_terms_of_service),
|
text = GetString(R.string.activity_landing_terms_of_service),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms.ui
|
package org.thoughtcrime.securesms.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
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.IntrinsicSize
|
import androidx.compose.foundation.layout.IntrinsicSize
|
||||||
@ -20,14 +21,19 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.graphics.RectangleShape
|
import androidx.compose.ui.graphics.RectangleShape
|
||||||
import androidx.compose.ui.graphics.takeOrElse
|
import androidx.compose.ui.graphics.takeOrElse
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalColors
|
import org.thoughtcrime.securesms.ui.theme.LocalColors
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
|
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
|
||||||
|
import org.thoughtcrime.securesms.ui.theme.PreviewTheme
|
||||||
import org.thoughtcrime.securesms.ui.theme.h7
|
import org.thoughtcrime.securesms.ui.theme.h7
|
||||||
import org.thoughtcrime.securesms.ui.theme.large
|
import org.thoughtcrime.securesms.ui.theme.large
|
||||||
import org.thoughtcrime.securesms.ui.theme.largeBold
|
import org.thoughtcrime.securesms.ui.theme.largeBold
|
||||||
|
|
||||||
|
|
||||||
class DialogButtonModel(
|
class DialogButtonModel(
|
||||||
val text: GetString,
|
val text: GetString,
|
||||||
val contentDescription: GetString = text,
|
val contentDescription: GetString = text,
|
||||||
@ -41,8 +47,9 @@ fun AlertDialog(
|
|||||||
onDismissRequest: () -> Unit,
|
onDismissRequest: () -> Unit,
|
||||||
title: String? = null,
|
title: String? = null,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
content: @Composable () -> Unit = {},
|
buttons: List<DialogButtonModel>? = null,
|
||||||
buttons: List<DialogButtonModel>? = null
|
showCloseButton: Boolean = false,
|
||||||
|
content: @Composable () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
androidx.compose.material.AlertDialog(
|
androidx.compose.material.AlertDialog(
|
||||||
onDismissRequest,
|
onDismissRequest,
|
||||||
@ -50,15 +57,18 @@ fun AlertDialog(
|
|||||||
backgroundColor = LocalColors.current.backgroundSecondary,
|
backgroundColor = LocalColors.current.backgroundSecondary,
|
||||||
buttons = {
|
buttons = {
|
||||||
Box {
|
Box {
|
||||||
IconButton(
|
// only show the 'x' button is required
|
||||||
onClick = onDismissRequest,
|
if(showCloseButton) {
|
||||||
modifier = Modifier.align(Alignment.TopEnd)
|
IconButton(
|
||||||
) {
|
onClick = onDismissRequest,
|
||||||
Icon(
|
modifier = Modifier.align(Alignment.TopEnd)
|
||||||
painter = painterResource(id = R.drawable.ic_dialog_x),
|
) {
|
||||||
tint = LocalColors.current.text,
|
Icon(
|
||||||
contentDescription = "back"
|
painter = painterResource(id = R.drawable.ic_dialog_x),
|
||||||
)
|
tint = LocalColors.current.text,
|
||||||
|
contentDescription = "back"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = Modifier.fillMaxWidth()) {
|
Column(modifier = Modifier.fillMaxWidth()) {
|
||||||
@ -129,3 +139,50 @@ fun DialogButton(text: String, modifier: Modifier, color: Color = Color.Unspecif
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
fun PreviewSimpleDialog(){
|
||||||
|
PreviewTheme {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = {},
|
||||||
|
title = stringResource(R.string.warning),
|
||||||
|
text = stringResource(R.string.you_cannot_go_back_further_in_order_to_stop_loading_your_account_session_needs_to_quit),
|
||||||
|
buttons = listOf(
|
||||||
|
DialogButtonModel(
|
||||||
|
GetString(stringResource(R.string.quit)),
|
||||||
|
color = LocalColors.current.danger,
|
||||||
|
onClick = {}
|
||||||
|
),
|
||||||
|
DialogButtonModel(
|
||||||
|
GetString(stringResource(R.string.cancel))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
fun PreviewXCloseDialog(){
|
||||||
|
PreviewTheme {
|
||||||
|
AlertDialog(
|
||||||
|
title = stringResource(R.string.urlOpen),
|
||||||
|
text = stringResource(R.string.urlOpenBrowser),
|
||||||
|
showCloseButton = true, // display the 'x' button
|
||||||
|
buttons = listOf(
|
||||||
|
DialogButtonModel(
|
||||||
|
text = GetString(R.string.activity_landing_terms_of_service),
|
||||||
|
contentDescription = GetString(R.string.AccessibilityId_terms_of_service_button),
|
||||||
|
onClick = {}
|
||||||
|
),
|
||||||
|
DialogButtonModel(
|
||||||
|
text = GetString(R.string.activity_landing_privacy_policy),
|
||||||
|
contentDescription = GetString(R.string.AccessibilityId_privacy_policy_button),
|
||||||
|
onClick = {}
|
||||||
|
)
|
||||||
|
),
|
||||||
|
onDismissRequest = {}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user