From 8b2df857cfac2f13ae8ebf9ccbd908af37ced0cc Mon Sep 17 00:00:00 2001 From: Pranav Maganti Date: Sun, 10 Jul 2022 14:06:53 +0100 Subject: [PATCH 1/4] Update compose to 1.2.0-rc03 --- app/build.gradle.kts | 8 +++----- buildSrc/src/main/kotlin/Dependencies.kt | 17 +++++++++-------- color/build.gradle.kts | 6 +++--- core/build.gradle.kts | 6 +++--- datetime/build.gradle.kts | 6 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- test-utils/build.gradle.kts | 6 +++--- 7 files changed, 25 insertions(+), 26 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index bdcccb5f..554b149e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -5,14 +5,12 @@ plugins { } android { - compileSdk = 31 - buildToolsVersion = "30.0.3" - defaultConfig { applicationId = "com.vanpra.composematerialdialogs" minSdk = 23 - targetSdk = 30 + targetSdk = 33 + compileSdk = 33 versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -38,7 +36,7 @@ android { } composeOptions { - kotlinCompilerExtensionVersion = Dependencies.AndroidX.Compose.version + kotlinCompilerExtensionVersion = Dependencies.AndroidX.Compose.compilerVersion } } diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 711ccac3..969ba126 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,8 +1,8 @@ object Dependencies { - const val desugar = "com.android.tools:desugar_jdk_libs:1.1.5" + const val desugar = "com.android.tools:desugar_jdk_libs:1.2.0" object ComposeMaterialDialogs { - const val version = "0.6.3" + const val version = "0.7.0" const val core = "io.github.vanpra.compose-material-dialogs:core:$version" const val datetime = "io.github.vanpra.compose-material-dialogs:datetime:$version" @@ -14,12 +14,12 @@ object Dependencies { } object Accompanist { - private const val version = "0.24.9-beta" + private const val version = "0.24.13-rc" const val pager = "com.google.accompanist:accompanist-pager:$version" } object Kotlin { - private const val version = "1.6.21" + private const val version = "1.7.0" const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version" } @@ -30,11 +30,11 @@ object Dependencies { } object Google { - const val material = "com.google.android.material:material:1.6.0" + const val material = "com.google.android.material:material:1.6.1" } object AndroidX { - const val coreKtx = "androidx.core:core-ktx:1.7.0" + const val coreKtx = "androidx.core:core-ktx:1.8.0" object Testing { const val version = "1.4.0" @@ -44,7 +44,8 @@ object Dependencies { } object Compose { - const val version = "1.2.0-beta02" + const val version = "1.2.0-rc03" + const val compilerVersion = "1.2.0" const val ui = "androidx.compose.ui:ui:$version" const val material = "androidx.compose.material:material:$version" @@ -55,7 +56,7 @@ object Dependencies { const val testing = "androidx.compose.ui:ui-test-junit4:$version" const val activity = "androidx.activity:activity-compose:1.4.0" - const val navigation = "androidx.navigation:navigation-compose:2.4.2" + const val navigation = "androidx.navigation:navigation-compose:2.5.0" } } } \ No newline at end of file diff --git a/color/build.gradle.kts b/color/build.gradle.kts index 62e356dd..4e02e924 100644 --- a/color/build.gradle.kts +++ b/color/build.gradle.kts @@ -5,8 +5,8 @@ plugins { android { defaultConfig { minSdk = 21 - compileSdk = 31 - targetSdk = 31 + compileSdk = 33 + targetSdk = 33 testInstrumentationRunner = "com.karumi.shot.ShotTestRunner" testApplicationId = "com.vanpra.composematerialdialogs.color.test" @@ -42,7 +42,7 @@ android { } composeOptions { - kotlinCompilerExtensionVersion = Dependencies.AndroidX.Compose.version + kotlinCompilerExtensionVersion = Dependencies.AndroidX.Compose.compilerVersion } } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 58adf680..bb730d00 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -5,8 +5,8 @@ plugins { android { defaultConfig { minSdk = 21 - compileSdk = 31 - targetSdk = 31 + compileSdk = 33 + targetSdk = 33 testInstrumentationRunner = "com.karumi.shot.ShotTestRunner" testApplicationId = "com.vanpra.composematerialdialogs.test" @@ -45,7 +45,7 @@ android { } composeOptions { - kotlinCompilerExtensionVersion = Dependencies.AndroidX.Compose.version + kotlinCompilerExtensionVersion = Dependencies.AndroidX.Compose.compilerVersion } } diff --git a/datetime/build.gradle.kts b/datetime/build.gradle.kts index 1f78fe91..b35baf23 100644 --- a/datetime/build.gradle.kts +++ b/datetime/build.gradle.kts @@ -8,8 +8,8 @@ android { } defaultConfig { minSdk = 21 - compileSdk = 31 - targetSdk = 31 + compileSdk = 33 + targetSdk = 33 testInstrumentationRunner = "com.karumi.shot.ShotTestRunner" testApplicationId = "com.vanpra.composematerialdialogs.test" @@ -45,7 +45,7 @@ android { } composeOptions { - kotlinCompilerExtensionVersion = Dependencies.AndroidX.Compose.version + kotlinCompilerExtensionVersion = Dependencies.AndroidX.Compose.compilerVersion } kotlinOptions { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c4eec5a6..58458096 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri Feb 05 10:11:42 GMT 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-rc-4-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index 851aa5ac..1c954203 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -6,8 +6,8 @@ plugins { android { defaultConfig { minSdk = 21 - compileSdk = 31 - targetSdk = 30 + compileSdk = 33 + targetSdk = 33 testInstrumentationRunner = "com.karumi.shot.ShotTestRunner" testApplicationId = "com.vanpra.composematerialdialogs.test" @@ -44,7 +44,7 @@ android { } composeOptions { - kotlinCompilerExtensionVersion = Dependencies.AndroidX.Compose.version + kotlinCompilerExtensionVersion = Dependencies.AndroidX.Compose.compilerVersion } } From ba895533e82cdfdba0db6347878fcfde1d50301a Mon Sep 17 00:00:00 2001 From: Pranav Maganti Date: Sun, 10 Jul 2022 14:07:29 +0100 Subject: [PATCH 2/4] Remove material extended icon dependency --- build.gradle.kts | 4 +- .../src/main/kotlin/CommonModulePlugin.kt | 3 +- .../datetime/date/DatePicker.kt | 49 ++++++++----------- .../drawable/baseline_arrow_drop_down_24.xml | 5 ++ .../drawable/baseline_arrow_drop_up_24.xml | 5 ++ 5 files changed, 34 insertions(+), 32 deletions(-) create mode 100644 datetime/src/main/res/drawable/baseline_arrow_drop_down_24.xml create mode 100644 datetime/src/main/res/drawable/baseline_arrow_drop_up_24.xml diff --git a/build.gradle.kts b/build.gradle.kts index bdc1d230..442bacaa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,9 +14,9 @@ buildscript { dependencies { classpath(Dependencies.Kotlin.gradlePlugin) - classpath("com.android.tools.build:gradle:7.4.0-alpha02") + classpath("com.android.tools.build:gradle:7.3.0-beta05") classpath("com.vanniktech:gradle-maven-publish-plugin:0.19.0") - classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.6.21") + classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.7.0") classpath(Dependencies.Shot.core) } } diff --git a/buildSrc/src/main/kotlin/CommonModulePlugin.kt b/buildSrc/src/main/kotlin/CommonModulePlugin.kt index 3691fe2b..d2ad7a9b 100644 --- a/buildSrc/src/main/kotlin/CommonModulePlugin.kt +++ b/buildSrc/src/main/kotlin/CommonModulePlugin.kt @@ -26,9 +26,8 @@ class CommonModulePlugin: Plugin { 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.animation) androidTestImplementation(Dependencies.AndroidX.Compose.activity) androidTestImplementation(Dependencies.AndroidX.Compose.testing) diff --git a/datetime/src/main/java/com/vanpra/composematerialdialogs/datetime/date/DatePicker.kt b/datetime/src/main/java/com/vanpra/composematerialdialogs/datetime/date/DatePicker.kt index 2f845545..f77b5cb7 100644 --- a/datetime/src/main/java/com/vanpra/composematerialdialogs/datetime/date/DatePicker.kt +++ b/datetime/src/main/java/com/vanpra/composematerialdialogs/datetime/date/DatePicker.kt @@ -31,8 +31,6 @@ import androidx.compose.material.ContentAlpha import androidx.compose.material.Icon import androidx.compose.material.Text import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowDropDown -import androidx.compose.material.icons.filled.ArrowDropUp import androidx.compose.material.icons.filled.KeyboardArrowLeft import androidx.compose.material.icons.filled.KeyboardArrowRight import androidx.compose.runtime.Composable @@ -45,6 +43,7 @@ import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clipToBounds import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight.Companion.W400 import androidx.compose.ui.text.font.FontWeight.Companion.W600 @@ -56,6 +55,7 @@ import com.google.accompanist.pager.HorizontalPager import com.google.accompanist.pager.PagerState import com.google.accompanist.pager.rememberPagerState import com.vanpra.composematerialdialogs.MaterialDialogScope +import com.vanpra.composematerialdialogs.datetime.R import com.vanpra.composematerialdialogs.datetime.util.getFullLocalName import com.vanpra.composematerialdialogs.datetime.util.getShortLocalName import com.vanpra.composematerialdialogs.datetime.util.isSmallDevice @@ -124,9 +124,7 @@ internal fun DatePickerImpl( ) { page -> val viewDate = remember { LocalDate.of( - state.yearRange.first + page / 12, - page % 12 + 1, - 1 + state.yearRange.first + page / 12, page % 12 + 1, 1 ) } @@ -158,7 +156,7 @@ private fun YearPicker( state: DatePickerState, pagerState: PagerState, ) { - val gridState = rememberLazyGridState((viewDate.year - state.yearRange.first) / 3) + val gridState = rememberLazyGridState(viewDate.year - state.yearRange.first) val coroutineScope = rememberCoroutineScope() LazyVerticalGrid( @@ -205,8 +203,7 @@ private fun YearPickerItem( Text( year.toString(), style = TextStyle( - color = colors.dateTextColor(selected).value, - fontSize = 18.sp + color = colors.dateTextColor(selected).value, fontSize = 18.sp ) ) } @@ -223,9 +220,8 @@ private fun CalendarViewHeader( ) { val coroutineScope = rememberCoroutineScope() val month = remember { viewDate.month.getFullLocalName(locale) } - val yearDropdownIcon = remember(state.yearPickerShowing) { - if (state.yearPickerShowing) Icons.Default.ArrowDropUp else Icons.Default.ArrowDropDown - } + val arrowDropUp = painterResource(id = R.drawable.baseline_arrow_drop_up_24) + val arrowDropDown = painterResource(id = R.drawable.baseline_arrow_drop_down_24) Box( Modifier @@ -251,7 +247,7 @@ private fun CalendarViewHeader( Spacer(Modifier.width(4.dp)) Box(Modifier.size(24.dp), contentAlignment = Alignment.Center) { Icon( - yearDropdownIcon, + if (state.yearPickerShowing) arrowDropUp else arrowDropDown, contentDescription = "Year Selector", tint = state.colors.calendarHeaderTextColor ) @@ -269,14 +265,13 @@ private fun CalendarViewHeader( modifier = Modifier .testTag("dialog_date_prev_month") .size(24.dp) - .clickable( - onClick = { - coroutineScope.launch { - if (pagerState.currentPage - 1 >= 0) - pagerState.animateScrollToPage(pagerState.currentPage - 1) - } + .clickable(onClick = { + coroutineScope.launch { + if (pagerState.currentPage - 1 >= 0) pagerState.animateScrollToPage( + pagerState.currentPage - 1 + ) } - ), + }), tint = state.colors.calendarHeaderTextColor ) @@ -288,14 +283,13 @@ private fun CalendarViewHeader( modifier = Modifier .testTag("dialog_date_next_month") .size(24.dp) - .clickable( - onClick = { - coroutineScope.launch { - if (pagerState.currentPage + 1 < pagerState.pageCount) - pagerState.animateScrollToPage(pagerState.currentPage + 1) - } + .clickable(onClick = { + coroutineScope.launch { + if (pagerState.currentPage + 1 < pagerState.pageCount) pagerState.animateScrollToPage( + pagerState.currentPage + 1 + ) } - ), + }), tint = state.colors.calendarHeaderTextColor ) } @@ -369,8 +363,7 @@ private fun DateSelectionBox( .wrapContentSize(Alignment.Center) .alpha(if (enabled) ContentAlpha.high else ContentAlpha.disabled), style = TextStyle( - color = colors.dateTextColor(selected).value, - fontSize = 12.sp + color = colors.dateTextColor(selected).value, fontSize = 12.sp ) ) } diff --git a/datetime/src/main/res/drawable/baseline_arrow_drop_down_24.xml b/datetime/src/main/res/drawable/baseline_arrow_drop_down_24.xml new file mode 100644 index 00000000..c1c897af --- /dev/null +++ b/datetime/src/main/res/drawable/baseline_arrow_drop_down_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/datetime/src/main/res/drawable/baseline_arrow_drop_up_24.xml b/datetime/src/main/res/drawable/baseline_arrow_drop_up_24.xml new file mode 100644 index 00000000..10c5932c --- /dev/null +++ b/datetime/src/main/res/drawable/baseline_arrow_drop_up_24.xml @@ -0,0 +1,5 @@ + + + From 7aaa76ea814f9f0ca003a423db1d8a567bee4f68 Mon Sep 17 00:00:00 2001 From: Pranav Maganti Date: Sun, 10 Jul 2022 14:08:22 +0100 Subject: [PATCH 3/4] Add color and style parameters to title and message --- .../MaterialDialogCore.kt | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/vanpra/composematerialdialogs/MaterialDialogCore.kt b/core/src/main/java/com/vanpra/composematerialdialogs/MaterialDialogCore.kt index bc5cce87..fa259319 100644 --- a/core/src/main/java/com/vanpra/composematerialdialogs/MaterialDialogCore.kt +++ b/core/src/main/java/com/vanpra/composematerialdialogs/MaterialDialogCore.kt @@ -17,6 +17,8 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.TextStyle import androidx.compose.ui.unit.dp /** @@ -29,6 +31,8 @@ import androidx.compose.ui.unit.dp fun MaterialDialogScope.title( text: String? = null, @StringRes res: Int? = null, + color: Color = MaterialTheme.colors.onSurface, + style: TextStyle = MaterialTheme.typography.h6, center: Boolean = false ) { val titleText = getString(res, text) @@ -50,8 +54,8 @@ fun MaterialDialogScope.title( Text( text = titleText, - color = MaterialTheme.colors.onSurface, - style = MaterialTheme.typography.h6, + color = color, + style = style, modifier = modifier ) } @@ -66,6 +70,8 @@ fun MaterialDialogScope.title( fun MaterialDialogScope.iconTitle( text: String? = null, @StringRes textRes: Int? = null, + color: Color = MaterialTheme.colors.onSurface, + style: TextStyle = MaterialTheme.typography.h6, icon: @Composable () -> Unit = {}, ) { val titleText = getString(textRes, text) @@ -79,8 +85,8 @@ fun MaterialDialogScope.iconTitle( Spacer(Modifier.width(14.dp)) Text( text = titleText, - color = MaterialTheme.colors.onBackground, - style = MaterialTheme.typography.h6 + color = color, + style = style ) } } @@ -91,13 +97,18 @@ fun MaterialDialogScope.iconTitle( * @param res message text from a string resource */ @Composable -fun MaterialDialogScope.message(text: String? = null, @StringRes res: Int? = null) { +fun MaterialDialogScope.message( + text: String? = null, + color: Color = MaterialTheme.colors.onSurface, + style: TextStyle = MaterialTheme.typography.body1, + @StringRes res: Int? = null +) { val messageText = getString(res, text) Text( text = messageText, - color = MaterialTheme.colors.onSurface, - style = MaterialTheme.typography.body1, + color = color, + style = style, modifier = Modifier .padding(bottom = 28.dp, start = 24.dp, end = 24.dp) ) From bd82c9815e4a04a0dc0984d39eadb256902d1664 Mon Sep 17 00:00:00 2001 From: Pranav Maganti Date: Sun, 10 Jul 2022 14:14:23 +0100 Subject: [PATCH 4/4] Update documentation for 0.8.1-rc --- CHANGELOG.md | 7 +++++++ README.md | 2 +- gradle.properties | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5da6a7a7..ddac1d17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### 0.8.1-rc - 2022-05-25 + +- Update compose to 1.2.0-rc03 ([#156](https://github.com/vanpra/compose-material-dialogs/issues/156)) +- Update kotlin to 1.7.0 +- Remove `material-icons-extended` dependency ([#153](https://github.com/vanpra/compose-material-dialogs/issues/153)) +- Add parameter for changing title and message style and color ([#150](https://github.com/vanpra/compose-material-dialogs/issues/150)) + ### 0.8.0-beta - 2022-05-25 - Update compose to 1.2.0-beta02 ([#149](https://github.com/vanpra/compose-material-dialogs/pull/149)) diff --git a/README.md b/README.md index 5b0521a6..53039e97 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ **Latest Stable Library Version: 0.7.2 (Supports Compose 1.1.1)** -**Latest Beta Library Version: 0.8.0-beta (Supports Compose 1.2.0-beta02)** +**Latest Beta Library Version: 0.8.1-rc (Supports Compose 1.2.0-rc03)** ### [See Releases and Changelog](https://github.com/vanpra/compose-material-dialogs/blob/main/CHANGELOG.md) diff --git a/gradle.properties b/gradle.properties index 0a154077..0a9b1e83 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ android.enableJetifier=false kotlin.code.style=official GROUP=io.github.vanpra.compose-material-dialogs -VERSION_NAME=0.8.0-beta +VERSION_NAME=0.8.1-rc POM_DESCRIPTION=A Material Dialog Builder for Jetpack Compose POM_INCEPTION_YEAR=2020