Skip to content

Commit

Permalink
Merge branch 'main' into kotlin-2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonMarquis authored Apr 27, 2024
2 parents 1cb97b1 + 30a7ecf commit 856a7cd
Show file tree
Hide file tree
Showing 85 changed files with 2,069 additions and 1,182 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-gradle/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: 'Gradle setup and wrapper validation'
runs:
using: composite
steps:
- uses: gradle/actions/setup-gradle@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0
- uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
with:
validate-wrappers: true
gradle-home-cache-cleanup: true
Expand Down
49 changes: 47 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,55 @@

## [Unreleased]

## [0.9.0]

_2024-04-23_

### Spark

* 🎨 Add a new intent param to the `Popover`
#### 🆕 Chips can now be selectable and closed
> [!CAUTION]
> The `Filled` style has been removed and may break your build if used. You need to see with your ui to know which styles to use instead of this one
> [!WARNING]
> The styles for chips have been deprecated you now need to use either the `Chip` or the `ChipSelectable` components for your need and provide the style in argument
If you want to make your Chip closable then you will need to add a callback action in the new `onClose` parameter.

---

#### 🆕 BottomSheet now use the spark specs
> [!CAUTION]
> This change will most likely break your build since most of the api has changed.
> We now use the M3 `BottomSheet` instead of a fork from a alpha version of it we did when it was only available in M2.
> [!WARNING]
> The `BottomSheet` currently only accept M3 snackbars, you won't be able to display a SparkSnackbar
---

- 🆕 ProgressTracker is now available! it still has a few minor visual bugs but it can be tested by squads on their scope don't hesitate to give us feedbacks!
- 🆕 `TextLinkButton` will now use `LocalContentColor` when using the Surface intent. This will allow you to have a `onSurface` `TextLink` when needed
- 🆕 `Popover` can now take an intent for its surface color
- 🆕 `Image` has its `emptyIcon` and `errorIcon` parameters open now for special cases
- 💬 A11y have been translated to german
- 💄 `Rating` will now have a lisible color when disabled
- 💄 Badge now use surface instead of onColor for its border color
- 🐛 Filled and Contrast `Button` now have a clear disabled state when their content color is dark
- 💄 New icons have been added

### Catalog App

- 🎨 Brand colors has been updated to their latest values
- 🔧 All Configurators are now scrollable

### CI

- 🔧 Decorrelated spotless and ktlint
- 🆕 Added Paparazzi as a manual workflow
- 🆕 Ran Lava Vulnerability Scanner on CI workflow
- 🔧 Moved code formatting tasks first in the contributing list

## [0.8.0]

_2024-02-28_
Expand Down Expand Up @@ -220,7 +263,9 @@ _2023-03-29_

<!-- Links -->

[Unreleased]: https://github.com/adevinta/spark-android/compare/0.8.0...HEAD
[Unreleased]: https://github.com/adevinta/spark-android/compare/0.9.0...HEAD

[0.9.0]: https://github.com/adevinta/spark-android/releases/tag/0.9.0

[0.8.0]: https://github.com/adevinta/spark-android/releases/tag/0.8.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ import androidx.compose.ui.zIndex
import com.adevinta.spark.SparkTheme
import com.adevinta.spark.catalog.backdrop.BackdropValue.Concealed
import com.adevinta.spark.catalog.backdrop.BackdropValue.Revealed
import com.adevinta.spark.components.bottomsheet.PreUpPostDownNestedScrollConnection
import com.adevinta.spark.components.bottomsheet.SwipeableDefaults
import com.adevinta.spark.components.bottomsheet.SwipeableState
import com.adevinta.spark.components.bottomsheet.swipeable
import com.adevinta.spark.components.bottomsheet.layout.PreUpPostDownNestedScrollConnection
import com.adevinta.spark.components.bottomsheet.layout.SwipeableDefaults
import com.adevinta.spark.components.bottomsheet.layout.SwipeableState
import com.adevinta.spark.components.bottomsheet.layout.swipeable
import com.adevinta.spark.components.snackbars.SnackbarHost
import com.adevinta.spark.components.snackbars.SnackbarHostState
import com.adevinta.spark.components.surface.Surface
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
/*
* Copyright (c) 2023-2024 Adevinta
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.adevinta.spark.catalog.configurator.samples.bottomsheet

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.SheetState
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import com.adevinta.spark.SparkTheme
import com.adevinta.spark.catalog.model.Configurator
import com.adevinta.spark.catalog.util.SampleSourceUrl
import com.adevinta.spark.components.bottomsheet.BottomSheet
import com.adevinta.spark.components.bottomsheet.DragHandle
import com.adevinta.spark.components.buttons.ButtonFilled
import com.adevinta.spark.components.buttons.ButtonIntent
import com.adevinta.spark.components.icons.Icon
import com.adevinta.spark.components.image.Illustration
import com.adevinta.spark.components.image.Image
import com.adevinta.spark.components.list.ListItem
import com.adevinta.spark.components.menu.DropdownMenuItem
import com.adevinta.spark.components.spacer.VerticalSpacer
import com.adevinta.spark.components.text.Text
import com.adevinta.spark.components.text.TextLinkButton
import com.adevinta.spark.components.textfields.SelectTextField
import com.adevinta.spark.components.toggles.SwitchLabelled
import com.adevinta.spark.icons.LikeFill
import com.adevinta.spark.icons.SparkIcons
import com.adevinta.spark.icons.Store
import com.adevinta.spark.tokens.highlight
import kotlinx.coroutines.launch

public val BottomSheetConfigurator: Configurator = Configurator(
name = "BottomSheet",
description = "BottomSheet configuration",
sourceUrl = "$SampleSourceUrl/BottomSheetSamples.kt",
) {
BottomSheetSample()
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun ColumnScope.BottomSheetSample() {
var isDragHandlerEnabled by remember { mutableStateOf(true) }
var openBottomSheet by rememberSaveable { mutableStateOf(false) }
var skipPartiallyExpanded by remember { mutableStateOf(false) }
var bottomSheetContentExample by remember { mutableStateOf(BottomSheetContentExamples.Text) }

val bottomSheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = skipPartiallyExpanded,
)
val scope = rememberCoroutineScope()

SwitchLabelled(
checked = isDragHandlerEnabled,
onCheckedChange = {
isDragHandlerEnabled = it
},
) {
Text(
text = "Show Drag Handle",
modifier = Modifier.fillMaxWidth(),
)
}

SwitchLabelled(
checked = skipPartiallyExpanded,
onCheckedChange = {
skipPartiallyExpanded = it
},
) {
Text(
text = "Skip Partially Expanded",
modifier = Modifier.fillMaxWidth(),
)
}

val contentExamples = BottomSheetContentExamples.entries.toTypedArray()
var expanded by remember { mutableStateOf(false) }
SelectTextField(
modifier = Modifier.fillMaxWidth(),
value = bottomSheetContentExample.name,
onValueChange = {},
readOnly = true,
label = "BottomSheet Content Example",
expanded = expanded,
onExpandedChange = { expanded = !expanded },
onDismissRequest = { expanded = false },
dropdownContent = {
contentExamples.forEach {
DropdownMenuItem(
text = { Text(it.name) },
onClick = {
bottomSheetContentExample = it
expanded = false
},
)
}
},
)

VerticalSpacer(24.dp)

ButtonFilled(
text = "Show BottomSheet",
onClick = { openBottomSheet = !openBottomSheet },
)

ConfiguredBottomSheet(
bottomSheetContentExample = bottomSheetContentExample,
openBottomSheet = openBottomSheet,
isDragHandlerEnabled = isDragHandlerEnabled,
onDismissRequest = { openBottomSheet = false },
onHideBottomSheetClicked = {
scope.launch { bottomSheetState.hide() }.invokeOnCompletion {
if (!bottomSheetState.isVisible) {
openBottomSheet = false
}
}
},
bottomSheetState = bottomSheetState,
)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun ConfiguredBottomSheet(
bottomSheetContentExample: BottomSheetContentExamples,
openBottomSheet: Boolean,
isDragHandlerEnabled: Boolean,
onDismissRequest: () -> Unit,
onHideBottomSheetClicked: () -> Unit,
bottomSheetState: SheetState,
) {
if (openBottomSheet) {
BottomSheet(
dragHandle = if (isDragHandlerEnabled) {
{ DragHandle() }
} else {
null
},
onDismissRequest = onDismissRequest,
sheetState = bottomSheetState,
) {
when (bottomSheetContentExample) {
BottomSheetContentExamples.Text -> TextContent()
BottomSheetContentExamples.Image -> ImageContent()
BottomSheetContentExamples.Illustration -> IllustrationContent()
BottomSheetContentExamples.List -> ListContent(onHideBottomSheetClicked)
}
}
}
}

@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun ListContent(onHideBottomSheetClicked: () -> Unit) {
LazyColumn {
stickyHeader {
Row(horizontalArrangement = Arrangement.Center) {
// Note: If you provide logic outside of onDismissRequest to remove the sheet,
// you must additionally handle intended state cleanup, if any.
ButtonFilled(
modifier = Modifier.padding(24.dp),
text = "Hide Bottom Sheet",
onClick = onHideBottomSheetClicked,
)
}
}

items(50) {
ListItem(
headlineContent = { Text("Item $it") },
leadingContent = {
Icon(
SparkIcons.LikeFill,
contentDescription = "Localized description",
)
},
)
}
}
}

@Composable
private fun TextContent() {
Column(modifier = Modifier.padding(16.dp)) {
Text(
text = "Title",
modifier = Modifier.padding(bottom = 16.dp),
style = SparkTheme.typography.headline1.highlight,
)
Text(
text = "Do you want to have this cookie now?",
modifier = Modifier.padding(bottom = 16.dp),
style = SparkTheme.typography.body2.highlight,
)
TextLinkButton(
text = "Text Link",
onClick = {},
intent = ButtonIntent.Alert,
)
}
}

@Composable
private fun ImageContent() {
Box(
contentAlignment = Alignment.TopCenter,
) {
Image(
modifier = Modifier
.height(500.dp)
.fillMaxWidth(),
model = "https://upload.wikimedia.org/wikipedia/commons/f/fd/Pink_flower.jpg",
contentScale = ContentScale.Crop,
contentDescription = null,
)
}
}

@Composable
private fun IllustrationContent() {
Illustration(
sparkIcon = SparkIcons.Store,
contentDescription = null,
modifier = Modifier.size(100.dp),
)
}

public enum class BottomSheetContentExamples {
Text,
Image,
Illustration,
List,
}
Loading

0 comments on commit 856a7cd

Please sign in to comment.