From 9dfaa71a1db9c991991163406206b039b469476e Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Jun 2024 20:02:04 +0930 Subject: [PATCH] Add border() Component --- .../conversation/start/InviteFriendFragment.kt | 17 +++-------------- .../recoverypassword/RecoveryPassword.kt | 11 ++--------- .../securesms/ui/components/Border.kt | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 23 deletions(-) create mode 100644 app/src/main/java/org/thoughtcrime/securesms/ui/components/Border.kt diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/InviteFriendFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/InviteFriendFragment.kt index 0a6d25a69e..b3e7d27cf9 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/InviteFriendFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/InviteFriendFragment.kt @@ -5,27 +5,20 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.compose.foundation.background -import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement.Absolute.spacedBy -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.wrapContentHeight -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp import androidx.fragment.app.Fragment import dagger.hilt.android.AndroidEntryPoint import network.loki.messenger.R @@ -33,15 +26,15 @@ import org.session.libsession.utilities.TextSecurePreferences import org.thoughtcrime.securesms.preferences.copyPublicKey import org.thoughtcrime.securesms.preferences.sendInvitationToUseSession import org.thoughtcrime.securesms.ui.LocalDimensions -import org.thoughtcrime.securesms.ui.color.LocalColors import org.thoughtcrime.securesms.ui.PreviewTheme import org.thoughtcrime.securesms.ui.base +import org.thoughtcrime.securesms.ui.color.LocalColors import org.thoughtcrime.securesms.ui.components.AppBar import org.thoughtcrime.securesms.ui.components.SlimOutlineButton import org.thoughtcrime.securesms.ui.components.SlimOutlineCopyButton +import org.thoughtcrime.securesms.ui.components.border import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.createThemedComposeView -import org.thoughtcrime.securesms.ui.extraSmallMonospace import org.thoughtcrime.securesms.ui.small @AndroidEntryPoint @@ -88,11 +81,7 @@ private fun InviteFriend( modifier = Modifier .contentDescription(R.string.AccessibilityId_recovery_password_container) .fillMaxWidth() - .border( - width = LocalDimensions.current.borderStroke, - color = LocalColors.current.borders, - shape = MaterialTheme.shapes.small - ) + .border() .padding(LocalDimensions.current.marginSmall), textAlign = TextAlign.Center, style = base diff --git a/app/src/main/java/org/thoughtcrime/securesms/recoverypassword/RecoveryPassword.kt b/app/src/main/java/org/thoughtcrime/securesms/recoverypassword/RecoveryPassword.kt index 79f610caeb..2465545a1e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/recoverypassword/RecoveryPassword.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/recoverypassword/RecoveryPassword.kt @@ -1,7 +1,6 @@ package org.thoughtcrime.securesms.recoverypassword import androidx.compose.animation.AnimatedVisibility -import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -11,9 +10,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -26,7 +23,6 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter -import androidx.compose.ui.unit.dp import network.loki.messenger.R import org.thoughtcrime.securesms.ui.CellWithPaddingAndMargin import org.thoughtcrime.securesms.ui.LocalDimensions @@ -39,6 +35,7 @@ import org.thoughtcrime.securesms.ui.color.LocalColors import org.thoughtcrime.securesms.ui.components.QrImage import org.thoughtcrime.securesms.ui.components.SlimOutlineButton import org.thoughtcrime.securesms.ui.components.SlimOutlineCopyButton +import org.thoughtcrime.securesms.ui.components.border import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.extraSmallMonospace import org.thoughtcrime.securesms.ui.h8 @@ -135,11 +132,7 @@ private fun RecoveryPassword(seed: String) { modifier = Modifier .contentDescription(R.string.AccessibilityId_recovery_password_container) .padding(vertical = LocalDimensions.current.marginSmall) - .border( - width = LocalDimensions.current.borderStroke, - color = LocalColors.current.borders, - shape = MaterialTheme.shapes.small - ) + .border() .padding(LocalDimensions.current.marginSmall), textAlign = TextAlign.Center, style = extraSmallMonospace, diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Border.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/Border.kt new file mode 100644 index 0000000000..4039f84ec6 --- /dev/null +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/Border.kt @@ -0,0 +1,16 @@ +package org.thoughtcrime.securesms.ui.components + +import androidx.compose.foundation.border +import androidx.compose.material.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.SolidColor +import org.thoughtcrime.securesms.ui.LocalDimensions +import org.thoughtcrime.securesms.ui.color.LocalColors + +@Composable +fun Modifier.border() = this.border( + width = LocalDimensions.current.borderStroke, + brush = SolidColor(LocalColors.current.borders), + shape = MaterialTheme.shapes.small +) \ No newline at end of file