Skip to content

Commit

Permalink
chore: Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Dec 3, 2024
1 parent c78ac8b commit 8916d07
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@
*/
package com.infomaniak.swisstransfer.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import com.infomaniak.swisstransfer.ui.theme.Dimens
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow
import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow

private val STICKY_BUTTON_VERTICAL_PADDING = Margin.Small

@Composable
fun BottomStickyButtonScaffold(
Expand All @@ -44,12 +50,12 @@ fun BottomStickyButtonScaffold(
modifier = modifier
.fillMaxWidth()
.padding(contentPaddings)
.padding(vertical = Margin.Small),
.padding(vertical = STICKY_BUTTON_VERTICAL_PADDING),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Box(
modifier = Modifier
.padding(bottom = Margin.Small)
.padding(bottom = STICKY_BUTTON_VERTICAL_PADDING)
.weight(1.0f)
.widthIn(max = Dimens.MaxSinglePaneScreenWidth),
content = content,
Expand All @@ -58,3 +64,40 @@ fun BottomStickyButtonScaffold(
}
}
}

@PreviewSmallWindow
@PreviewLargeWindow
@Composable
private fun Preview() {
SwissTransferTheme {
Surface {
BottomStickyButtonScaffold(
topBar = {
Text(
modifier = Modifier
.fillMaxWidth()
.background(Color.DarkGray),
text = "topBar",
textAlign = TextAlign.Center,
)
},
topButton = { modifier ->
SwissTransferButton(
modifier = modifier,
style = ButtonType.PRIMARY,
onClick = {},
content = { Text("sticky button") },
)
},
) {
Text(
modifier = Modifier
.fillMaxSize()
.background(Color.LightGray),
text = "content",
textAlign = TextAlign.Center,
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ private fun DoubleButtonComboPreview() {
)
},
)
Spacer(Modifier.height(Margin.Medium))
DoubleButtonCombo(
bottomButton = {
LargeButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.tooling.preview.Preview
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.MatomoSwissTransfer.toFloat
import com.infomaniak.swisstransfer.ui.components.SwissTransferAlertDialog
import com.infomaniak.swisstransfer.ui.components.SwissTransferTextField
import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.PasswordTransferOption
Expand Down Expand Up @@ -110,8 +112,10 @@ private fun ColumnScope.AnimatedPasswordInput(
imeAction = ImeAction.Done,
isError = isError,
supportingText = {
val errorText = if (isError) stringResource(R.string.errorTransferPasswordLength) else ""
Text(text = errorText, minLines = 2)
Text(
modifier = Modifier.alpha(isError.toFloat()),
text = stringResource(R.string.errorTransferPasswordLength),
)
},
onValueChange = { password.set(it) },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ package com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.component
import androidx.annotation.PluralsRes
import androidx.annotation.StringRes
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
Expand All @@ -47,7 +44,7 @@ fun TransferTypeButtons(transferType: GetSetCallbacks<TransferTypeUi>) {
Row(
modifier = Modifier
.horizontalScroll(rememberScrollState())
.windowInsetsPadding(insets = WindowInsets(left = Margin.Medium, top = 0.dp, right = Margin.Medium, bottom = 0.dp)),
.padding(horizontal = Margin.Medium),
horizontalArrangement = Arrangement.spacedBy(Margin.Mini),
) {
for (transferTypeEntry in TransferTypeUi.entries) {
Expand Down

0 comments on commit 8916d07

Please sign in to comment.