-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #254 from Spendesk/release/1.12.0
Release 1.12.0
- Loading branch information
Showing
10 changed files
with
347 additions
and
39 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
library-compose/src/main/java/com/spendesk/grapes/compose/card/GrapesInformationCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package com.spendesk.grapes.compose.card | ||
|
||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.ColumnScope | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.CardColors | ||
import androidx.compose.material3.CardDefaults | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.tooling.preview.PreviewParameter | ||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider | ||
import androidx.compose.ui.unit.dp | ||
import com.spendesk.grapes.compose.listitem.GrapesDivider | ||
import com.spendesk.grapes.compose.listitem.GrapesInlineInformationItem | ||
import com.spendesk.grapes.compose.theme.GrapesTheme | ||
|
||
/** | ||
* @author RomainGF | ||
* @since 17/08/2023 | ||
*/ | ||
@Composable | ||
fun GrapesInformationCard( | ||
title: String, | ||
modifier: Modifier = Modifier, | ||
colors: CardColors = GrapesInformationCardDefaults.colors, | ||
border: BorderStroke = GrapesInformationCardDefaults.border, | ||
contentVerticalArrangement: Arrangement.Vertical = GrapesInformationCardDefaults.contentVerticalArrangement, | ||
content: @Composable ColumnScope.() -> Unit = {}, | ||
) { | ||
Card( | ||
modifier = modifier, | ||
colors = colors, | ||
border = border, | ||
) { | ||
Column( | ||
verticalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.paddingLarge), | ||
modifier = Modifier.padding(vertical = GrapesTheme.dimensions.paddingLarge), | ||
) { | ||
Text( | ||
text = title, | ||
style = GrapesTheme.typography.titleS, | ||
modifier = Modifier.padding(horizontal = GrapesTheme.dimensions.paddingLarge), | ||
) | ||
GrapesDivider() | ||
Column( | ||
verticalArrangement = contentVerticalArrangement, | ||
content = content, | ||
modifier = Modifier.padding(horizontal = GrapesTheme.dimensions.paddingLarge), | ||
) | ||
} | ||
} | ||
} | ||
|
||
object GrapesInformationCardDefaults { | ||
|
||
private val borderThickness = 0.5.dp | ||
|
||
val colors: CardColors @Composable get() = CardDefaults.elevatedCardColors( | ||
containerColor = GrapesTheme.colors.mainWhite, | ||
) | ||
|
||
val border: BorderStroke @Composable get() = BorderStroke( | ||
width = borderThickness, | ||
color = GrapesTheme.colors.mainNeutralNormal, | ||
) | ||
|
||
val contentVerticalArrangement: Arrangement.HorizontalOrVertical | ||
@Composable get() = Arrangement.spacedBy(GrapesTheme.dimensions.paddingLarge) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun PreviewDescription( | ||
@PreviewParameter(DescriptionParameterProvider::class) texts: Pair<String, String>, | ||
) { | ||
GrapesTheme { | ||
Surface( | ||
color = GrapesTheme.colors.mainBackground, | ||
) { | ||
GrapesInformationCard( | ||
title = texts.first, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(16.dp), | ||
) { | ||
Text(texts.second) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private class DescriptionParameterProvider : PreviewParameterProvider<Pair<String, String>> { | ||
override val values = sequenceOf( | ||
"This is a simple example of a very very very long title" to "Lorem Ipsum is simply dummy text.", | ||
"Short title" to "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.", | ||
"This is a simple example of a very very very long title" to "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.", | ||
) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun PreviewDescriptionItems() { | ||
GrapesTheme { | ||
Surface( | ||
color = GrapesTheme.colors.mainBackground, | ||
) { | ||
GrapesInformationCard( | ||
title = "Description", | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(16.dp), | ||
) { | ||
GrapesInlineInformationItem( | ||
title = "Subscription owner", | ||
value = "Ben Hintz", | ||
) | ||
GrapesInlineInformationItem( | ||
title = "Subscription owner", | ||
value = "Ben Hintz", | ||
) | ||
} | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...compose/src/main/java/com/spendesk/grapes/compose/listitem/GrapesInlineInformationItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.spendesk.grapes.compose.listitem | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.tooling.preview.PreviewParameter | ||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider | ||
import com.spendesk.grapes.compose.theme.GrapesTheme | ||
|
||
/** | ||
* @author : RomainGF | ||
* @since : 18/08/2023 | ||
**/ | ||
@Composable | ||
fun GrapesInlineInformationItem( | ||
title: String, | ||
value: String, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Row( | ||
modifier = modifier, | ||
horizontalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.paddingXSmall), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
Text( | ||
text = title, | ||
color = GrapesTheme.colors.mainNeutralDarker, | ||
style = GrapesTheme.typography.bodyRegular, | ||
modifier = Modifier.weight(1f), | ||
) | ||
Box( | ||
modifier = Modifier.weight(1f), | ||
contentAlignment = Alignment.CenterEnd, | ||
) { | ||
Text( | ||
text = value, | ||
style = GrapesTheme.typography.bodyRegular, | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview(showBackground = true) | ||
private fun Preview( | ||
@PreviewParameter(ItemParameterProvider::class) item: Pair<String, String>, | ||
) { | ||
GrapesTheme { | ||
GrapesInlineInformationItem( | ||
title = item.first, | ||
value = item.second, | ||
) | ||
} | ||
} | ||
|
||
private class ItemParameterProvider : PreviewParameterProvider<Pair<String, String>> { | ||
override val values = sequenceOf( | ||
"This is an example of a very long key" to "Short value", | ||
"Short key" to "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.", | ||
"This is an example of a very long key" to "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.", | ||
) | ||
} |
Oops, something went wrong.