Skip to content

Commit

Permalink
Merge pull request #113 from vanpra/0.6.1
Browse files Browse the repository at this point in the history
Library Version 0.6.1
  • Loading branch information
PranavMaganti authored Oct 7, 2021
2 parents d785e4b + 1efc793 commit 2d253be
Show file tree
Hide file tree
Showing 32 changed files with 74 additions and 56 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

### 0.6.1 - 2021-10-07

- Update compose to 1.1.0-alpha05 ([#112](https://github.com/vanpra/compose-material-dialogs/issues/112) and [#110](https://github.com/vanpra/compose-material-dialogs/issues/110))
- Update kotlin to 1.5.31
- Make compose animation dependency explicit to ensure an old version is not used (thanks **[skolson](https://github.com/skolson)**)

### 0.6.0 - 2021-09-10

- [BREAKING CHANGE] Replace MaterialDialog class structure with composable function with state. See [docs](https://vanpra.github.io/compose-material-dialogs) and the [sample app](https://github.com/vanpra/compose-material-dialogs/tree/main/app/src/main/java/com/vanpra/composematerialdialogdemos/demos) for examples
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ae8d455118164f43a24732761a970cc8)](https://www.codacy.com/gh/vanpra/compose-material-dialogs/dashboard?utm_source=github.com&utm_medium=referral&utm_content=vanpra/compose-material-dialogs&utm_campaign=Badge_Grade)![Build & Test](https://github.com/vanpra/compose-material-dialogs/actions/workflows/main.yml/badge.svg)

**Current Library Compose Version: 1.1.0-alpha03**
**Current Library Compose Version: 1.1.0-alpha05**

### [See Releases and Changelog](https://github.com/vanpra/compose-material-dialogs/blob/main/CHANGELOG.md)

Expand All @@ -19,7 +19,7 @@
```gradle
dependencies {
...
implementation "io.github.vanpra.compose-material-dialogs:core:0.6.0"
implementation "io.github.vanpra.compose-material-dialogs:core:0.6.1"
...
}
```
Expand All @@ -35,7 +35,7 @@ dependencies {
```gradle
dependencies {
...
implementation "io.github.vanpra.compose-material-dialogs:datetime:0.6.0"
implementation "io.github.vanpra.compose-material-dialogs:datetime:0.6.1"
...
}
```
Expand All @@ -51,7 +51,7 @@ dependencies {
```gradle
dependencies {
...
implementation "io.github.vanpra.compose-material-dialogs:color:0.6.0"
implementation "io.github.vanpra.compose-material-dialogs:color:0.6.1"
...
}
```
Expand Down
4 changes: 4 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ dependencies {

implementation(Dependencies.Kotlin.stdlib)
implementation(Dependencies.Google.material)
implementation(Dependencies.AndroidX.coreKtx)

implementation(Dependencies.AndroidX.Compose.ui)
implementation(Dependencies.AndroidX.Compose.material)
implementation(Dependencies.AndroidX.Compose.materialIconsExtended)
implementation(Dependencies.AndroidX.Compose.animation)
implementation(Dependencies.AndroidX.Compose.foundationLayout)

implementation(Dependencies.AndroidX.Compose.activity)
implementation(Dependencies.AndroidX.Compose.navigation)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ fun BasicListDialogDemo() {
DialogAndShowButton(buttonText = "Custom List Dialog") {
title(res = R.string.backup_dialog_title)
listItems(
emails,
modifier = Modifier.padding(bottom = 8.dp).padding(horizontal = 24.dp),
list = emails,
item = { _, email ->
Row(Modifier.fillMaxWidth()) {
Image(
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {

dependencies {
classpath(Dependencies.Kotlin.gradlePlugin)
classpath("com.android.tools.build:gradle:7.1.0-alpha11")
classpath("com.android.tools.build:gradle:7.1.0-alpha13")
classpath("com.vanniktech:gradle-maven-publish-plugin:0.17.0")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.5.0")
classpath(Dependencies.Shot.core)
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/CommonModulePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class CommonModulePlugin: Plugin<Project> {
implementation(Dependencies.AndroidX.Compose.ui)
implementation(Dependencies.AndroidX.Compose.material)
implementation(Dependencies.AndroidX.Compose.materialIconsExtended)
implementation(Dependencies.AndroidX.Compose.animation)
implementation(Dependencies.AndroidX.Compose.foundationLayout)

androidTestImplementation(Dependencies.AndroidX.Compose.activity)
androidTestImplementation(Dependencies.AndroidX.Compose.testing)
Expand Down
22 changes: 12 additions & 10 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ object Dependencies {
const val desugar = "com.android.tools:desugar_jdk_libs:1.1.5"

object ComposeMaterialDialogs {
const val version = "0.5.1"
const val version = "0.6.0"

const val core = "io.github.vanpra.compose-material-dialogs:core:$version"
const val datetime = "io.github.vanpra.compose-material-dialogs:datetime:$version"
Expand All @@ -14,12 +14,12 @@ object Dependencies {
}

object Accompanist {
private const val version = "0.18.0"
private const val version = "0.19.0"
const val pager = "com.google.accompanist:accompanist-pager:$version"
}

object Kotlin {
private const val version = "1.5.30"
private const val version = "1.5.31"
const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version"
const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version"
}
Expand All @@ -31,30 +31,32 @@ object Dependencies {
}

object Google {
const val material = "com.google.android.material:material:1.5.0-alpha02"
const val material = "com.google.android.material:material:1.5.0-alpha04"
}

object AndroidX {
const val coreKtx = "androidx.core:core-ktx:1.7.0-alpha02"
const val coreKtx = "androidx.core:core-ktx:1.7.0-beta02"

object Testing {
const val version = "1.4.1-alpha01"
const val version = "1.4.1-alpha03"
const val core = "androidx.test:core:$version"
const val rules = "androidx.test:rules:$version"
const val runner = "androidx.test:runner:$version"
}

object Compose {
const val version = "1.1.0-alpha03"
const val version = "1.1.0-alpha05"

const val ui = "androidx.compose.ui:ui:$version"
const val material = "androidx.compose.material:material:$version"
const val materialIconsExtended =
"androidx.compose.material:material-icons-extended:$version"
const val animation = "androidx.compose.animation:animation:$version"
const val foundationLayout = "androidx.compose.foundation:foundation-layout:$version"

const val testing = "androidx.compose.ui:ui-test-junit4:1.1.0-alpha03"
const val activity = "androidx.activity:activity-compose:1.4.0-alpha01"
const val navigation = "androidx.navigation:navigation-compose:2.4.0-alpha08"
const val testing = "androidx.compose.ui:ui-test-junit4:$version"
const val activity = "androidx.activity:activity-compose:1.4.0-beta01"
const val navigation = "androidx.navigation:navigation-compose:2.4.0-alpha10"
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.SemanticsActions
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performGesture
import androidx.compose.ui.test.performSemanticsAction
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.swipeLeft
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.vanpra.composematerialdialogs.color.ARGBPickerState
Expand Down Expand Up @@ -157,7 +157,7 @@ class ColorPickerDialogTests {
}
}

composeTestRule.onDialogColorPicker().performGesture { swipeLeft() }
composeTestRule.onDialogColorPicker().performTouchInput { swipeLeft() }
composeTestRule.waitForIdle()

composeTestRule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.vanpra.composematerialdialogs.color.test.screenshot
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performGesture
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.swipeLeft
import com.karumi.shot.ScreenshotTest
import com.vanpra.composematerialdialogs.color.ARGBPickerState
Expand Down Expand Up @@ -66,7 +66,7 @@ class ColorPickerDialogTests : ScreenshotTest {
}
}

composeTestRule.onDialogColorPicker().performGesture { swipeLeft() }
composeTestRule.onDialogColorPicker().performTouchInput { swipeLeft() }
composeTestRule.waitForIdle()
compareScreenshot(composeTestRule.onDialog())
}
Expand All @@ -84,7 +84,7 @@ class ColorPickerDialogTests : ScreenshotTest {
}
}

composeTestRule.onDialogColorPicker().performGesture { swipeLeft() }
composeTestRule.onDialogColorPicker().performTouchInput { swipeLeft() }
composeTestRule.waitForIdle()
compareScreenshot(composeTestRule.onDialog())
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class ListDialog {
DialogWithContent(dialogState = dialogState) {
title(res = R.string.backup_dialog_title)
listItems(
emails,
list = emails,
onClick = { index, item -> selectedItem = Pair(index, item) }
) { _, email ->
Row(Modifier.fillMaxWidth()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ListDialog : ScreenshotTest {
DialogWithContent {
title(res = R.string.backup_dialog_title)
listItems(
emails,
list = emails,
item = { _, email ->
Row(Modifier.fillMaxWidth()) {
Image(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ fun MaterialDialog(

BoxWithConstraints {
val maxHeight = if (isLargeDevice()) {
LocalConfiguration.current.screenHeightDp.dp - 90.dp
LocalConfiguration.current.screenHeightDp.dp - 96.dp
} else {
560.dp
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ internal fun MaterialDialogScope.DialogButtonsLayout(
content: @Composable MaterialDialogButtons.() -> Unit
) {
val interButtonPadding = with(LocalDensity.current) { 12.dp.toPx().toInt() }
val defaultBoxHeight = with(LocalDensity.current) { 36.dp.toPx().toInt() }
val defaultBoxHeight = with(LocalDensity.current) { 52.dp.toPx().toInt() }
val defaultButtonHeight = with(LocalDensity.current) { 36.dp.toPx().toInt() }
val accessibilityPadding = with(LocalDensity.current) { 12.dp.toPx().toInt() }
val verticalPadding = with(LocalDensity.current) { 4.dp.toPx().toInt() }
val verticalPadding = with(LocalDensity.current) { 8.dp.toPx().toInt() }

Layout(
{ content(dialogButtons) },
Expand All @@ -61,7 +62,7 @@ internal fun MaterialDialogScope.DialogButtonsLayout(

val placeables = measurables.map {
(it.layoutId as MaterialDialogButtonTypes) to it.measure(
constraints.copy(minWidth = 0)
constraints.copy(minWidth = 0, maxHeight = defaultButtonHeight)
)
}
val totalWidth = placeables.sumOf { it.second.width }
Expand All @@ -71,10 +72,10 @@ internal fun MaterialDialogScope.DialogButtonsLayout(
if (column) {
val buttonHeight = placeables.sumOf { it.second.height }
val heightPadding = (placeables.size - 1) * interButtonPadding
buttonHeight + heightPadding
buttonHeight + heightPadding + 2 * verticalPadding
} else {
defaultBoxHeight
} + 2 * verticalPadding
}

layout(constraints.maxWidth, height) {
var currX = constraints.maxWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp

private val bottomPadding = Modifier.padding(bottom = 8.dp)

/**
* Adds a selectable list with custom items to the dialog
*
Expand All @@ -40,14 +38,19 @@ private val bottomPadding = Modifier.padding(bottom = 8.dp)
*/
@Composable
fun <T> MaterialDialogScope.listItems(
modifier: Modifier = Modifier,
list: List<T>,
closeOnClick: Boolean = true,
onClick: (index: Int, item: T) -> Unit = { _, _ -> },
isEnabled: (index: Int) -> Boolean = { _ -> true },
item: @Composable (index: Int, T) -> Unit
item: @Composable (index: Int, T) -> Unit,
) {
BoxWithConstraints {
LazyColumn(Modifier.then(bottomPadding).testTag("dialog_list")) {
LazyColumn(
Modifier
.then(modifier)
.testTag("dialog_list")
) {
itemsIndexed(list) { index, it ->
Box(
Modifier
Expand All @@ -62,7 +65,6 @@ fun <T> MaterialDialogScope.listItems(
},
enabled = isEnabled(index)
)
.padding(horizontal = 24.dp)
) {
item(index, it)
}
Expand All @@ -83,14 +85,19 @@ fun MaterialDialogScope.listItems(
closeOnClick: Boolean = true,
onClick: (index: Int, item: String) -> Unit = { _, _ -> }
) {
listItems(list = list, closeOnClick = closeOnClick, onClick = onClick) { _, item ->
listItems(
modifier = Modifier.padding(bottom = 8.dp),
list = list,
closeOnClick = closeOnClick,
onClick = onClick
) { _, item ->
Text(
item,
color = MaterialTheme.colors.onSurface,
style = MaterialTheme.typography.body1,
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 12.dp)
.padding(vertical = 12.dp, horizontal = 24.dp)
.wrapContentWidth(Alignment.Start)
)
}
Expand Down Expand Up @@ -224,7 +231,8 @@ private fun MultiChoiceItem(
Row(
Modifier
.fillMaxWidth()
.height(48.dp),
.height(48.dp)
.padding(start = 12.dp, end = 24.dp),
verticalAlignment = Alignment.CenterVertically
) {
Checkbox(checked = selected, onCheckedChange = { onChecked(index) }, enabled = enabled)
Expand Down Expand Up @@ -256,7 +264,8 @@ private fun SingleChoiceItem(
Row(
Modifier
.fillMaxWidth()
.height(48.dp),
.height(48.dp)
.padding(start = 12.dp, end = 24.dp),
verticalAlignment = Alignment.CenterVertically
) {
RadioButton(
Expand Down
Loading

0 comments on commit 2d253be

Please sign in to comment.