renaming spacing to be more general

This commit is contained in:
ThomasSession 2024-07-15 10:51:24 +10:00
parent facbee99a5
commit bb630fc11b
19 changed files with 62 additions and 62 deletions

View File

@ -46,7 +46,7 @@ fun DisappearingMessages(
.padding(bottom = 20.dp)
.verticalScroll(scrollState)
.fadingEdges(scrollState),
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallItemSpacing)
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)
) {
state.cards.forEach {
OptionsCard(it, callbacks)

View File

@ -74,17 +74,17 @@ internal fun StartConversationScreen(
Column(
modifier = Modifier
.padding(horizontal = LocalDimensions.current.margin)
.padding(top = LocalDimensions.current.itemSpacing)
.padding(top = LocalDimensions.current.spacing)
.padding(bottom = LocalDimensions.current.margin)
) {
Text(stringResource(R.string.accountIdYours), style = LocalType.current.xl)
Spacer(modifier = Modifier.height(LocalDimensions.current.xxxsItemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.xxxsSpacing))
Text(
text = stringResource(R.string.qrYoursDescription),
color = LocalColors.current.textSecondary,
style = LocalType.current.small
)
Spacer(modifier = Modifier.height(LocalDimensions.current.smallItemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing))
QrImage(
string = accountId,
Modifier.contentDescription(R.string.AccessibilityId_qr_code),

View File

@ -36,7 +36,7 @@ internal fun InviteFriend(
Column(modifier = Modifier.background(LocalColors.current.backgroundSecondary)) {
AppBar(stringResource(R.string.invite_a_friend), onBack = onBack, onClose = onClose)
Column(
modifier = Modifier.padding(horizontal = LocalDimensions.current.itemSpacing),
modifier = Modifier.padding(horizontal = LocalDimensions.current.spacing),
) {
Text(
accountId,
@ -49,19 +49,19 @@ internal fun InviteFriend(
style = LocalType.current.base
)
Spacer(modifier = Modifier.height(LocalDimensions.current.xsItemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.xsSpacing))
Text(
stringResource(R.string.invite_your_friend_to_chat_with_you_on_session_by_sharing_your_account_id_with_them),
textAlign = TextAlign.Center,
style = LocalType.current.small,
color = LocalColors.current.textSecondary,
modifier = Modifier.padding(horizontal = LocalDimensions.current.smallItemSpacing)
modifier = Modifier.padding(horizontal = LocalDimensions.current.smallSpacing)
)
Spacer(modifier = Modifier.height(LocalDimensions.current.smallItemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing))
Row(horizontalArrangement = spacedBy(LocalDimensions.current.smallItemSpacing)) {
Row(horizontalArrangement = spacedBy(LocalDimensions.current.smallSpacing)) {
SlimOutlineButton(
stringResource(R.string.share),
modifier = Modifier

View File

@ -151,8 +151,8 @@ fun MessageDetails(
Column(
modifier = Modifier
.verticalScroll(rememberScrollState())
.padding(vertical = LocalDimensions.current.smallItemSpacing),
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallItemSpacing)
.padding(vertical = LocalDimensions.current.smallSpacing),
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)
) {
state.record?.let { message ->
AndroidView(
@ -192,7 +192,7 @@ fun CellMetadata(
state.apply {
if (listOfNotNull(sent, received, error, senderInfo).isEmpty()) return
CellWithPaddingAndMargin {
Column(verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallItemSpacing)) {
Column(verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)) {
TitledText(sent)
TitledText(received)
TitledErrorText(error)
@ -250,7 +250,7 @@ fun Carousel(attachments: List<Attachment>, onClick: (Int) -> Unit) {
val pagerState = rememberPagerState { attachments.size }
Column(verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallItemSpacing)) {
Column(verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)) {
Row {
CarouselPrevButton(pagerState)
Box(modifier = Modifier.weight(1f)) {
@ -259,7 +259,7 @@ fun Carousel(attachments: List<Attachment>, onClick: (Int) -> Unit) {
ExpandButton(
modifier = Modifier
.align(Alignment.BottomEnd)
.padding(LocalDimensions.current.xxsItemSpacing)
.padding(LocalDimensions.current.xxsSpacing)
) { onClick(pagerState.currentPage) }
}
CarouselNextButton(pagerState)
@ -339,8 +339,8 @@ fun FileDetails(fileDetails: List<TitledText>) {
Cell {
FlowRow(
modifier = Modifier.padding(horizontal = LocalDimensions.current.xsItemSpacing, vertical = LocalDimensions.current.itemSpacing),
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallItemSpacing)
modifier = Modifier.padding(horizontal = LocalDimensions.current.xsSpacing, vertical = LocalDimensions.current.spacing),
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)
) {
fileDetails.forEach {
BoxWithConstraints {
@ -348,7 +348,7 @@ fun FileDetails(fileDetails: List<TitledText>) {
it,
modifier = Modifier
.widthIn(min = maxWidth.div(2))
.padding(horizontal = LocalDimensions.current.xsItemSpacing)
.padding(horizontal = LocalDimensions.current.xsSpacing)
.width(IntrinsicSize.Max)
)
}
@ -395,7 +395,7 @@ fun TitledText(
@Composable
fun TitledView(title: GetString, modifier: Modifier = Modifier, content: @Composable () -> Unit) {
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.xxxsItemSpacing)) {
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.xxxsSpacing)) {
Text(title.string(), style = LocalType.current.base.bold())
content()
}

View File

@ -56,7 +56,7 @@ internal fun EmptyView(newAccount: Boolean) {
stringResource(R.string.conversationsNone),
style = LocalType.current.h8,
textAlign = TextAlign.Center,
modifier = Modifier.padding(bottom = LocalDimensions.current.xsItemSpacing))
modifier = Modifier.padding(bottom = LocalDimensions.current.xsSpacing))
Text(
stringResource(R.string.onboardingHitThePlusButton),
style = LocalType.current.small,

View File

@ -52,7 +52,7 @@ internal fun SeedReminder(startRecoveryPasswordActivity: () -> Unit) {
stringResource(R.string.save_your_recovery_password),
style = LocalType.current.h8
)
Spacer(Modifier.requiredWidth(LocalDimensions.current.xxsItemSpacing))
Spacer(Modifier.requiredWidth(LocalDimensions.current.xxsSpacing))
SessionShieldIcon()
}
Text(

View File

@ -115,7 +115,7 @@ internal fun LandingScreen(
style = LocalType.current.h4,
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.height(LocalDimensions.current.itemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.spacing))
LazyColumn(
state = listState,
@ -123,7 +123,7 @@ internal fun LandingScreen(
.heightIn(min = LocalDimensions.current.minScrollableViewHeight)
.fillMaxWidth()
.weight(3f),
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallItemSpacing)
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)
) {
items(
MESSAGES.take(count),
@ -148,7 +148,7 @@ internal fun LandingScreen(
.contentDescription(R.string.AccessibilityId_create_account_button),
onClick = createAccount
)
Spacer(modifier = Modifier.height(LocalDimensions.current.smallItemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing))
PrimaryOutlineButton(
stringResource(R.string.onboardingAccountExists),
modifier = Modifier
@ -165,7 +165,7 @@ internal fun LandingScreen(
.contentDescription(R.string.AccessibilityId_open_url),
onClick = { isUrlDialogVisible = true }
)
Spacer(modifier = Modifier.height(LocalDimensions.current.xxsItemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.xxsSpacing))
}
}
}
@ -219,8 +219,8 @@ private fun MessageText(
style = LocalType.current.large,
color = textColor,
modifier = Modifier.padding(
horizontal = LocalDimensions.current.smallItemSpacing,
vertical = LocalDimensions.current.xsItemSpacing
horizontal = LocalDimensions.current.smallSpacing,
vertical = LocalDimensions.current.xsSpacing
)
)
}

View File

@ -74,7 +74,7 @@ private fun RecoveryPassword(state: State, onChange: (String) -> Unit = {}, onCo
.verticalScroll(rememberScrollState())
) {
Spacer(Modifier.weight(1f))
Spacer(modifier = Modifier.height(LocalDimensions.current.smallItemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing))
Column(
modifier = Modifier.padding(horizontal = LocalDimensions.current.largeMargin)
@ -84,19 +84,19 @@ private fun RecoveryPassword(state: State, onChange: (String) -> Unit = {}, onCo
text = stringResource(R.string.sessionRecoveryPassword),
style = LocalType.current.h4
)
Spacer(Modifier.width(LocalDimensions.current.xxsItemSpacing))
Spacer(Modifier.width(LocalDimensions.current.xxsSpacing))
Icon(
modifier = Modifier.align(Alignment.CenterVertically),
painter = painterResource(id = R.drawable.ic_shield_outline),
contentDescription = null,
)
}
Spacer(Modifier.height(LocalDimensions.current.smallItemSpacing))
Spacer(Modifier.height(LocalDimensions.current.smallSpacing))
Text(
stringResource(R.string.activity_link_enter_your_recovery_password_to_load_your_account_if_you_haven_t_saved_it_you_can_find_it_in_your_app_settings),
style = LocalType.current.base
)
Spacer(Modifier.height(LocalDimensions.current.itemSpacing))
Spacer(Modifier.height(LocalDimensions.current.spacing))
SessionOutlinedTextField(
text = state.recoveryPhrase,
modifier = Modifier.fillMaxWidth(),
@ -109,7 +109,7 @@ private fun RecoveryPassword(state: State, onChange: (String) -> Unit = {}, onCo
)
}
Spacer(modifier = Modifier.height(LocalDimensions.current.smallItemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing))
Spacer(Modifier.weight(2f))
ContinuePrimaryOutlineButton(modifier = Modifier.align(Alignment.CenterHorizontally), onContinue)

View File

@ -26,7 +26,7 @@ internal fun LoadingScreen(progress: Float) {
stringResource(R.string.waitOneMoment),
style = LocalType.current.h7
)
Spacer(modifier = Modifier.height(LocalDimensions.current.xxxsItemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.xxxsSpacing))
Text(
stringResource(R.string.loadAccountProgressMessage),
style = LocalType.current.base

View File

@ -60,7 +60,7 @@ internal fun MessageNotificationsScreen(
Text(stringResource(R.string.notificationsMessage), style = LocalType.current.h4)
Spacer(Modifier.height(LocalDimensions.current.xsMargin))
Text(stringResource(R.string.onboardingMessageNotificationExplaination), style = LocalType.current.base)
Spacer(Modifier.height(LocalDimensions.current.itemSpacing))
Spacer(Modifier.height(LocalDimensions.current.spacing))
}
NotificationRadioButton(

View File

@ -51,18 +51,18 @@ internal fun PickDisplayName(
.verticalScroll(rememberScrollState())
) {
Spacer(Modifier.weight(1f))
Spacer(modifier = Modifier.height(LocalDimensions.current.smallItemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing))
Column(
modifier = Modifier.padding(horizontal = LocalDimensions.current.largeMargin)
) {
Text(stringResource(state.title), style = LocalType.current.h4)
Spacer(Modifier.height(LocalDimensions.current.smallItemSpacing))
Spacer(Modifier.height(LocalDimensions.current.smallSpacing))
Text(
stringResource(state.description),
style = LocalType.current.base,
modifier = Modifier.padding(bottom = LocalDimensions.current.xsItemSpacing))
Spacer(Modifier.height(LocalDimensions.current.itemSpacing))
modifier = Modifier.padding(bottom = LocalDimensions.current.xsSpacing))
Spacer(Modifier.height(LocalDimensions.current.spacing))
SessionOutlinedTextField(
text = state.displayName,
modifier = Modifier.fillMaxWidth(),
@ -75,7 +75,7 @@ internal fun PickDisplayName(
)
}
Spacer(modifier = Modifier.height(LocalDimensions.current.smallItemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing))
Spacer(Modifier.weight(2f))
ContinuePrimaryOutlineButton(modifier = Modifier.align(Alignment.CenterHorizontally), onContinue)

View File

@ -431,7 +431,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
modifier = Modifier
.padding(horizontal = LocalDimensions.current.smallMargin)
.padding(top = LocalDimensions.current.xxxsMargin),
horizontalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallItemSpacing),
horizontalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing),
) {
PrimaryOutlineButton(
stringResource(R.string.share),
@ -445,7 +445,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
)
}
Spacer(modifier = Modifier.height(LocalDimensions.current.itemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.spacing))
val hasPaths by hasPaths().collectAsState(initial = false)

View File

@ -76,7 +76,7 @@ private fun RecoveryPasswordCell(
stringResource(R.string.sessionRecoveryPassword),
style = LocalType.current.h8
)
Spacer(Modifier.width(LocalDimensions.current.xxsItemSpacing))
Spacer(Modifier.width(LocalDimensions.current.xxsSpacing))
SessionShieldIcon()
}
@ -107,7 +107,7 @@ private fun RecoveryPasswordCell(
AnimatedVisibility(!showQr) {
Row(
horizontalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallItemSpacing),
horizontalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing),
verticalAlignment = Alignment.CenterVertically
) {
SlimOutlineCopyButton(

View File

@ -73,15 +73,15 @@ fun AlertDialog(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxWidth()
.padding(top = LocalDimensions.current.smallItemSpacing)
.padding(horizontal = LocalDimensions.current.smallItemSpacing)
.padding(top = LocalDimensions.current.smallSpacing)
.padding(horizontal = LocalDimensions.current.smallSpacing)
) {
title?.let {
Text(
it,
textAlign = TextAlign.Center,
style = LocalType.current.h7,
modifier = Modifier.padding(bottom = LocalDimensions.current.xxsItemSpacing)
modifier = Modifier.padding(bottom = LocalDimensions.current.xxsSpacing)
)
}
text?.let {
@ -89,7 +89,7 @@ fun AlertDialog(
it,
textAlign = TextAlign.Center,
style = LocalType.current.large,
modifier = Modifier.padding(bottom = LocalDimensions.current.xxsItemSpacing)
modifier = Modifier.padding(bottom = LocalDimensions.current.xxsSpacing)
)
}
content()
@ -130,8 +130,8 @@ fun DialogButton(text: String, modifier: Modifier, color: Color = Color.Unspecif
style = LocalType.current.large.bold(),
textAlign = TextAlign.Center,
modifier = Modifier.padding(
top = LocalDimensions.current.smallItemSpacing,
bottom = LocalDimensions.current.itemSpacing
top = LocalDimensions.current.smallSpacing,
bottom = LocalDimensions.current.spacing
)
)
}

View File

@ -226,7 +226,7 @@ fun ItemButton(
text,
Modifier
.fillMaxWidth()
.padding(vertical = LocalDimensions.current.xsItemSpacing)
.padding(vertical = LocalDimensions.current.xsSpacing)
.align(Alignment.CenterVertically),
style = textStyle
)
@ -269,7 +269,7 @@ fun CellWithPaddingAndMargin(
fun <T> TitledRadioButton(option: RadioOption<T>, onClick: () -> Unit) {
val color = if (option.enabled) LocalColors.current.text else LocalColors.current.disabled
Row(
horizontalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallItemSpacing),
horizontalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing),
modifier = Modifier
.runIf(option.enabled) { clickable { if (!option.selected) onClick() } }
.heightIn(min = 60.dp)

View File

@ -96,7 +96,7 @@ fun MaybeScanQrCode(
style = LocalType.current.base,
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.size(LocalDimensions.current.itemSpacing))
Spacer(modifier = Modifier.size(LocalDimensions.current.spacing))
OutlineButton(
stringResource(R.string.sessionSettings),
modifier = Modifier.align(Alignment.CenterHorizontally),
@ -114,7 +114,7 @@ fun MaybeScanQrCode(
Spacer(modifier = Modifier.weight(1f))
Text(stringResource(R.string.fragment_scan_qr_code_camera_access_explanation),
style = LocalType.current.xl, textAlign = TextAlign.Center)
Spacer(modifier = Modifier.height(LocalDimensions.current.itemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.spacing))
PrimaryOutlineButton(
stringResource(R.string.cameraGrantAccess),
modifier = Modifier.fillMaxWidth(),
@ -186,11 +186,11 @@ fun ScanQrCode(errors: Flow<String>, onScan: (String) -> Unit) {
snackbarHost = {
SnackbarHost(
hostState = scaffoldState.snackbarHostState,
modifier = Modifier.padding(LocalDimensions.current.smallItemSpacing)
modifier = Modifier.padding(LocalDimensions.current.smallSpacing)
) { data ->
Snackbar(
snackbarData = data,
modifier = Modifier.padding(LocalDimensions.current.smallItemSpacing)
modifier = Modifier.padding(LocalDimensions.current.smallSpacing)
)
}
}
@ -204,7 +204,7 @@ fun ScanQrCode(errors: Flow<String>, onScan: (String) -> Unit) {
Box(
Modifier
.aspectRatio(1f)
.padding(LocalDimensions.current.itemSpacing)
.padding(LocalDimensions.current.spacing)
.clip(shape = RoundedCornerShape(26.dp))
.background(Color(0x33ffffff))
.align(Alignment.Center)

View File

@ -40,7 +40,7 @@ import org.thoughtcrime.securesms.util.QRCodeUtilities
fun QrImage(
string: String?,
modifier: Modifier = Modifier,
contentPadding: Dp = LocalDimensions.current.smallItemSpacing,
contentPadding: Dp = LocalDimensions.current.smallSpacing,
icon: Int = R.drawable.session_shield
) {
var bitmap: Bitmap? by remember {

View File

@ -130,7 +130,7 @@ fun SessionOutlinedTextField(
)
}
error?.let {
Spacer(modifier = Modifier.height(LocalDimensions.current.xsItemSpacing))
Spacer(modifier = Modifier.height(LocalDimensions.current.xsSpacing))
Text(
it,
modifier = Modifier.fillMaxWidth()

View File

@ -7,11 +7,11 @@ import androidx.compose.ui.unit.dp
val LocalDimensions = staticCompositionLocalOf { Dimensions() }
data class Dimensions(
val xxxsItemSpacing: Dp = 4.dp,
val xxsItemSpacing: Dp = 8.dp,
val xsItemSpacing: Dp = 12.dp,
val smallItemSpacing: Dp = 16.dp,
val itemSpacing: Dp = 24.dp,
val xxxsSpacing: Dp = 4.dp,
val xxsSpacing: Dp = 8.dp,
val xsSpacing: Dp = 12.dp,
val smallSpacing: Dp = 16.dp,
val spacing: Dp = 24.dp,
val xxxsMargin: Dp = 8.dp,
val xxsMargin: Dp = 12.dp,