Skip to content

Commit 4e61dad

Browse files
authored
Merge pull request #117 from SpineEventEngine/cut-dialog-height-with-empty-description
Decrease the dialog's height if the description field is empty.
2 parents 96f4ddc + ebe1936 commit 4e61dad

5 files changed

Lines changed: 90 additions & 38 deletions

File tree

core/src/main/kotlin/io/spine/chords/core/layout/ConfirmationDialog.kt

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ import io.spine.chords.core.AbstractComponentSetup
3838
import io.spine.chords.core.appshell.Props
3939
import kotlinx.coroutines.CompletableDeferred
4040

41+
/**
42+
* Default width of the [ConfirmationDialog].
43+
*/
44+
private val DefaultDialogWidth = 450.dp
45+
46+
/**
47+
* Default height of the [ConfirmationDialog].
48+
*/
49+
private val DefaultDialogHeight = 220.dp
50+
51+
/**
52+
* The value used to reduce the dialog's height
53+
* when the description field is empty.
54+
*/
55+
private val ReservedDescriptionHeight = 32.dp
56+
4157
/**
4258
* A dialog that prompts the user either to make a boolean decision
4359
* (e.g. approve or deny some action).
@@ -123,7 +139,9 @@ public class ConfirmationDialog : Dialog() {
123139
*/
124140
public var yesButtonText: String
125141
get() = submitButtonText
126-
set(value) { submitButtonText = value }
142+
set(value) {
143+
submitButtonText = value
144+
}
127145

128146
/**
129147
* The label for the dialog's No button.
@@ -132,16 +150,18 @@ public class ConfirmationDialog : Dialog() {
132150
*/
133151
public var noButtonText: String
134152
get() = cancelButtonText
135-
set(value) { cancelButtonText = value }
153+
set(value) {
154+
cancelButtonText = value
155+
}
136156

137157
init {
138158
submitAvailable = true
139159
cancelAvailable = true
140160

141161
yesButtonText = "Yes"
142162
noButtonText = "No"
143-
width = 430.dp
144-
height = 210.dp
163+
width = DefaultDialogWidth
164+
height = DefaultDialogHeight
145165
}
146166

147167
/**
@@ -152,19 +172,21 @@ public class ConfirmationDialog : Dialog() {
152172
val textStyle = typography.bodyLarge
153173

154174
Column {
155-
Row(
156-
modifier = Modifier.padding(bottom = 6.dp)
157-
) {
175+
Row {
158176
Text(
159177
text = message,
160178
style = textStyle
161179
)
162180
}
163-
Row {
164-
Text(
165-
text = description,
166-
style = textStyle
167-
)
181+
if (description.isNotBlank()) {
182+
Row(
183+
modifier = Modifier.padding(top = 8.dp)
184+
) {
185+
Text(
186+
text = description,
187+
style = textStyle
188+
)
189+
}
168190
}
169191
}
170192
}
@@ -181,6 +203,12 @@ public class ConfirmationDialog : Dialog() {
181203
* makes a decision.
182204
*/
183205
public suspend fun showConfirmation(): Boolean {
206+
// TODO:2025-04-18:oleg.melnik: Remove the code below after automatic
207+
// size detection is implemented for dialogs.
208+
// https://github.com/SpineEventEngine/Chords/issues/118
209+
if (description.isBlank() && height == DefaultDialogHeight) {
210+
height -= ReservedDescriptionHeight
211+
}
184212
var confirmed = false
185213
val dialogClosure = CompletableDeferred<Unit>()
186214
onBeforeSubmit = {

core/src/main/kotlin/io/spine/chords/core/layout/InputTextDialog.kt

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ import kotlinx.coroutines.CompletableDeferred
4747
*/
4848
private const val InputComponentNoOfLines = 3
4949

50+
/**
51+
* Default width of the [InputTextDialog].
52+
*/
53+
private val DefaultDialogWidth = 450.dp
54+
55+
/**
56+
* Default height of the [InputTextDialog].
57+
*/
58+
private val DefaultDialogHeight = 300.dp
59+
60+
/**
61+
* The value used to reduce the dialog's height
62+
* when the description field is empty.
63+
*/
64+
private val ReservedDescriptionHeight = 24.dp
65+
5066
/**
5167
* A dialog that allows input of a text value.
5268
*
@@ -182,8 +198,8 @@ public class InputTextDialog : Dialog() {
182198
init {
183199
submitAvailable = true
184200
cancelAvailable = true
185-
width = 430.dp
186-
height = 300.dp
201+
width = DefaultDialogWidth
202+
height = DefaultDialogHeight
187203
}
188204

189205
/**
@@ -193,23 +209,25 @@ public class InputTextDialog : Dialog() {
193209
protected override fun contentSection() {
194210
val textStyle = typography.bodyLarge
195211
Column {
196-
Row(
197-
modifier = Modifier.padding(bottom = 8.dp)
198-
) {
212+
Row {
199213
Text(
200214
text = message,
201215
style = textStyle
202216
)
203217
}
218+
if (description.isNotBlank()) {
219+
Row(
220+
modifier = Modifier.padding(top = 8.dp)
221+
) {
222+
Text(
223+
text = description,
224+
style = textStyle
225+
)
226+
}
227+
}
204228
Row(
205-
modifier = Modifier.padding(bottom = 16.dp)
229+
modifier = Modifier.padding(top = 16.dp)
206230
) {
207-
Text(
208-
text = description,
209-
style = textStyle
210-
)
211-
}
212-
Row {
213231
text.value = defaultText
214232
StringField {
215233
label = textFieldLabel
@@ -238,6 +256,12 @@ public class InputTextDialog : Dialog() {
238256
* pressing the submit button, or `null`, if the user cancels the input.
239257
*/
240258
private suspend fun show(): String? {
259+
// TODO:2025-04-18:oleg.melnik: Remove the code below after automatic
260+
// size detection is implemented for dialogs.
261+
// https://github.com/SpineEventEngine/Chords/issues/118
262+
if (description.isBlank() && height == DefaultDialogHeight) {
263+
height -= ReservedDescriptionHeight
264+
}
241265
var dialogCancelled = false
242266
val dialogClosure = CompletableDeferred<Unit>()
243267
onBeforeSubmit = {

dependencies.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
# Dependencies of `io.spine.chords:spine-chords-client:2.0.0-SNAPSHOT.79`
3+
# Dependencies of `io.spine.chords:spine-chords-client:2.0.0-SNAPSHOT.80`
44

55
## Runtime
66
1. **Group** : cafe.adriel.voyager. **Name** : voyager-core. **Version** : 1.0.1.**No license information found**
@@ -1094,12 +1094,12 @@
10941094

10951095
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
10961096

1097-
This report was generated on **Tue Apr 08 11:56:54 EEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
1097+
This report was generated on **Fri Apr 18 13:36:25 EEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
10981098

10991099

11001100

11011101

1102-
# Dependencies of `io.spine.chords:spine-chords-codegen-tests:2.0.0-SNAPSHOT.79`
1102+
# Dependencies of `io.spine.chords:spine-chords-codegen-tests:2.0.0-SNAPSHOT.80`
11031103

11041104
## Runtime
11051105
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
@@ -1953,12 +1953,12 @@ This report was generated on **Tue Apr 08 11:56:54 EEST 2025** using [Gradle-Lic
19531953

19541954
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
19551955

1956-
This report was generated on **Tue Apr 08 11:57:03 EEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
1956+
This report was generated on **Fri Apr 18 13:36:27 EEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
19571957

19581958

19591959

19601960

1961-
# Dependencies of `io.spine.chords:spine-chords-core:2.0.0-SNAPSHOT.79`
1961+
# Dependencies of `io.spine.chords:spine-chords-core:2.0.0-SNAPSHOT.80`
19621962

19631963
## Runtime
19641964
1. **Group** : cafe.adriel.voyager. **Name** : voyager-core. **Version** : 1.0.1.
@@ -2991,12 +2991,12 @@ This report was generated on **Tue Apr 08 11:57:03 EEST 2025** using [Gradle-Lic
29912991

29922992
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
29932993

2994-
This report was generated on **Tue Apr 08 11:57:05 EEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
2994+
This report was generated on **Fri Apr 18 13:36:28 EEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
29952995

29962996

29972997

29982998

2999-
# Dependencies of `io.spine.chords:spine-chords-proto:2.0.0-SNAPSHOT.79`
2999+
# Dependencies of `io.spine.chords:spine-chords-proto:2.0.0-SNAPSHOT.80`
30003000

30013001
## Runtime
30023002
1. **Group** : cafe.adriel.voyager. **Name** : voyager-core. **Version** : 1.0.1.**No license information found**
@@ -4015,12 +4015,12 @@ This report was generated on **Tue Apr 08 11:57:05 EEST 2025** using [Gradle-Lic
40154015

40164016
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
40174017

4018-
This report was generated on **Tue Apr 08 11:57:06 EEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
4018+
This report was generated on **Fri Apr 18 13:36:29 EEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
40194019

40204020

40214021

40224022

4023-
# Dependencies of `io.spine.chords:spine-chords-proto-values:2.0.0-SNAPSHOT.79`
4023+
# Dependencies of `io.spine.chords:spine-chords-proto-values:2.0.0-SNAPSHOT.80`
40244024

40254025
## Runtime
40264026
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
@@ -4814,12 +4814,12 @@ This report was generated on **Tue Apr 08 11:57:06 EEST 2025** using [Gradle-Lic
48144814

48154815
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
48164816

4817-
This report was generated on **Tue Apr 08 11:57:07 EEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
4817+
This report was generated on **Fri Apr 18 13:36:30 EEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
48184818

48194819

48204820

48214821

4822-
# Dependencies of `io.spine.chords:spine-chords-runtime:2.0.0-SNAPSHOT.79`
4822+
# Dependencies of `io.spine.chords:spine-chords-runtime:2.0.0-SNAPSHOT.80`
48234823

48244824
## Runtime
48254825
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
@@ -5583,4 +5583,4 @@ This report was generated on **Tue Apr 08 11:57:07 EEST 2025** using [Gradle-Lic
55835583

55845584
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
55855585

5586-
This report was generated on **Tue Apr 08 11:57:07 EEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
5586+
This report was generated on **Fri Apr 18 13:36:31 EEST 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject.
1010
-->
1111
<groupId>io.spine.chords</groupId>
1212
<artifactId>Chords</artifactId>
13-
<version>2.0.0-SNAPSHOT.79</version>
13+
<version>2.0.0-SNAPSHOT.80</version>
1414

1515
<inceptionYear>2015</inceptionYear>
1616

version.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
/**
2828
* The version of all Chords libraries.
2929
*/
30-
val chordsVersion: String by extra("2.0.0-SNAPSHOT.79")
30+
val chordsVersion: String by extra("2.0.0-SNAPSHOT.80")

0 commit comments

Comments
 (0)