Standardise margins

This commit is contained in:
Andrew 2024-06-17 14:39:45 +09:30
parent e2eea61c68
commit 2341685fd3
8 changed files with 113 additions and 86 deletions

View File

@ -94,7 +94,7 @@ class LandingActivity: BaseActionBarActivity() {
@Preview @Preview
@Composable @Composable
private fun LandingScreen( private fun PreviewLandingScreen(
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors @PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
) { ) {
PreviewTheme(colors) { PreviewTheme(colors) {
@ -119,7 +119,8 @@ class LandingActivity: BaseActionBarActivity() {
Column { Column {
Column(modifier = Modifier Column(modifier = Modifier
.weight(1f) .weight(1f)
.padding(horizontal = LocalDimensions.current.marginMedium)) { .padding(horizontal = LocalDimensions.current.marginOnboarding)
) {
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.weight(1f))
Text( Text(
stringResource(R.string.onboardingBubblePrivacyInYourPocket), stringResource(R.string.onboardingBubblePrivacyInYourPocket),
@ -132,7 +133,7 @@ class LandingActivity: BaseActionBarActivity() {
LazyColumn( LazyColumn(
state = listState, state = listState,
modifier = Modifier modifier = Modifier
.heightIn(min = 200.dp) .heightIn(min = LocalDimensions.current.minScrollableViewHeight)
.fillMaxWidth() .fillMaxWidth()
.weight(3f), .weight(3f),
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.itemSpacingSmall) verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.itemSpacingSmall)

View File

@ -32,6 +32,7 @@ import org.session.libsession.utilities.TextSecurePreferences
import org.thoughtcrime.securesms.BaseActionBarActivity import org.thoughtcrime.securesms.BaseActionBarActivity
import org.thoughtcrime.securesms.onboarding.loading.LoadingManager import org.thoughtcrime.securesms.onboarding.loading.LoadingManager
import org.thoughtcrime.securesms.onboarding.messagenotifications.startMessageNotificationsActivity import org.thoughtcrime.securesms.onboarding.messagenotifications.startMessageNotificationsActivity
import org.thoughtcrime.securesms.onboarding.ui.ContinueButton
import org.thoughtcrime.securesms.ui.LocalDimensions import org.thoughtcrime.securesms.ui.LocalDimensions
import org.thoughtcrime.securesms.ui.PreviewTheme import org.thoughtcrime.securesms.ui.PreviewTheme
import org.thoughtcrime.securesms.ui.base import org.thoughtcrime.securesms.ui.base
@ -116,8 +117,10 @@ fun PreviewRecoveryPassword() {
@Composable @Composable
fun RecoveryPassword(state: LinkDeviceState, onChange: (String) -> Unit = {}, onContinue: () -> Unit = {}) { fun RecoveryPassword(state: LinkDeviceState, onChange: (String) -> Unit = {}, onContinue: () -> Unit = {}) {
Column {
Column( Column(
modifier = Modifier.padding(horizontal = LocalDimensions.current.marginLarge) modifier = Modifier.padding(horizontal = LocalDimensions.current.marginLarge)
.weight(1f)
) { ) {
Spacer(Modifier.weight(1f)) Spacer(Modifier.weight(1f))
Row { Row {
@ -147,14 +150,10 @@ fun RecoveryPassword(state: LinkDeviceState, onChange: (String) -> Unit = {}, on
onContinue = onContinue, onContinue = onContinue,
error = state.error error = state.error
) )
Spacer(Modifier.weight(2f)) Spacer(Modifier.weight(2f))
OutlineButton( }
stringResource(R.string.continue_2),
modifier = Modifier ContinueButton(modifier = Modifier.align(Alignment.CenterHorizontally), onContinue)
.align(Alignment.CenterHorizontally)
.padding(vertical = 20.dp)
.fillMaxWidth(),
onClick = onContinue
)
} }
} }

View File

@ -13,6 +13,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameter
import network.loki.messenger.R import network.loki.messenger.R
import org.thoughtcrime.securesms.onboarding.ui.ContinueButton
import org.thoughtcrime.securesms.ui.LocalDimensions import org.thoughtcrime.securesms.ui.LocalDimensions
import org.thoughtcrime.securesms.ui.PreviewTheme import org.thoughtcrime.securesms.ui.PreviewTheme
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
@ -42,7 +43,8 @@ fun MessageNotificationsScreen(
) { ) {
Column { Column {
Spacer(Modifier.weight(1f)) Spacer(Modifier.weight(1f))
Column(modifier = Modifier.padding(horizontal = LocalDimensions.current.marginMedium)) {
Column(modifier = Modifier.padding(horizontal = LocalDimensions.current.marginOnboarding)) {
Text(stringResource(R.string.notificationsMessage), style = h4) Text(stringResource(R.string.notificationsMessage), style = h4)
Spacer(Modifier.height(LocalDimensions.current.marginExtraSmall)) Spacer(Modifier.height(LocalDimensions.current.marginExtraSmall))
Text(stringResource(R.string.onboardingMessageNotificationExplaination), style = base) Text(stringResource(R.string.onboardingMessageNotificationExplaination), style = base)
@ -64,16 +66,9 @@ fun MessageNotificationsScreen(
onClick = { setEnabled(false) } onClick = { setEnabled(false) }
) )
} }
Spacer(Modifier.weight(1f)) Spacer(Modifier.weight(1f))
OutlineButton(
stringResource(R.string.continue_2), ContinueButton(Modifier.align(Alignment.CenterHorizontally), onContinue)
modifier = Modifier
.padding(horizontal = LocalDimensions.current.marginLarge)
.contentDescription(R.string.AccessibilityId_continue)
.align(Alignment.CenterHorizontally)
.fillMaxWidth(),
onClick = onContinue
)
Spacer(modifier = Modifier.height(LocalDimensions.current.marginExtraExtraSmall))
} }
} }

View File

@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
@ -14,9 +13,10 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import network.loki.messenger.R import network.loki.messenger.R
import org.thoughtcrime.securesms.onboarding.ui.ContinueButton
import org.thoughtcrime.securesms.ui.LocalDimensions
import org.thoughtcrime.securesms.ui.PreviewTheme import org.thoughtcrime.securesms.ui.PreviewTheme
import org.thoughtcrime.securesms.ui.base import org.thoughtcrime.securesms.ui.base
import org.thoughtcrime.securesms.ui.components.OutlineButton
import org.thoughtcrime.securesms.ui.components.SessionOutlinedTextField import org.thoughtcrime.securesms.ui.components.SessionOutlinedTextField
import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.h4 import org.thoughtcrime.securesms.ui.h4
@ -31,11 +31,12 @@ fun PreviewDisplayName() {
@Composable @Composable
fun DisplayName(state: State, onChange: (String) -> Unit = {}, onContinue: () -> Unit = {}) { fun DisplayName(state: State, onChange: (String) -> Unit = {}, onContinue: () -> Unit = {}) {
Column {
Column( Column(
verticalArrangement = Arrangement.spacedBy(20.dp), verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.itemSpacingOnboarding),
modifier = Modifier modifier = Modifier
.padding(horizontal = 50.dp) .padding(horizontal = LocalDimensions.current.marginOnboarding)
.padding(bottom = 12.dp) .weight(1f)
) { ) {
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.weight(1f))
Text(stringResource(state.title), style = h4) Text(stringResource(state.title), style = h4)
@ -56,14 +57,8 @@ fun DisplayName(state: State, onChange: (String) -> Unit = {}, onContinue: () ->
) )
Spacer(modifier = Modifier.weight(2f)) Spacer(modifier = Modifier.weight(2f))
}
OutlineButton( ContinueButton(Modifier.align(Alignment.CenterHorizontally), onContinue)
stringResource(R.string.continue_2),
modifier = Modifier
.contentDescription(R.string.AccessibilityId_continue)
.align(Alignment.CenterHorizontally)
.width(262.dp),
onClick = onContinue,
)
} }
} }

View File

@ -42,7 +42,6 @@ import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.extraSmallMonospace import org.thoughtcrime.securesms.ui.extraSmallMonospace
import org.thoughtcrime.securesms.ui.h8 import org.thoughtcrime.securesms.ui.h8
@Preview @Preview
@Composable @Composable
fun PreviewRecoveryPasswordScreen( fun PreviewRecoveryPasswordScreen(

View File

@ -0,0 +1,36 @@
package org.thoughtcrime.securesms.onboarding.ui
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import network.loki.messenger.R
import org.thoughtcrime.securesms.ui.LocalDimensions
import org.thoughtcrime.securesms.ui.components.OutlineButton
import org.thoughtcrime.securesms.ui.contentDescription
@Composable
fun ContinueButton(modifier: Modifier, onContinue: () -> Unit) {
OutlineButton(
stringResource(R.string.continue_2),
modifier = modifier
.contentDescription(R.string.AccessibilityId_continue)
.fillMaxWidth()
.padding(horizontal = LocalDimensions.current.marginLarge)
.padding(bottom = LocalDimensions.current.marginExtraExtraSmall),
onClick = onContinue,
)
}
@Composable
fun OnboardingButton(text: String, modifier: Modifier, onClick: () -> Unit) {
OutlineButton(
text,
modifier = modifier
.fillMaxWidth()
.padding(horizontal = LocalDimensions.current.marginLarge)
.padding(bottom = LocalDimensions.current.marginExtraExtraSmall),
onClick = onClick,
)
}

View File

@ -10,13 +10,16 @@ data class Dimensions(
val itemSpacingTiny: Dp = 4.dp, val itemSpacingTiny: Dp = 4.dp,
val itemSpacingExtraSmall: Dp = 8.dp, val itemSpacingExtraSmall: Dp = 8.dp,
val itemSpacingSmall: Dp = 16.dp, val itemSpacingSmall: Dp = 16.dp,
val itemSpacingOnboarding: Dp = 20.dp,
val itemSpacingMedium: Dp = 24.dp, val itemSpacingMedium: Dp = 24.dp,
val marginTiny: Dp = 8.dp, val marginTiny: Dp = 8.dp,
val marginExtraExtraSmall: Dp = 12.dp, val marginExtraExtraSmall: Dp = 12.dp,
val marginExtraSmall: Dp = 16.dp, val marginExtraSmall: Dp = 16.dp,
val marginSmall: Dp = 24.dp, val marginSmall: Dp = 24.dp,
val marginMedium: Dp = 32.dp, val marginMedium: Dp = 32.dp,
val marginOnboarding: Dp = 36.dp,
val marginLarge: Dp = 64.dp, val marginLarge: Dp = 64.dp,
val dividerIndent: Dp = 80.dp, val dividerIndent: Dp = 80.dp,
val appBarHeight: Dp = 64.dp val appBarHeight: Dp = 64.dp,
val minScrollableViewHeight: Dp = 200.dp
) )

View File

@ -50,7 +50,6 @@ import org.thoughtcrime.securesms.ui.baseBold
import org.thoughtcrime.securesms.ui.color.Colors import org.thoughtcrime.securesms.ui.color.Colors
import org.thoughtcrime.securesms.ui.color.LocalColors import org.thoughtcrime.securesms.ui.color.LocalColors
import org.thoughtcrime.securesms.ui.color.radioButtonColors import org.thoughtcrime.securesms.ui.color.radioButtonColors
import org.thoughtcrime.securesms.ui.color.slimOutlineButton
import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.extraSmall import org.thoughtcrime.securesms.ui.extraSmall
import org.thoughtcrime.securesms.ui.h8 import org.thoughtcrime.securesms.ui.h8