Skip to content

Commit

Permalink
Release 1.22.0 #333
Browse files Browse the repository at this point in the history
  • Loading branch information
kelianClerc authored Jan 17, 2024
2 parents 4666fe7 + 68279a3 commit f17bdc3
Show file tree
Hide file tree
Showing 14 changed files with 511 additions and 66 deletions.
19 changes: 9 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.firebase.appdistribution) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.detekt) apply false
alias(grapesLibs.plugins.android.application) apply false
alias(grapesLibs.plugins.android.library) apply false
alias(grapesLibs.plugins.kotlin.android) apply false
alias(grapesLibs.plugins.kotlin.parcelize) apply false
alias(grapesLibs.plugins.kotlin.jvm) apply false
alias(grapesLibs.plugins.hilt) apply false
alias(grapesLibs.plugins.firebase.appdistribution) apply false
alias(grapesLibs.plugins.ksp) apply false
alias(grapesLibs.plugins.detekt) apply false
}

allprojects {
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[versions]
grapes-version = '1.21.2'
grapes-version = '1.22.0'
androidMinSdk = "21"
androidTargetSdk = "34"
androidCompileSdk = "34"

kotlin = "1.9.0"
gradle = "8.1.1"
firebase-app-distrib = "3.0.3"
gradle = "8.2.1"
firebase-app-distrib = "4.0.1"
ksp = "1.9.0-1.0.13"
detekt = "1.23.4"
detektFormatting = "1.23.4"

# Dagger
hilt = "2.48"
hilt = "2.50"

# Androidx
androidx-lifecycle-ktx = "2.6.2"
Expand Down
33 changes: 16 additions & 17 deletions library-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask

plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.detekt)
alias(grapesLibs.plugins.android.library)
alias(grapesLibs.plugins.kotlin.android)
alias(grapesLibs.plugins.detekt)
id("maven-publish")
}

android {
namespace = "com.spendesk.grapes.compose"

compileSdk = libs.versions.androidCompileSdk.get().toInt()
compileSdk = grapesLibs.versions.androidCompileSdk.get().toInt()

defaultConfig {
minSdk = libs.versions.androidMinSdk.get().toInt()
minSdk = grapesLibs.versions.androidMinSdk.get().toInt()

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -24,7 +24,7 @@ android {
}

composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.kotlin.compiler.get()
kotlinCompilerExtensionVersion = grapesLibs.versions.compose.kotlin.compiler.get()
}

compileOptions {
Expand Down Expand Up @@ -57,10 +57,10 @@ detekt {
allRules = false // activate all available (even unstable) rules.
config.setFrom("$rootDir/config/detekt/detekt-configuration.yml")
baseline = file("$projectDir/config/baseline.xml")
toolVersion = libs.plugins.detekt.get().version.requiredVersion
toolVersion = grapesLibs.plugins.detekt.get().version.requiredVersion

dependencies {
detektPlugins(libs.detekt.formatting)
detektPlugins(grapesLibs.detekt.formatting)
}
}

Expand All @@ -80,19 +80,18 @@ tasks.withType<DetektCreateBaselineTask>().configureEach {
}

dependencies {
testImplementation(libs.junit4)
androidTestImplementation(libs.junit.android)
androidTestImplementation(libs.espresso.core)
testImplementation(grapesLibs.junit4)
androidTestImplementation(grapesLibs.junit.android)
androidTestImplementation(grapesLibs.espresso.core)


api(libs.androidx.lifecycle.ktx)
api(grapesLibs.androidx.lifecycle.ktx)

// Compose
api(platform(libs.compose.bom))
api(libs.bundles.compose)
api(platform(grapesLibs.compose.bom))
api(grapesLibs.bundles.compose)

// UI Tests
androidTestImplementation(libs.compose.tests.ui)
androidTestImplementation(grapesLibs.compose.tests.ui)
}

afterEvaluate {
Expand All @@ -101,7 +100,7 @@ afterEvaluate {
register("release", MavenPublication::class) {
group = "com.github.Spendesk"
artifactId = "grapes-android-compose"
version = libs.versions.grapes.version.get()
version = grapesLibs.versions.grapes.version.get()

from(components["release"])
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.spendesk.grapes.compose.textblock

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
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.unit.dp
import com.spendesk.grapes.compose.textblock.actions.GrapesRetryTextBlockAction
import com.spendesk.grapes.compose.theme.GrapesTheme

/**
* @author Kélian CLERC
* @since 15/01/2024
*/
@Composable
fun GrapesTextBlock(
modifier: Modifier = Modifier,
header: (@Composable () -> Unit)? = null,
content: (@Composable () -> Unit)? = null,
) {
Column(
modifier = modifier
.background(GrapesTheme.colors.structureSurface, GrapesTheme.shapes.shape2)
.border(BorderStroke(0.5.dp, GrapesTheme.colors.neutralLighter), GrapesTheme.shapes.shape2)
) {
header?.invoke()
content?.invoke()
}
}

@Preview
@Composable
private fun TextBlockPreview() {
GrapesTheme {
GrapesTextBlock(
modifier = Modifier
.padding(16.dp)
.fillMaxWidth(),
header = {
GrapesTextBlockHeader(
title = "Title which is very long and need to be truncated",
informativeLabel = {
GrapesTextBlockInformativeLabel(
label = "• Missing",
color = GrapesTheme.colors.warningDark,
)
},
action = {
GrapesRetryTextBlockAction(retryLabel = "Retry", onRetryClicked = { /*TODO*/ })
},
modifier = Modifier
.padding(horizontal = GrapesTheme.dimensions.spacing3)
.padding(top = GrapesTheme.dimensions.spacing3)
)
},
content = {
Text(
text = "Content",
style = GrapesTheme.typography.bodyM,
color = GrapesTheme.colors.neutralDark,
modifier = Modifier.padding(GrapesTheme.dimensions.spacing3)
)
},
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.spendesk.grapes.compose.textblock

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
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.textblock.actions.GrapesRetryTextBlockAction
import com.spendesk.grapes.compose.theme.GrapesTheme

/**
* @author Kélian CLERC
* @since 16/01/2024
*/
@Composable
fun GrapesTextBlockHeader(
title: String,
modifier: Modifier = Modifier,
informativeLabel: (@Composable () -> Unit)? = null,
action: (@Composable () -> Unit)? = null,
) {
Row(modifier = modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
HeaderText(
title = title,
modifier = Modifier
.weight(1f),
informativeLabel = informativeLabel
)
Spacer(modifier = Modifier.width(GrapesTheme.dimensions.spacing3))
action?.invoke()
}
}

@Composable
private fun HeaderText(
title: String,
modifier: Modifier = Modifier,
informativeLabel: (@Composable () -> Unit)? = null,
) {
Row(modifier = modifier.wrapContentWidth(align = Alignment.Start), verticalAlignment = Alignment.CenterVertically) {
Text(
text = title,
style = GrapesTheme.typography.titleS,
color = GrapesTheme.colors.structureComplementary,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f, fill = false)
)
informativeLabel?.let {
Spacer(modifier = Modifier.width(GrapesTheme.dimensions.spacing1))
informativeLabel.invoke()
}
}
}

@Preview
@Composable
private fun TextBlockHeaderPreview(
@PreviewParameter(TextBlockHeaderProvider::class) item: Triple<String, String?, String?>,
) {
val informativeLabel: (@Composable () -> Unit)? = item.second?.let {
{
GrapesTextBlockInformativeLabel(
label = "$it",
color = GrapesTheme.colors.warningDark,
)
}
}
val action: (@Composable () -> Unit)? = item.third?.let {
{
GrapesRetryTextBlockAction(retryLabel = it, onRetryClicked = { /*TODO*/ })
}
}

GrapesTextBlockHeader(title = item.first, informativeLabel = informativeLabel, action = action, modifier = Modifier.padding(GrapesTheme.dimensions.spacing3))
}

private class TextBlockHeaderProvider : PreviewParameterProvider<Triple<String, String?, String?>> {
override val values = sequenceOf(
Triple("Title", null, null),
Triple("This is an example of a very long key very long key very long long very key", null, null),
Triple("Title", "Short value", null),
Triple("This is an example of a very long key very long key very long long very key", "Short value", null),
Triple("Title", null, "Short action"),
Triple("This is an example of a very long key very long key very long long very key", null, "Short action"),
Triple("Title", "Short value", "Short action"),
Triple("This is an example of a very long key", "Short value", "Short action"),
Triple("This is an example of a very long key", "Short value", "Short action"),
Triple("This is an example of a very long key", "Long value of a very long value", "Short action"),
Triple("This is an example of a very long key", "Long value of a very long value", "Long action with a very long action"),
Triple("Title", "Long value very long key very long key very long long very key", null),
Triple("This is an example of a very long key very long key very long long very key", "Long value very long key very long key very long long very key", null),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.spendesk.grapes.compose.textblock

/**
* @author Kélian CLERC
* @since 16/01/2024
*/
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
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

@Composable
fun GrapesTextBlockInformativeLabel(
label: String,
color: Color,
modifier: Modifier = Modifier
) {
Row(
modifier = modifier,
horizontalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.spacing2),
verticalAlignment = Alignment.CenterVertically
) {
Spacer(
modifier = Modifier
.size(4.dp)
.background(color, shape = GrapesTheme.shapes.shape4)
)
Text(
text = label,
style = GrapesTheme.typography.bodyM,
color = color,
maxLines = 1,
)
}
}

@Preview
@Composable
private fun TextBlockOptionalTitlePreview() {
GrapesTheme {
Column(
modifier = Modifier.padding(GrapesTheme.dimensions.paddingLarge),
verticalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.paddingLarge)
) {
GrapesTextBlockInformativeLabel("Missing", color = GrapesTheme.colors.warningNormal)
GrapesTextBlockInformativeLabel("Optional", color = GrapesTheme.colors.neutralNormal)
}
}
}
Loading

0 comments on commit f17bdc3

Please sign in to comment.