Skip to content

Commit

Permalink
Merge pull request #109 from Infomaniak/fix-double-button-with-single…
Browse files Browse the repository at this point in the history
…-button

Fix width of double button where only one button is defined
  • Loading branch information
LunarX authored Oct 18, 2024
2 parents 5cd1d7e + e1ff1f8 commit a79128f
Showing 1 changed file with 44 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows

private val WIDTH_LIMIT = 800.dp
private val WIDTH_THRESHOLD = 500.dp
Expand Down Expand Up @@ -92,10 +95,45 @@ private fun HorizontallyStackedButtons(

@Composable
private fun SingleButton(button: @Composable (Modifier) -> Unit) {
button(
Modifier
.fillMaxWidth()
.widthIn(WIDTH_LIMIT / 2)
.padding(bottom = Margin.Large, start = Margin.Medium, end = Margin.Medium),
)
Box(Modifier.widthIn(max = WIDTH_LIMIT / 2)) {
button(
Modifier
.fillMaxWidth()
.padding(bottom = Margin.Large, start = Margin.Medium, end = Margin.Medium),
)
}
}

@PreviewAllWindows
@Composable
private fun DoubleButtonComboPreview() {
SwissTransferTheme {
Column {
DoubleButtonCombo(
topButton = {
LargeButton(
modifier = it,
titleRes = R.string.appName,
onClick = {},
)
},
bottomButton = {
LargeButton(
modifier = it,
titleRes = R.string.appName,
onClick = {},
)
},
)
DoubleButtonCombo(
bottomButton = {
LargeButton(
modifier = it,
titleRes = R.string.appName,
onClick = {},
)
},
)
}
}
}

0 comments on commit a79128f

Please sign in to comment.