Skip to content

Commit

Permalink
Merge pull request #108 from vanpra/0.6.0
Browse files Browse the repository at this point in the history
Library version 0.6.0
  • Loading branch information
PranavMaganti authored Sep 10, 2021
2 parents e2fdbb0 + b0b866d commit 76f42e1
Show file tree
Hide file tree
Showing 45 changed files with 468 additions and 372 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

### 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
- Update compose to 1.1.0-alpha03
- Update kotlin to 1.5.30
- Fix bug which caused the year picker to fill the whole dialog

### 0.5.1 - 2021-07-29

- Update compose to 1.0.0
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
```gradle
dependencies {
...
implementation "io.github.vanpra.compose-material-dialogs:core:0.5.1"
implementation "io.github.vanpra.compose-material-dialogs:core:0.6.0"
...
}
```
Expand All @@ -35,7 +35,7 @@ dependencies {
```gradle
dependencies {
...
implementation "io.github.vanpra.compose-material-dialogs:datetime:0.5.1"
implementation "io.github.vanpra.compose-material-dialogs:datetime:0.6.0"
...
}
```
Expand All @@ -51,7 +51,7 @@ dependencies {
```gradle
dependencies {
...
implementation "io.github.vanpra.compose-material-dialogs:color:0.5.1"
implementation "io.github.vanpra.compose-material-dialogs:color:0.6.0"
...
}
```
Expand Down
10 changes: 2 additions & 8 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

android {
compileSdk = 30
compileSdk = 31
buildToolsVersion = "30.0.3"

defaultConfig {
Expand Down Expand Up @@ -52,20 +52,14 @@ dependencies {
// implementation(Dependencies.ComposeMaterialDialogs.color)

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

implementation(Dependencies.AndroidX.Compose.ui)
implementation(Dependencies.AndroidX.Compose.material)
implementation(Dependencies.AndroidX.Compose.materialIconsExtended)
implementation(Dependencies.AndroidX.Compose.activity)
implementation(Dependencies.AndroidX.Compose.navigation)

implementation(Dependencies.AndroidX.coreKtx)
implementation(Dependencies.AndroidX.appcompat)

implementation(Dependencies.material)

implementation(kotlin("stdlib-jdk8"))

androidTestImplementation(Dependencies.AndroidX.Compose.testing)
coreLibraryDesugaring(Dependencies.desugar)
}
Empty file removed app/mirakle_build_file_stub
Empty file.
8 changes: 2 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.vanpra.composematerialdialogdemos"
android:sharedUserId="com.vanpra.composematerialdialogs.uid">

Expand All @@ -10,15 +9,12 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Composematerialdialogs"
tools:replace="android:theme">
android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.Composematerialdialogs.NoActionBar">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.vanpra.composematerialdialogdemos

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -31,7 +31,7 @@ import com.vanpra.composematerialdialogdemos.ui.ComposeMaterialDialogsTheme
/**
* @brief MainActivity with material dialog samples
*/
class MainActivity : AppCompatActivity() {
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Expand Down
13 changes: 8 additions & 5 deletions app/src/main/java/com/vanpra/composematerialdialogdemos/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.vanpra.composematerialdialogs.MaterialDialog
import com.vanpra.composematerialdialogs.MaterialDialogButtons
import com.vanpra.composematerialdialogs.MaterialDialogScope
import com.vanpra.composematerialdialogs.rememberMaterialDialogState

/**
* @brief Builds a dialog and adds button to the layout which shows the dialog on click
Expand All @@ -22,14 +23,16 @@ import com.vanpra.composematerialdialogs.MaterialDialogButtons
fun DialogAndShowButton(
buttonText: String,
buttons: @Composable MaterialDialogButtons.() -> Unit = {},
content: @Composable MaterialDialog.() -> Unit
content: @Composable MaterialDialogScope.() -> Unit
) {
val dialog = remember { MaterialDialog() }
val dialogState = rememberMaterialDialogState()

dialog.build(content = content, buttons = buttons)
MaterialDialog(dialogState = dialogState, buttons = buttons) {
content()
}

TextButton(
onClick = { dialog.show() },
onClick = { dialogState.show() },
modifier = Modifier
.fillMaxWidth()
.padding(8.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fun BasicDialogDemo() {
input(
label = "Name", hint = "Jon Smith",
keyboardActions = KeyboardActions(
onDone = { this@DialogAndShowButton.submit() }
onDone = { submit() }
),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,15 @@ fun BasicListDialogDemo() {
fun MultiSelectionDemo() {
var initialSelection by remember { mutableStateOf(setOf(3, 5)) }

DialogAndShowButton(buttonText = "Multi-Selection Dialog", buttons = { defaultListDialogButtons() }) {
title(res = R.string.labels_dialog_title)
listItemsMultiChoice(labels) {
println(it)
DialogAndShowButton(
buttonText = "Multi-Selection Dialog",
buttons = { defaultListDialogButtons() }
) {
title(res = R.string.labels_dialog_title)
listItemsMultiChoice(labels) {
println(it)
}
}
}

DialogAndShowButton(
buttonText = "Multi-Selection Dialog with disabled items",
Expand Down
23 changes: 0 additions & 23 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,2 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Composematerialdialogs" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>

<style name="Theme.Composematerialdialogs.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="Theme.Composematerialdialogs.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="Theme.Composematerialdialogs.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("com.diffplug.spotless") version "5.14.1"
id("com.diffplug.spotless") version "5.14.3"
id("org.jetbrains.dokka") version "1.5.0"
}

Expand All @@ -15,10 +15,10 @@ buildscript {

dependencies {
classpath(Dependencies.Kotlin.gradlePlugin)
classpath("com.android.tools.build:gradle:7.1.0-alpha05")
classpath("com.android.tools.build:gradle:7.1.0-alpha11")
classpath("com.vanniktech:gradle-maven-publish-plugin:0.17.0")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.5.0")
classpath("com.karumi:shot:5.10.6")
classpath(Dependencies.Shot.core)
}
}

Expand Down
2 changes: 0 additions & 2 deletions buildSrc/src/main/kotlin/CommonModulePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class CommonModulePlugin: Plugin<Project> {
dependencies.apply {
implementation(Dependencies.Kotlin.stdlib)
implementation(Dependencies.AndroidX.coreKtx)
implementation(Dependencies.AndroidX.appcompat)
implementation(Dependencies.material)

implementation(Dependencies.AndroidX.Compose.ui)
implementation(Dependencies.AndroidX.Compose.material)
Expand Down
31 changes: 17 additions & 14 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
object Dependencies {
const val material = "com.google.android.material:material:1.5.0-alpha01"
const val desugar = "com.android.tools:desugar_jdk_libs:1.1.5"

object ComposeMaterialDialogs {
Expand All @@ -11,47 +10,51 @@ object Dependencies {
}

object Ktlint {
const val version = "0.42.0"
const val version = "0.42.1"
}

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

object Kotlin {
private const val version = "1.5.10"
private const val version = "1.5.30"
const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version"
const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version"
}

object Shot {
private const val version = "5.10.6"
const val shot = "com.karumi:shot-android:$version"
private const val version = "5.11.2"
const val core = "com.karumi:shot:$version"
const val android = "com.karumi:shot-android:$version"
}

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

object AndroidX {
const val appcompat = "androidx.appcompat:appcompat:1.4.0-alpha03"
const val coreKtx = "androidx.core:core-ktx:1.7.0-alpha01"
const val coreKtx = "androidx.core:core-ktx:1.7.0-alpha02"

object Testing {
const val version = "1.4.0"
const val version = "1.4.1-alpha01"
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.0.0"
const val version = "1.1.0-alpha03"

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 testing = "androidx.compose.ui:ui-test-junit4:1.0.0-rc02"
const val activity = "androidx.activity:activity-compose:1.3.0-rc02"
const val navigation = "androidx.navigation:navigation-compose:2.4.0-alpha05"
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"
}
}
}
}
80 changes: 80 additions & 0 deletions buildSrc/src/main/kotlin/update_deps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import re
from typing import List
import bs4 as beautifulsoup
import requests
from tqdm import tqdm

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec

main_search_url = 'https://search.maven.org/solrsearch/select?q=g:"{}"+AND+a:"{}"&core=gav&rows=1&wt=json'
google_search_url = "https://maven.google.com/web/index.html"


chrome_options = Options()
# chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=1920x1080")
driver = webdriver.Chrome(options=chrome_options)

dep_file = "Dependencies.kt"

with open(dep_file, "r") as readfile:
current_deps = readfile.read().splitlines()

version_patten = re.compile(r"version = \"(.*)\"")
dep_pattern = re.compile(r"const val ([^=]*) = \"(.*)\"")
current_version = ("", -1, "")

updated_deps: List[str] = []

for index, item in enumerate(tqdm(current_deps)):
version_match = version_patten.search(item)
dep_match = dep_pattern.search(item)

if version_match:
if current_version[1] != -1:
updated_deps[current_version[1]] = re.sub(version_patten, f'version = "{current_version[0]}"', current_version[2])
current_version = (version_match.group(1), index, item)
updated_deps.append(item)
elif dep_match:
(dep, version) = dep_match.group(2).rsplit(":", 1)
(group, artifact) = dep.split(":")
main_dep_url = main_search_url.format(group, artifact)
google_dep_url = f"{google_search_url}#{group}:{artifact}"

res = requests.get(main_dep_url).json()
latest_version = version

if res["response"]["docs"]:
latest_version = res["response"]["docs"][0]["v"]
else:
print(google_dep_url)
driver.get(google_dep_url)
elems = WebDriverWait(driver, 10).until(
ec.visibility_of_element_located(
(By.XPATH, "//div[@class='content-header ng-binding ng-scope']")
)
)

soup = beautifulsoup.BeautifulSoup(driver.page_source, "html.parser")
latest_version = soup.find("span", {"class": "ng-binding"}).text

if version == "$version":
current_version = (latest_version, current_version[1], current_version[2])
updated_deps.append(item)
else:
updated_deps.append(
f"const val {dep_match.group(1)} = \"{group}:{artifact}:{latest_version}\""
)
else:
updated_deps.append(item)


if current_version[1] != -1:
updated_deps[current_version[1]] = re.sub(version_patten, f'version = "{current_version[0]}"', current_version[2])

with open(dep_file, "w") as outfile:
outfile.write("\n".join(updated_deps))
Loading

0 comments on commit 76f42e1

Please sign in to comment.