-
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.
- Loading branch information
Showing
35 changed files
with
2,219 additions
and
283 deletions.
There are no files selected for viewing
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
84 changes: 84 additions & 0 deletions
84
library-compose/src/main/java/com/spendesk/grapes/compose/bucket/BucketHeadline.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,84 @@ | ||
package com.spendesk.grapes.compose.bucket | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.rememberScrollState | ||
import androidx.compose.foundation.verticalScroll | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.semantics.Role | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.spendesk.grapes.compose.theme.GrapesTheme | ||
|
||
/** | ||
* @author : dany | ||
* @since : 06/03/2023, Mon | ||
**/ | ||
@Composable | ||
internal fun GrapesBucketHeadline( | ||
title: String, | ||
modifier: Modifier = Modifier, | ||
action: String? = null, | ||
actionColor: Color? = null, | ||
onActionClicked: (() -> Unit)? = null | ||
) { | ||
Row(modifier = modifier.fillMaxWidth()) { | ||
Text( | ||
modifier = Modifier.weight(1f, fill = true), | ||
text = title, | ||
color = GrapesTheme.colors.mainComplementary, | ||
overflow = TextOverflow.Ellipsis, | ||
maxLines = 1, | ||
style = GrapesTheme.typography.titleS | ||
) | ||
if (action != null && actionColor != null) { | ||
Spacer(modifier = Modifier.size(GrapesTheme.dimensions.paddingMedium)) | ||
Text( | ||
modifier = Modifier.clickable(onClick = onActionClicked ?: {}, onClickLabel = action, role = Role.Button), | ||
text = action, | ||
color = actionColor, | ||
overflow = TextOverflow.Ellipsis, | ||
maxLines = 1, | ||
style = GrapesTheme.typography.titleS | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
private fun GrapesBucketHeadlinePreview() { | ||
GrapesTheme { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.background(GrapesTheme.colors.mainNeutralLighter) | ||
.verticalScroll(rememberScrollState()), | ||
) { | ||
|
||
GrapesBucketHeadline(title = "Bucket de Rick Astley") | ||
Spacer(modifier = Modifier.size(GrapesTheme.dimensions.paddingLarge)) | ||
|
||
GrapesBucketHeadline(title = "Bucket de Rick Astley a bit longer than expecteeeeeeeeeeeeeed") | ||
Spacer(modifier = Modifier.size(GrapesTheme.dimensions.paddingLarge)) | ||
|
||
GrapesBucketHeadline(title = "Bucket de Rick Astley a bit longer than expecteeeeeeeeeeeeeeeeeeed", action = "Remove", actionColor = GrapesTheme.colors.mainAlertNormal) | ||
Spacer(modifier = Modifier.size(GrapesTheme.dimensions.paddingLarge)) | ||
|
||
GrapesBucketHeadline(title = "Bucket de Rick Astley", action = "Remove", actionColor = GrapesTheme.colors.mainAlertNormal) | ||
Spacer(modifier = Modifier.size(GrapesTheme.dimensions.paddingLarge)) | ||
|
||
GrapesBucketHeadline(title = "Bucket de Rick Astley", action = "Remooooooove with too many ooooooooooos", actionColor = GrapesTheme.colors.mainAlertNormal) | ||
Spacer(modifier = Modifier.size(GrapesTheme.dimensions.paddingLarge)) | ||
} | ||
} | ||
} |
Oops, something went wrong.