-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from vanpra/0.7.0
Library release 0.7.0
- Loading branch information
Showing
25 changed files
with
413 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,9 @@ import androidx.compose.ui.text.input.ImeAction | |
import com.vanpra.composematerialdialogdemos.DialogAndShowButton | ||
import com.vanpra.composematerialdialogdemos.R | ||
import com.vanpra.composematerialdialogs.iconTitle | ||
import com.vanpra.composematerialdialogs.input | ||
import com.vanpra.composematerialdialogs.message | ||
import com.vanpra.composematerialdialogs.title | ||
import input | ||
|
||
/** | ||
* @brief Basic Dialog Demos | ||
|
@@ -80,7 +80,20 @@ fun BasicDialogDemo() { | |
} | ||
) { | ||
title(res = R.string.input_dialog_title) | ||
input(label = "Name", hint = "Jon Smith") { | ||
input(label = "Name", placeholder = "Jon Smith") { | ||
Log.d("SELECTION:", it) | ||
} | ||
} | ||
|
||
DialogAndShowButton( | ||
buttonText = "Outlined Input Dialog", | ||
buttons = { | ||
negativeButton("Cancel") | ||
positiveButton("Ok") | ||
} | ||
) { | ||
title(res = R.string.input_dialog_title) | ||
input(label = "Name", placeholder = "Jon Smith", textFieldStyle = TextFieldStyle.Outlined) { | ||
Log.d("SELECTION:", it) | ||
} | ||
} | ||
|
@@ -96,7 +109,7 @@ fun BasicDialogDemo() { | |
title(res = R.string.input_dialog_title) | ||
input( | ||
label = "Name", | ||
hint = "Jon Smith", | ||
placeholder = "Jon Smith", | ||
focusRequester = focusRequester, | ||
focusOnShow = true | ||
) { | ||
|
@@ -113,7 +126,7 @@ fun BasicDialogDemo() { | |
) { | ||
title(res = R.string.input_dialog_title) | ||
input( | ||
label = "Name", hint = "Jon Smith", | ||
label = "Name", placeholder = "Jon Smith", | ||
keyboardActions = KeyboardActions( | ||
onDone = { submit() } | ||
), | ||
|
@@ -133,7 +146,7 @@ fun BasicDialogDemo() { | |
title("Please enter your email") | ||
input( | ||
label = "Email", | ||
hint = "[email protected]", | ||
placeholder = "[email protected]", | ||
errorMessage = "Invalid email", | ||
isTextValid = { | ||
Patterns.EMAIL_ADDRESS.matcher(it).matches() && it.isNotEmpty() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,14 @@ import androidx.compose.foundation.layout.Row | |
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.AccountCircle | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateListOf | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
|
@@ -47,7 +49,7 @@ private val ringtones = | |
"Zen Too" | ||
) | ||
private val labels = listOf("None", "Forums", "Social", "Updates", "Promotions", "Spam", "Bin") | ||
private val emails = listOf( | ||
private val emails = mutableStateListOf( | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
|
@@ -68,12 +70,17 @@ fun BasicListDialogDemo() { | |
DialogAndShowButton(buttonText = "Simple List Dialog") { | ||
title(res = R.string.backup_dialog_title) | ||
listItems(emails) | ||
Button(onClick = { emails.add("[email protected]") }) { | ||
Text("Add") | ||
} | ||
} | ||
|
||
DialogAndShowButton(buttonText = "Custom List Dialog") { | ||
title(res = R.string.backup_dialog_title) | ||
listItems( | ||
modifier = Modifier.padding(bottom = 8.dp).padding(horizontal = 24.dp), | ||
modifier = Modifier | ||
.padding(bottom = 8.dp) | ||
.padding(horizontal = 24.dp), | ||
list = emails, | ||
item = { _, email -> | ||
Row(Modifier.fillMaxWidth()) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+21 KB
...omposematerialdialogs.test.screenshot.InputDialogTest_dialogWithFilledInput.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.8 KB
...posematerialdialogs.test.screenshot.InputDialogTest_dialogWithOutlinedInput.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.34 KB
(97%)
...npra.composematerialdialogs.test.screenshot.ListDialog_multiSelectionDialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...src/androidTest/java/com/vanpra/composematerialdialogs/test/screenshot/InputDialogTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.vanpra.composematerialdialogs.test.screenshot | ||
|
||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.karumi.shot.ScreenshotTest | ||
import com.vanpra.composematerialdialogs.test.R | ||
import com.vanpra.composematerialdialogs.test.utils.DialogWithContent | ||
import com.vanpra.composematerialdialogs.test.utils.extensions.onDialog | ||
import com.vanpra.composematerialdialogs.test.utils.extensions.setContentAndWaitForIdle | ||
import com.vanpra.composematerialdialogs.title | ||
import input | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class InputDialogTest : ScreenshotTest { | ||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun dialogWithFilledInput() { | ||
composeTestRule.setContentAndWaitForIdle { | ||
DialogWithContent( | ||
buttons = { | ||
negativeButton("Cancel") | ||
positiveButton("Ok") | ||
} | ||
) { | ||
title(res = R.string.input_dialog_title) | ||
input(label = "Name", placeholder = "Jon Smith") | ||
} | ||
} | ||
compareScreenshot(composeTestRule.onDialog()) | ||
} | ||
|
||
@Test | ||
fun dialogWithOutlinedInput() { | ||
composeTestRule.setContentAndWaitForIdle { | ||
DialogWithContent( | ||
buttons = { | ||
negativeButton("Cancel") | ||
positiveButton("Ok") | ||
} | ||
) { | ||
title(res = R.string.input_dialog_title) | ||
input( | ||
label = "Name", | ||
placeholder = "Jon Smith", | ||
textFieldStyle = TextFieldStyle.Outlined | ||
) | ||
} | ||
} | ||
compareScreenshot(composeTestRule.onDialog()) | ||
} | ||
} |
Oops, something went wrong.