Skip to content

Commit

Permalink
Release v1.5.0 (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
kelianClerc authored Mar 7, 2023
2 parents 70ff448 + 41cb2a7 commit 8a833c9
Show file tree
Hide file tree
Showing 35 changed files with 2,219 additions and 283 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
buildscript {

ext {
grapes_version = '1.4.0'
grapes_version = '1.5.0'

kotlin_version = '1.7.10'
firebase_app_distribution_version = '2.1.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
Expand All @@ -14,6 +15,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.spendesk.grapes.compose.theme.GrapesTheme
Expand All @@ -26,7 +28,7 @@ import com.spendesk.grapes.compose.theme.GrapesTheme
private val GrapesBucketBorderWidth = 0.2.dp

@Composable
fun GrapesBucket(
fun GrapesBucketContainer(
modifier: Modifier = Modifier,
content: @Composable () -> Unit
) {
Expand All @@ -40,17 +42,75 @@ fun GrapesBucket(
}
}

@Composable
fun GrapesBucket(
title: String,
modifier: Modifier = Modifier,
action: String? = null,
actionColor: Color? = null,
onActionClicked: (() -> Unit)? = null,
content: @Composable (() -> Unit)? = null
) {
GrapesBucketCore(
modifier = modifier,
headline = { GrapesBucketHeadline(title = title, action = action, actionColor = actionColor, onActionClicked = onActionClicked) },
content = content
)
}

// region internal

@Composable
internal fun GrapesBucketCore(
modifier: Modifier = Modifier,
headline: @Composable () -> Unit,
content: @Composable (() -> Unit)? = null
) {
GrapesBucketContainer(modifier = modifier) {
Column(modifier = Modifier.padding(GrapesTheme.dimensions.paddingLarge)) {
headline()

if (content != null) {
Spacer(Modifier.padding(bottom = GrapesTheme.dimensions.paddingLarge))
content()
}
}
}
}

// endregion internal

@Preview
@Composable
fun GrapesBucketPreview() {
private fun GrapesBucketPreview() {
GrapesTheme {
Column(
modifier = Modifier
.fillMaxSize()
.background(GrapesTheme.colors.mainNeutralLighter)
.verticalScroll(rememberScrollState()),
) {

GrapesBucket(
modifier = Modifier.padding(12.dp),
title = "Rick's bucket",
action = "Delete",
actionColor = GrapesTheme.colors.mainAlertNormal,
onActionClicked = { println("Clicked") },
content = {
Column {
Text(text = "Line 1")
Text(text = "Line 2")
}
}
)

GrapesBucket(
modifier = Modifier.padding(12.dp),
title = "Grapes Bucket Container Title"
)

GrapesBucketContainer(
modifier = Modifier
.padding(12.dp)
.fillMaxWidth()
Expand All @@ -63,7 +123,7 @@ fun GrapesBucketPreview() {
.padding(horizontal = 16.dp, vertical = 12.dp)
)
}
GrapesBucket(
GrapesBucketContainer(
modifier = Modifier
.padding(12.dp)
.fillMaxWidth()
Expand Down
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))
}
}
}
Loading

0 comments on commit 8a833c9

Please sign in to comment.