Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into renovate/androidx.com…
Browse files Browse the repository at this point in the history
…pose.bom

# Conflicts:
#	spark-screenshot-testing/src/test/snapshots/images/com.adevinta.spark_PreviewScreenshotTests_preview_tests_rangeslider_rangeslider_dark.png
#	spark-screenshot-testing/src/test/snapshots/images/com.adevinta.spark_PreviewScreenshotTests_preview_tests_rangeslider_rangeslider_light.png
  • Loading branch information
soulcramer committed Aug 2, 2023
2 parents 59ffdb8 + 2472f4e commit 05d833a
Show file tree
Hide file tree
Showing 316 changed files with 2,642 additions and 1,418 deletions.
2 changes: 1 addition & 1 deletion .github/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
commitizen ==3.5.3
commitizen ==3.6.0
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

## [Unreleased]

## [0.3.1]

_2023-07-31_

* 🆕 Added `Basic` and `Accent` intents to all released components.
* 💄Updated the default color intents to `Basic` for `Tag`, `Chip`, `Spinner`.
* 🗑️ Deprecated `Primary` and `Secondary` intents, `Main` and `Support`should be used instead.

## [0.3.0]

_2023-07-11_
Expand Down Expand Up @@ -66,7 +74,9 @@ _2023-03-29_

<!-- Links -->

[Unreleased]: https://github.com/adevinta/spark-android/compare/0.3.0...HEAD
[Unreleased]: https://github.com/adevinta/spark-android/compare/0.3.1...HEAD

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

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

Expand Down
45 changes: 33 additions & 12 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,43 @@
- Add the new version section and move the *unreleased changes* into it.
- Update the links at the end of the page.
3. Commit and push the changes to a new PR
```bash
git commit -am "chore: prepare version X.Y.X"
git push
```
```bash
git commit -am "chore: prepare version X.Y.X"
git push
```
4. Once the PR is merged, tag the release on the `main` branch
```bash
git fetch
git tag X.Y.Z origin/main
git push origin X.Y.Z
```
```bash
git fetch
git tag X.Y.Z origin/main
git push origin X.Y.Z
```
5. Wait for the [publishing workflow](https://github.com/adevinta/spark-android/actions/workflows/publish.yml) to build and publish the release.
6. Update the `version` in [gradle.properties](gradle.properties) to the next `SNAPSHOT` version.
7. Commit and push the changes to a new PR
```bash
git commit -am "chore: prepare next development version"
```
```bash
git commit -am "chore: prepare next development version"
```
8. Go to [Sonatype Nexus](https://s01.oss.sonatype.org/) to promote (close then release) the artifact ([docs & detailed steps](https://central.sonatype.org/publish/release/)). Or drop it if there is a problem!
9. Trigger the manual workflow [![📋 Publish Dokka to GitHub Pages](https://github.com/adevinta/spark-android/actions/workflows/dokka.yml/badge.svg)](https://github.com/adevinta/spark-android/actions/workflows/dokka.yml) with the version tag.
10. Draft a [new release](https://github.com/adevinta/spark-android/releases/new) with the version tag, add the corresponding [CHANGELOG.md](CHANGELOG.md) entries, and publish it when ready.

---

## Hotfix

Hotfixes can sometimes be a bit tricky to do right. Please follow these steps carefully:

1. Create the hotfix remote branch (the `hotfix` prefix is important)
```bash
git push origin refs/tags/X.Y.Z:refs/heads/hotfix/X.Y.Z+1
```
2. Create a local hotfix PR branch
```bash
git switch --create patch-hotfix-X.Y.Z+1 refs/tags/X.Y.Z
```
3. Commit the necessary changes and open a PR targeting the hotfix branch.
4. Once the PR is merged, you can continue with the regular release process described above.
5. Finally, merge these changes back to the main branch with a new PR
```bash
git merge --no-ff refs/tags/X.Y.Z+1
```
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ internal fun CatalogApp(
.calculateBottomPadding(),
peekHeight = BackdropScaffoldDefaults.PeekHeight + WindowInsets.statusBars.asPaddingValues()
.calculateTopPadding(),
backLayerBackgroundColor = SparkTheme.colors.primaryContainer,
backLayerBackgroundColor = SparkTheme.colors.mainContainer,
appBar = {
HomeTabBar(
modifier = Modifier.statusBarsPadding(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public fun BackdropScaffold(
headerHeight: Dp = BackdropScaffoldDefaults.HeaderHeight,
persistentAppBar: Boolean = true,
stickyFrontLayer: Boolean = true,
backLayerBackgroundColor: Color = SparkTheme.colors.primary,
backLayerBackgroundColor: Color = SparkTheme.colors.main,
backLayerContentColor: Color = contentColorFor(backLayerBackgroundColor),
frontLayerShape: Shape = BackdropScaffoldDefaults.frontLayerShape,
frontLayerElevation: Dp = BackdropScaffoldDefaults.FrontLayerElevation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private fun ButtonSample() {
var iconSide by remember { mutableStateOf(IconSide.START) }
var style by remember { mutableStateOf(ButtonStyle.Filled) }
var size by remember { mutableStateOf(ButtonSize.Medium) }
var intent by remember { mutableStateOf(ButtonIntent.Primary) }
var intent by remember { mutableStateOf(ButtonIntent.Main) }
var buttonText by remember { mutableStateOf("Filled Button") }

ConfigedButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.adevinta.spark.catalog.configurator.samples.checkboxes
package com.adevinta.spark.catalog.configurator.samples.toggles

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -78,7 +78,7 @@ private fun CheckboxSample() {
var contentSide by remember { mutableStateOf(ContentSide.End) }
var label: String? by remember { mutableStateOf(null) }
var state by remember { mutableStateOf(ToggleableState.On) }
var intent by remember { mutableStateOf(ToggleIntent.Primary) }
var intent by remember { mutableStateOf(ToggleIntent.Main) }
val onClick = {
state = when (state) {
ToggleableState.On -> ToggleableState.Off
Expand Down Expand Up @@ -151,7 +151,7 @@ private fun CheckboxSample() {
)
Column {
Text(
text = stringResource(id = R.string.configurator_component_checkbox_content_side_label),
text = stringResource(id = R.string.configurator_component_toggle_content_side_label),
modifier = Modifier.padding(bottom = 8.dp),
style = SparkTheme.typography.body2.copy(fontWeight = FontWeight.Bold),
)
Expand All @@ -176,7 +176,7 @@ private fun CheckboxSample() {
label = it
},
label = stringResource(id = R.string.configurator_component_screen_textfield_label),
placeholder = stringResource(id = R.string.configurator_component_checkbox_placeholder_label),
placeholder = stringResource(id = R.string.configurator_component_toggle_placeholder_label),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*
* Copyright (c) 2023 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.toggles

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.adevinta.spark.SparkTheme
import com.adevinta.spark.catalog.R
import com.adevinta.spark.catalog.model.Configurator
import com.adevinta.spark.catalog.themes.SegmentedButton
import com.adevinta.spark.catalog.util.SampleSourceUrl
import com.adevinta.spark.components.menu.DropdownMenuItem
import com.adevinta.spark.components.text.Text
import com.adevinta.spark.components.textfields.SelectTextField
import com.adevinta.spark.components.textfields.TextField
import com.adevinta.spark.components.toggles.ContentSide
import com.adevinta.spark.components.toggles.RadioButton
import com.adevinta.spark.components.toggles.RadioButtonLabelled
import com.adevinta.spark.components.toggles.SwitchLabelled
import com.adevinta.spark.components.toggles.ToggleIntent

public val RadioButtonConfigurator: Configurator = Configurator(
name = "RadioButton",
description = "RadioButton configuration",
sourceUrl = "$SampleSourceUrl/RadioButtonSamples.kt",
) {
RadioButtonSample()
}

@Preview(
showBackground = true,
)
@Composable
private fun RadioButtonSample() {
val scrollState = rememberScrollState()
val focusManager = LocalFocusManager.current
Column(
verticalArrangement = Arrangement.spacedBy(16.dp),
modifier = Modifier.verticalScroll(scrollState),
) {
var isEnabled by remember { mutableStateOf(true) }
var contentSide by remember { mutableStateOf(ContentSide.End) }
var label: String? by remember { mutableStateOf(null) }
var selected by remember { mutableStateOf(false) }
var intent by remember { mutableStateOf(ToggleIntent.Main) }
val onClick = { selected = !selected }
ConfigedRadioButton(
label = label,
onClick = onClick,
selected = selected,
isEnabled = isEnabled,
intent = intent,
contentSide = contentSide,
)
SwitchLabelled(
checked = isEnabled,
onCheckedChange = {
isEnabled = it
focusManager.clearFocus()
},
) {
Text(
text = stringResource(id = R.string.configurator_component_screen_enabled_label),
modifier = Modifier.fillMaxWidth(),
)
}
val intents = ToggleIntent.values()
var expanded by remember { mutableStateOf(false) }
SelectTextField(
modifier = Modifier.fillMaxWidth(),
value = intent.name,
onValueChange = {},
readOnly = true,
label = stringResource(id = R.string.configurator_component_screen_intent_label),
expanded = expanded,
onExpandedChange = { expanded = !expanded },
onDismissRequest = { expanded = false },
dropdownContent = {
intents.forEach {
DropdownMenuItem(
text = { Text(it.name) },
onClick = {
intent = it
expanded = false
},
)
}
},
)
Column {
Text(
text = stringResource(id = R.string.configurator_component_toggle_content_side_label),
modifier = Modifier.padding(bottom = 8.dp),
style = SparkTheme.typography.body2.copy(fontWeight = FontWeight.Bold),
)
val contentSides = ContentSide.values()
val contentSidesLabel = contentSides.map { it.name }
SegmentedButton(
options = contentSidesLabel,
selectedOption = contentSide.name,
onOptionSelect = {
contentSide = ContentSide.valueOf(it)
focusManager.clearFocus()
},
modifier = Modifier
.fillMaxWidth()
.height(48.dp),
)
}
TextField(
modifier = Modifier.fillMaxWidth(),
value = label.orEmpty(),
onValueChange = {
label = it
},
label = stringResource(id = R.string.configurator_component_screen_textfield_label),
placeholder = stringResource(id = R.string.configurator_component_toggle_placeholder_label),
)
}
}

@Composable
private fun ConfigedRadioButton(
modifier: Modifier = Modifier,
label: String?,
onClick: () -> Unit,
selected: Boolean,
isEnabled: Boolean,
contentSide: ContentSide,
intent: ToggleIntent,
) {
if (label.isNullOrBlank().not()) {
RadioButtonLabelled(
modifier = modifier,
enabled = isEnabled,
selected = selected,
onClick = onClick,
contentSide = contentSide,
intent = intent,
) { Text(text = label!!) }
} else {
RadioButton(
modifier = modifier,
enabled = isEnabled,
selected = selected,
onClick = onClick,
intent = intent,
)
}
}
Loading

0 comments on commit 05d833a

Please sign in to comment.