Skip to content

Commit

Permalink
Merge pull request #184 from Spendesk/release/1.7.0
Browse files Browse the repository at this point in the history
Release/1.7.0
  • Loading branch information
jpbarbaud authored Mar 20, 2023
2 parents efa9b24 + c0b1fa7 commit 1d3f29f
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 159 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.6.0'
grapes_version = '1.7.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
@@ -1,109 +1,62 @@
package com.spendesk.grapes.compose.bucket

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
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 androidx.compose.ui.unit.dp
import com.spendesk.grapes.compose.theme.GrapesTheme

/**
* @author jean-philippe
* @since 15/03/2023, Wednesday
* @since 20/03/2023, Monday
**/

@Immutable
object GrapesBucketDefaults {
private val BorderWidth = 0.2.dp
private val BucketPadding = 16.dp

@Composable
fun DefaultGrapesBucketDecorationBox(
modifier: Modifier = Modifier,
contentPaddingValues: PaddingValues = bucketPadding(),
innerContent: @Composable () -> Unit
) {
Box(
modifier = modifier
.background(GrapesTheme.colors.mainWhite, GrapesTheme.shapes.medium)
.border(BorderWidth, GrapesTheme.colors.mainNeutralNormal, GrapesTheme.shapes.medium)
.clip(GrapesTheme.shapes.medium)
.padding(contentPaddingValues)
) {
innerContent()
}
}

fun bucketPadding(
start: Dp = BucketPadding,
top: Dp = BucketPadding,
end: Dp = BucketPadding,
bottom: Dp = BucketPadding
): PaddingValues = PaddingValues(start, top, end, bottom)
}

@Composable
fun GrapesBucket(
title: String,
modifier: Modifier = Modifier,
action: String? = null,
actionColor: Color? = null,
onActionClicked: (() -> Unit)? = null,
decorationBox: @Composable (innerContent: @Composable () -> Unit) -> Unit =
@Composable { innerContent ->
GrapesBucketDefaults.DefaultGrapesBucketDecorationBox(innerContent = innerContent)
},
content: @Composable (() -> Unit)? = null
) {
val headLine = @Composable {
GrapesBucketHeadline(
title = title,
action = action,
actionColor = actionColor,
onActionClicked = onActionClicked
)
}

GrapesBucket(
GrapesBucketCore(
modifier = modifier,
decorationBox = decorationBox,
headline = headLine,
headline = { GrapesBucketHeadline(title = title, action = action, actionColor = actionColor, onActionClicked = onActionClicked) },
content = content
)
}

// region internal

@Composable
fun GrapesBucket(
internal fun GrapesBucketCore(
modifier: Modifier = Modifier,
decorationBox: @Composable (innerContent: @Composable () -> Unit) -> Unit =
@Composable { innerContent ->
GrapesBucketDefaults.DefaultGrapesBucketDecorationBox(innerContent = innerContent)
},
headline: @Composable (() -> Unit)? = null,
content: @Composable (() -> Unit)? = null,
headline: @Composable () -> Unit,
content: @Composable (() -> Unit)? = null
) {
GrapesBucketCore(
modifier = modifier,
headline = headline,
content = content,
decorationBox = decorationBox,
)
GrapesBucketContainer(modifier = modifier) {
Column {
headline()

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

// endregion internal

@Preview
@Composable
private fun GrapesBucketPreview() {
Expand All @@ -112,11 +65,11 @@ private fun GrapesBucketPreview() {
modifier = Modifier
.fillMaxSize()
.background(GrapesTheme.colors.mainNeutralLighter)
.padding(12.dp)
.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {

GrapesBucket(
modifier = Modifier.padding(12.dp),
title = "Rick's bucket",
action = "Delete",
actionColor = GrapesTheme.colors.mainAlertNormal,
Expand All @@ -130,38 +83,9 @@ private fun GrapesBucketPreview() {
)

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

val headline = @Composable {
Text(text = "This is a headline composable")
}

val content = @Composable {
Text(text = "This is a content composable")
}

GrapesBucket(
headline = headline,
content = content
)

val customDecorationBox: @Composable (innerContent: @Composable () -> Unit) -> Unit = @Composable { innerContent ->
Box(
modifier = Modifier
.background(Color.Yellow, GrapesTheme.shapes.medium)
.clip(GrapesTheme.shapes.medium)
.padding(4.dp)
) {
innerContent()
}
}

GrapesBucket(
headline = headline,
content = content,
decorationBox = customDecorationBox,
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.spendesk.grapes.compose.bucket

import androidx.compose.foundation.background
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.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
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.draw.clip
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.spendesk.grapes.compose.theme.GrapesTheme

/**
* @author Kélian CLERC
* @since 06/12/2022
*/

private val GrapesBucketBorderWidth = 0.2.dp

@Composable
fun GrapesBucketContainer(
modifier: Modifier = Modifier,
content: @Composable () -> Unit
) {
Box(
modifier = modifier
.background(GrapesTheme.colors.mainWhite, GrapesTheme.shapes.medium)
.border(GrapesBucketBorderWidth, GrapesTheme.colors.mainNeutralNormal, GrapesTheme.shapes.medium)
.clip(GrapesTheme.shapes.medium)
) {
content()
}
}

@Preview
@Composable
private fun GrapesContainerPreview() {
GrapesTheme {
Column(
modifier = Modifier
.fillMaxSize()
.background(GrapesTheme.colors.mainNeutralLighter)
.verticalScroll(rememberScrollState()),
) {
GrapesBucketContainer(
modifier = Modifier
.padding(12.dp)
.fillMaxWidth()
) {
Text(
text = "Bucket content",
modifier = Modifier
.fillMaxSize()
.clickable { println("Clicked") }
.padding(horizontal = 16.dp, vertical = 12.dp)
)
}
GrapesBucketContainer(
modifier = Modifier
.padding(12.dp)
.fillMaxWidth()
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 12.dp)
) {
Text(text = "Line 1")
Text(text = "Line 2")
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.spendesk.grapes.compose.theme.GrapesTheme
* @since : 06/03/2023, Mon
**/
@Composable
fun GrapesBucketHeadline(
internal fun GrapesBucketHeadline(
title: String,
modifier: Modifier = Modifier,
action: String? = null,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.spendesk.grapes.compose.R
import com.spendesk.grapes.compose.bucket.GrapesBucket
import com.spendesk.grapes.compose.bucket.GrapesBucketContainer
import com.spendesk.grapes.compose.icons.Size
import com.spendesk.grapes.compose.icons.StatusInformationIcon
import com.spendesk.grapes.compose.model.GrapesConfigurationStatus
Expand Down Expand Up @@ -90,14 +90,15 @@ private fun IconActionPreview() {
) {
IconAction(iconActionConfiguration = alertConfiguration)
IconAction(iconActionConfiguration = infoConfigurationWithoutDescription)
GrapesBucket(
GrapesBucketContainer(
modifier = Modifier
.fillMaxWidth()
.padding(12.dp)
.fillMaxWidth()
) {
IconAction(
modifier = Modifier
.fillMaxWidth(),
.fillMaxWidth()
.padding(16.dp),
iconActionConfiguration = infoConfigurationWithDescription
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import com.spendesk.grapes.compose.theme.GrapesTheme
@Composable
fun GrapesCheckbox(
isChecked: Boolean,
onCheckedChange: ((Boolean) -> Unit),
onCheckedChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
isEnabled: Boolean = true,
) =
Expand Down
Loading

0 comments on commit 1d3f29f

Please sign in to comment.