diff --git a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/BillingDemos.kt b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/BillingDemos.kt index df1adb2..2f9cce6 100644 --- a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/BillingDemos.kt +++ b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/BillingDemos.kt @@ -6,9 +6,10 @@ import androidx.compose.material.icons.filled.Fastfood import androidx.compose.material.icons.filled.Info import androidx.compose.material.icons.filled.Shop import androidx.compose.material3.Icon +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.core.rememberDialogState import com.michaelflisar.composedialogs.demo.DemoDialogButton import com.michaelflisar.composedialogs.demo.DemoDialogRegion @@ -19,7 +20,7 @@ import com.michaelflisar.kotbilling.classes.Product import com.michaelflisar.kotbilling.classes.ProductType @Composable -fun BillingDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +fun BillingDemos(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { DemoDialogRegion("Billing Dialogs") DemoDialogRow { DemoDialogBilling(style, icon) @@ -27,13 +28,13 @@ fun BillingDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { } @Composable -private fun RowScope.DemoDialogBilling(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +private fun RowScope.DemoDialogBilling(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val context = LocalContext.current val state = rememberDialogState() if (state.showing) { DialogBilling( state = state, - title = "Dialog", + title = { Text("Dialog") }, products = listOf( DialogBilling.BillingProduct( Product( diff --git a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/ColorDemos.kt b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/ColorDemos.kt index 0395953..1ff6842 100644 --- a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/ColorDemos.kt +++ b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/ColorDemos.kt @@ -3,12 +3,13 @@ package com.michaelflisar.composedialogs.demo.demos import androidx.compose.foundation.layout.RowScope import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ColorLens +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import com.michaelflisar.composedialogs.core.* -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.demo.DemoDialogButton import com.michaelflisar.composedialogs.demo.DemoDialogRegion import com.michaelflisar.composedialogs.demo.DemoDialogRow @@ -17,7 +18,7 @@ import com.michaelflisar.composedialogs.dialogs.color.DialogColor import com.michaelflisar.composedialogs.dialogs.color.rememberDialogColor @Composable -fun ColorDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +fun ColorDemos(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { DemoDialogRegion("Color Dialogs") DemoDialogRow { DemoDialogColor1(style, icon) @@ -28,7 +29,7 @@ fun ColorDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { } @Composable -private fun RowScope.DemoDialogColor1(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +private fun RowScope.DemoDialogColor1(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val context = LocalContext.current val state = rememberDialogState() if (state.showing) { @@ -38,7 +39,7 @@ private fun RowScope.DemoDialogColor1(style: ComposeDialogStyle, icon: (@Composa color = color, alphaSupported = true, icon = icon, - title = "Color Dialog", + title = { Text("Color Dialog") }, style = style, onEvent = { if (it is DialogEvent.Button && it.button == DialogButtonType.Positive) { @@ -58,7 +59,7 @@ private fun RowScope.DemoDialogColor1(style: ComposeDialogStyle, icon: (@Composa } @Composable -private fun RowScope.DemoDialogColor2(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +private fun RowScope.DemoDialogColor2(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val context = LocalContext.current val state = rememberDialogState() if (state.showing) { @@ -69,7 +70,7 @@ private fun RowScope.DemoDialogColor2(style: ComposeDialogStyle, icon: (@Composa alphaSupported = false, labelStyle = DialogColor.LabelStyle.Percent, icon = icon, - title = "Color Dialog", + title = { Text("Color Dialog") }, style = style, onEvent = { if (it is DialogEvent.Button && it.button == DialogButtonType.Positive) { diff --git a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/CustomDemos.kt b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/CustomDemos.kt index 68cf511..f6af793 100644 --- a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/CustomDemos.kt +++ b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/CustomDemos.kt @@ -19,13 +19,13 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import com.michaelflisar.composedialogs.core.* -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.demo.DemoDialogButton import com.michaelflisar.composedialogs.demo.DemoDialogRegion import com.michaelflisar.composedialogs.demo.DemoDialogRow @Composable -fun CustomDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +fun CustomDemos(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { DemoDialogRegion("Custom Dialogs") DemoDialogRow { DemoDialogCustom1(style, icon) @@ -34,14 +34,14 @@ fun CustomDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { } @Composable -private fun RowScope.DemoDialogCustom1(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +private fun RowScope.DemoDialogCustom1(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val state = rememberDialogState() if (state.showing) { Dialog( state = state, style = style, icon = icon, - title = "Custom Dialog" + title = { Text("Custom Dialog") }, ) { var checked by rememberSaveable { mutableStateOf(false) } Row( @@ -68,14 +68,14 @@ private fun RowScope.DemoDialogCustom1(style: ComposeDialogStyle, icon: (@Compos } @Composable -private fun RowScope.DemoDialogCustom2(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +private fun RowScope.DemoDialogCustom2(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val state = rememberDialogState() if (state.showing) { Dialog( state = state, style = style, icon = icon, - title = "Custom Dialog" + title = { Text("Custom Dialog") }, ) { Column( modifier = Modifier.verticalScroll(rememberScrollState()) diff --git a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/DateTimeDemos.kt b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/DateTimeDemos.kt index 780a502..c23b1ad 100644 --- a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/DateTimeDemos.kt +++ b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/DateTimeDemos.kt @@ -7,13 +7,14 @@ import androidx.compose.material.icons.filled.Schedule import androidx.compose.material.icons.filled.Today import androidx.compose.material3.FilledIconButton import androidx.compose.material3.Icon +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import com.michaelflisar.composedialogs.core.DialogButtonType import com.michaelflisar.composedialogs.core.DialogEvent import com.michaelflisar.composedialogs.core.rememberDialogState -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.demo.DemoDialogButton import com.michaelflisar.composedialogs.demo.DemoDialogRegion import com.michaelflisar.composedialogs.demo.DemoDialogRow @@ -32,7 +33,7 @@ import java.time.format.TextStyle import java.util.Locale @Composable -fun DateTimeDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +fun DateTimeDemos(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { DemoDialogRegion("DateTime Dialogs") DemoDialogRow { DemoDialogDate1(style, icon, false) @@ -48,7 +49,7 @@ fun DateTimeDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { @Composable private fun RowScope.DemoDialogDate1( - style: ComposeDialogStyle, + style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?, customSetup: Boolean ) { @@ -103,7 +104,7 @@ private fun RowScope.DemoDialogDate1( setup = setup, dateRange = dateRange, icon = icon, - title = "Select Date", + title = { Text("Select Date") }, style = style, onEvent = { if (it is DialogEvent.Button && it.button == DialogButtonType.Positive) { @@ -126,7 +127,7 @@ private fun RowScope.DemoDialogDate1( @Composable private fun RowScope.DemoDialogTime1( - style: ComposeDialogStyle, + style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?, is24Hours: Boolean ) { @@ -144,7 +145,7 @@ private fun RowScope.DemoDialogTime1( time = time, setup = setup, icon = icon, - title = "Select Time", + title = { Text("Select Time") }, style = style, onEvent = { if (it is DialogEvent.Button && it.button == DialogButtonType.Positive) { diff --git a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/InfoDemos.kt b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/InfoDemos.kt index f142aa9..4568e4c 100644 --- a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/InfoDemos.kt +++ b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/InfoDemos.kt @@ -5,11 +5,12 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Info import androidx.compose.material3.Icon +import androidx.compose.material3.Text import androidx.compose.runtime.* import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.platform.LocalContext import com.michaelflisar.composedialogs.core.* -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.demo.DemoDialogButton import com.michaelflisar.composedialogs.demo.DemoDialogRegion import com.michaelflisar.composedialogs.demo.DemoDialogRow @@ -19,7 +20,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.launch @Composable -fun InfoDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +fun InfoDemos(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { DemoDialogRegion("Info Dialogs") DemoDialogRow { DemoDialogInfo1(style, icon) @@ -30,13 +31,13 @@ fun InfoDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { } @Composable -private fun RowScope.DemoDialogInfo1(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +private fun RowScope.DemoDialogInfo1(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val context = LocalContext.current val state = rememberDialogState() if (state.showing) { DialogInfo( state = state, - title = "Dialog", + title = { Text("Dialog") }, info = "Simple Info Dialog", icon = icon, style = style, @@ -54,7 +55,7 @@ private fun RowScope.DemoDialogInfo1(style: ComposeDialogStyle, icon: (@Composab } @Composable -private fun RowScope.DemoDialogInfo2(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +private fun RowScope.DemoDialogInfo2(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val context = LocalContext.current val state = rememberDialogState( showing = false, @@ -80,7 +81,7 @@ private fun RowScope.DemoDialogInfo2(style: ComposeDialogStyle, icon: (@Composab } DialogInfo( state = state, - title = "Dialog", + title = { Text("Dialog") }, info = if (time == 0) "Dialog can be dismissed" else "Dialog can be dismissed in $time seconds...", icon = currentIcon, style = style, diff --git a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/InputDemos.kt b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/InputDemos.kt index 2d7ab1a..47a3327 100644 --- a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/InputDemos.kt +++ b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/InputDemos.kt @@ -5,13 +5,14 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Numbers import androidx.compose.material.icons.filled.TextFields +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.input.KeyboardType import com.michaelflisar.composedialogs.core.DialogButtonType import com.michaelflisar.composedialogs.core.DialogEvent import com.michaelflisar.composedialogs.core.rememberDialogState -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.demo.DemoDialogButton import com.michaelflisar.composedialogs.demo.DemoDialogRegion import com.michaelflisar.composedialogs.demo.DemoDialogRow @@ -28,7 +29,7 @@ import com.michaelflisar.composedialogs.dialogs.input.rememberDialogInputValidat import com.michaelflisar.composedialogs.dialogs.number.rememberDialogNumber @Composable -fun InputDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +fun InputDemos(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { DemoDialogRegion("Text Input Dialogs") DemoDialogRow { DemoDialogInput1(style, icon) @@ -43,7 +44,7 @@ fun InputDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { } @Composable -private fun RowScope.DemoDialogInput1(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +private fun RowScope.DemoDialogInput1(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val context = LocalContext.current @@ -61,7 +62,7 @@ private fun RowScope.DemoDialogInput1(style: ComposeDialogStyle, icon: (@Composa // input dialog DialogInput( state = state, - title = "Input Dialog", + title = { Text("Input Dialog") }, input = input, inputLabel = "Text", icon = icon, @@ -96,7 +97,7 @@ private fun RowScope.DemoDialogInput1(style: ComposeDialogStyle, icon: (@Composa } @Composable -private fun RowScope.DemoDialogInput2(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +private fun RowScope.DemoDialogInput2(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val context = LocalContext.current @@ -110,7 +111,7 @@ private fun RowScope.DemoDialogInput2(style: ComposeDialogStyle, icon: (@Composa // input dialog DialogInput( state = state, - title = "Input Dialog", + title = { Text("Input Dialog") }, input = input, inputLabel = "Numerical Value", icon = icon, @@ -135,7 +136,7 @@ private fun RowScope.DemoDialogInput2(style: ComposeDialogStyle, icon: (@Composa } @Composable -private fun RowScope.DemoDialogInput3(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +private fun RowScope.DemoDialogInput3(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val context = LocalContext.current @@ -150,7 +151,7 @@ private fun RowScope.DemoDialogInput3(style: ComposeDialogStyle, icon: (@Composa // number dialog DialogInputNumber( state = state, - title = "Input Integer Dialog", + title = { Text("Input Integer Dialog") }, value = value, valueLabel = "Integer", icon = icon, @@ -175,7 +176,7 @@ private fun RowScope.DemoDialogInput3(style: ComposeDialogStyle, icon: (@Composa @Composable private fun RowScope.DemoDialogInput4( - style: ComposeDialogStyle, + style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?, enableButtonLongPress: Boolean ) { @@ -193,7 +194,7 @@ private fun RowScope.DemoDialogInput4( // number dialog DialogNumberPicker( state = state, - title = "Input Integer Dialog", + title = { Text("Input Integer Dialog") }, value = value, icon = icon, style = style, diff --git a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/ListDemos.kt b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/ListDemos.kt index 3211427..fca1e0d 100644 --- a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/ListDemos.kt +++ b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/ListDemos.kt @@ -30,7 +30,7 @@ import com.google.accompanist.drawablepainter.rememberDrawablePainter import com.michaelflisar.composedialogs.core.DialogButtonType import com.michaelflisar.composedialogs.core.DialogEvent import com.michaelflisar.composedialogs.core.rememberDialogState -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.demo.DemoDialogButton import com.michaelflisar.composedialogs.demo.DemoDialogRegion import com.michaelflisar.composedialogs.demo.DemoDialogRow @@ -42,7 +42,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @Composable -fun ListDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +fun ListDemos(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val context = LocalContext.current DemoDialogRegion("List Dialogs (Simple Layouts)") @@ -227,7 +227,7 @@ fun ListDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { @Composable private fun RowScope.DemoList( - style: ComposeDialogStyle, + style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?, itemContents: DialogList.ItemContents, itemIdProvider: (item: T) -> Int, @@ -271,7 +271,7 @@ private fun RowScope.DemoList( if (items != null) { DialogList( state = state, - title = "Dialog", + title = { Text("List Dialog") }, items = items, itemIdProvider = itemIdProvider, itemContents = itemContents, @@ -286,7 +286,7 @@ private fun RowScope.DemoList( } else { DialogList( state = state, - title = "Dialog", + title = { Text("List Dialog") }, loadingIndicator = { Column( modifier = Modifier.fillMaxWidth(), diff --git a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/NumberDemos.kt b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/NumberDemos.kt index 9ff22f7..1f59f20 100644 --- a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/NumberDemos.kt +++ b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/NumberDemos.kt @@ -6,12 +6,13 @@ import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Numbers import androidx.compose.material.icons.filled.Remove import androidx.compose.material3.Icon +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext import com.michaelflisar.composedialogs.core.DialogButtonType import com.michaelflisar.composedialogs.core.DialogEvent import com.michaelflisar.composedialogs.core.rememberDialogState -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.demo.DemoDialogButton import com.michaelflisar.composedialogs.demo.DemoDialogRegion import com.michaelflisar.composedialogs.demo.DemoDialogRow @@ -22,7 +23,7 @@ import com.michaelflisar.composedialogs.dialogs.number.RepeatingButton import com.michaelflisar.composedialogs.dialogs.number.rememberDialogNumber @Composable -fun NumberDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +fun NumberDemos(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { DemoDialogRegion("Number Picker Dialogs") DemoDialogRow { DemoDialogInput1(style, icon) @@ -40,7 +41,7 @@ fun NumberDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { @Composable private fun RowScope.DemoDialogInput1( - style: ComposeDialogStyle, + style: ComposeDialogStyle2, icon: (@Composable () -> Unit)? ) { @@ -57,7 +58,7 @@ private fun RowScope.DemoDialogInput1( // number dialog DialogNumberPicker( state = state, - title = "Integer Picker Dialog", + title = { Text("Integer Picker Dialog") }, value = value, icon = icon, style = style, @@ -84,7 +85,7 @@ private fun RowScope.DemoDialogInput1( @Composable private fun RowScope.DemoDialogInput2( - style: ComposeDialogStyle, + style: ComposeDialogStyle2, icon: (@Composable () -> Unit)? ) { @@ -101,7 +102,7 @@ private fun RowScope.DemoDialogInput2( // number dialog DialogNumberPicker( state = state, - title = "Integer Picker Dialog", + title = { Text("Integer Picker Dialog") }, value = value, icon = icon, style = style, @@ -128,7 +129,7 @@ private fun RowScope.DemoDialogInput2( } @Composable -private fun RowScope.DemoDialogInput3(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +private fun RowScope.DemoDialogInput3(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val context = LocalContext.current @@ -143,7 +144,7 @@ private fun RowScope.DemoDialogInput3(style: ComposeDialogStyle, icon: (@Composa // number dialog DialogNumberPicker( state = state, - title = "Float Picker Dialog", + title = { Text("Float Picker Dialog") }, value = value, icon = icon, style = style, @@ -176,7 +177,7 @@ private fun RowScope.DemoDialogInput3(style: ComposeDialogStyle, icon: (@Composa @Composable -private fun RowScope.DemoDialogInput4(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +private fun RowScope.DemoDialogInput4(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { val context = LocalContext.current @@ -191,7 +192,7 @@ private fun RowScope.DemoDialogInput4(style: ComposeDialogStyle, icon: (@Composa // number dialog DialogNumberPicker( state = state, - title = "Int Picker Dialog", + title = { Text("Int Picker Dialog") }, value = value, icon = icon, style = style, diff --git a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/ProgressDemos.kt b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/ProgressDemos.kt index e87e72d..8ab921a 100644 --- a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/ProgressDemos.kt +++ b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/ProgressDemos.kt @@ -11,7 +11,7 @@ import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import com.michaelflisar.composedialogs.core.* -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.demo.DemoDialogButton import com.michaelflisar.composedialogs.demo.DemoDialogRegion import com.michaelflisar.composedialogs.demo.DemoDialogRow @@ -21,7 +21,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.launch @Composable -fun ProgressDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +fun ProgressDemos(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { DemoDialogRegion("Progress Dialogs") DemoDialogRow { DemoDialogProgress1(style, icon) @@ -34,7 +34,7 @@ fun ProgressDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { @Composable private fun RowScope.DemoDialogProgress1( - style: ComposeDialogStyle, + style: ComposeDialogStyle2, icon: (@Composable () -> Unit)? ) { val context = LocalContext.current @@ -47,7 +47,7 @@ private fun RowScope.DemoDialogProgress1( }, progressStyle = DialogProgress.Style.Indeterminate(linear = true), icon = icon, - title = "Progress Dialog", + title = { Text("Progress Dialog") }, buttons = DialogDefaults.buttons( positive = DialogButton("Stop") ), @@ -71,7 +71,7 @@ private fun RowScope.DemoDialogProgress1( @Composable private fun RowScope.DemoDialogProgress2( - style: ComposeDialogStyle, + style: ComposeDialogStyle2, icon: (@Composable () -> Unit)? ) { val context = LocalContext.current @@ -84,7 +84,7 @@ private fun RowScope.DemoDialogProgress2( }, progressStyle = DialogProgress.Style.Indeterminate(linear = false), icon = icon, - title = "Progress Dialog", + title = { Text("Progress Dialog") }, buttons = DialogDefaults.buttons( positive = DialogButton("Stop") ), @@ -108,7 +108,7 @@ private fun RowScope.DemoDialogProgress2( @Composable private fun RowScope.DemoDialogProgress3( - style: ComposeDialogStyle, + style: ComposeDialogStyle2, icon: (@Composable () -> Unit)? ) { val context = LocalContext.current @@ -150,7 +150,7 @@ private fun RowScope.DemoDialogProgress3( }, progressStyle = progressStyle, icon = iconToShow, - title = "Progress Dialog", + title = { Text("Progress Dialog") }, buttons = DialogDefaults.buttons( positive = DialogButton("Close") ), diff --git a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/SingleDialogWithListDemos.kt b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/SingleDialogWithListDemos.kt index 5cab877..bd8d043 100644 --- a/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/SingleDialogWithListDemos.kt +++ b/demo/android/src/main/java/com/michaelflisar/composedialogs/demo/demos/SingleDialogWithListDemos.kt @@ -16,14 +16,14 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import com.michaelflisar.composedialogs.core.DialogStateWithData -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.core.rememberDialogState import com.michaelflisar.composedialogs.demo.DemoDialogRegion import com.michaelflisar.composedialogs.demo.showToast import com.michaelflisar.composedialogs.dialogs.info.DialogInfo @Composable -fun ColumnScope.SingleDialogWithListDemos(style: ComposeDialogStyle, icon: (@Composable () -> Unit)?) { +fun ColumnScope.SingleDialogWithListDemos(style: ComposeDialogStyle2, icon: (@Composable () -> Unit)?) { DemoDialogRegion("Clicking any item in the list below will open its dialog") val items = 1..100 @@ -57,7 +57,7 @@ fun ColumnScope.SingleDialogWithListDemos(style: ComposeDialogStyle, icon: (@Com @Composable private fun ListDialog( stateWithData: DialogStateWithData, - style: ComposeDialogStyle, + style: ComposeDialogStyle2, icon: (@Composable () -> Unit)? ) { if (stateWithData.showing) { @@ -65,7 +65,7 @@ private fun ListDialog( val data = stateWithData.requireData() DialogInfo( state = stateWithData, - title = "Item Info", + title = { Text("Item Info") }, info = "This is the dialog for Item #$data", icon = icon, style = style, diff --git a/demo/desktop/src/jvmMain/kotlin/com/michaelflisar/composedialogs/demo/Main.kt b/demo/desktop/src/jvmMain/kotlin/com/michaelflisar/composedialogs/demo/Main.kt index faf2a74..57bc6c6 100644 --- a/demo/desktop/src/jvmMain/kotlin/com/michaelflisar/composedialogs/demo/Main.kt +++ b/demo/desktop/src/jvmMain/kotlin/com/michaelflisar/composedialogs/demo/Main.kt @@ -23,27 +23,33 @@ import androidx.compose.ui.window.rememberWindowState import com.michaelflisar.composedialogs.core.DialogButtonType import com.michaelflisar.composedialogs.core.DialogDefaults import com.michaelflisar.composedialogs.core.DialogEvent -import com.michaelflisar.composedialogs.core.Options -import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.rememberDialogState -import com.michaelflisar.composedialogs.core.styleDialog +import com.michaelflisar.composedialogs.core.styleWindowsDialog import com.michaelflisar.composedialogs.dialogs.color.DialogColor import com.michaelflisar.composedialogs.dialogs.color.rememberDialogColor -import com.michaelflisar.composedialogs.dialogs.color.specialOptionsColorDialog +import com.michaelflisar.composedialogs.dialogs.color.styleWindowsColorDialog import com.michaelflisar.composedialogs.dialogs.date.DialogDate import com.michaelflisar.composedialogs.dialogs.date.rememberDialogDate +import com.michaelflisar.composedialogs.dialogs.date.styleWindowsDateDialog import com.michaelflisar.composedialogs.dialogs.info.DialogInfo +import com.michaelflisar.composedialogs.dialogs.info.styleWindowsInfoDialog import com.michaelflisar.composedialogs.dialogs.input.DialogInput import com.michaelflisar.composedialogs.dialogs.input.DialogInputNumber -import com.michaelflisar.composedialogs.dialogs.number.DialogNumberPicker -import com.michaelflisar.composedialogs.dialogs.number.NumberPickerSetup import com.michaelflisar.composedialogs.dialogs.input.rememberDialogInput import com.michaelflisar.composedialogs.dialogs.input.rememberDialogInputNumber +import com.michaelflisar.composedialogs.dialogs.input.styleWindowsInputDialog +import com.michaelflisar.composedialogs.dialogs.list.DialogList +import com.michaelflisar.composedialogs.dialogs.list.styleWindowsListDialog +import com.michaelflisar.composedialogs.dialogs.number.DialogNumberPicker +import com.michaelflisar.composedialogs.dialogs.number.NumberPickerSetup import com.michaelflisar.composedialogs.dialogs.number.rememberDialogNumber +import com.michaelflisar.composedialogs.dialogs.number.styleWindowsNumberDialog import com.michaelflisar.composedialogs.dialogs.progress.DialogProgress +import com.michaelflisar.composedialogs.dialogs.progress.styleWindowsProgressDialog import com.michaelflisar.composedialogs.dialogs.time.DialogTime import com.michaelflisar.composedialogs.dialogs.time.rememberDialogTime -import com.michaelflisar.composedialogs.dialogs.list.DialogList +import com.michaelflisar.composedialogs.dialogs.time.styleWindowsTimeDialog +import com.michaelflisar.toolbox.composables.MyCheckbox import com.michaelflisar.toolbox.composables.MyTitle import com.michaelflisar.toolbox.ui.MyScrollableLazyColumn @@ -73,6 +79,7 @@ fun main() { height = 600.dp ) ) { + val useWindowsDialog = remember { mutableStateOf(false) } val infos = remember { mutableStateListOf() } val dialog = rememberDialogState(data = null) Column( @@ -80,6 +87,7 @@ fun main() { verticalArrangement = Arrangement.spacedBy(8.dp) ) { MyTitle("Dialogs") + MyCheckbox(title = "Use Windows Dialog?", checked = useWindowsDialog) FlowRow( horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterVertically) @@ -109,12 +117,15 @@ fun main() { when (dialog.data) { Dialog.Color -> { val color = rememberDialogColor(Color.Blue.copy(alpha = .5f)) + val style = if (!useWindowsDialog.value) { + DialogDefaults.styleDialog() + } else DialogDefaults.styleWindowsColorDialog("Color Dialog") DialogColor( - title = "Color Dialog", + style = style, + title = { Text("Color Dialog") }, state = dialog, color = color, alphaSupported = true, - style = DialogDefaults.styleDialog(), onEvent = { if (it is DialogEvent.Button && it.button == DialogButtonType.Positive) { infos.add("Selected color: #${color.value.toArgb().toHexString()}") @@ -124,10 +135,15 @@ fun main() { } ) } + Dialog.Date -> { + val style = if (!useWindowsDialog.value) { + DialogDefaults.styleDialog() + } else DialogDefaults.styleWindowsDateDialog("Select Date") val date = rememberDialogDate() DialogDate( - title = "Select Date", + style = style, + title = { Text("Select Date") }, state = dialog, date = date, onEvent = { @@ -139,10 +155,15 @@ fun main() { } ) } + Dialog.Time -> { + val style = if (!useWindowsDialog.value) { + DialogDefaults.styleDialog() + } else DialogDefaults.styleWindowsTimeDialog("Select Time") val time = rememberDialogTime() DialogTime( - title = "Select Time", + style = style, + title = { Text("Select Time") }, state = dialog, time = time, //setup = DialogTimeDefaults.setup(is24Hours = true), @@ -155,9 +176,14 @@ fun main() { } ) } + Dialog.Info -> { + val style = if (!useWindowsDialog.value) { + DialogDefaults.styleDialog() + } else DialogDefaults.styleWindowsInfoDialog("Info Dialog") DialogInfo( - title = "Info Dialog", + style = style, + title = { Text("Info Dialog") }, state = dialog, info = "Information", infoLabel = "Important", @@ -166,9 +192,14 @@ fun main() { } ) } + Dialog.Progress -> { + val style = if (!useWindowsDialog.value) { + DialogDefaults.styleDialog() + } else DialogDefaults.styleWindowsProgressDialog("Progress Dialog") DialogProgress( - title = "Progress Dialog", + style = style, + title = { Text("Progress Dialog") }, state = dialog, content = { Text("Loading...") @@ -178,10 +209,15 @@ fun main() { } ) } + Dialog.Input -> { + val style = if (!useWindowsDialog.value) { + DialogDefaults.styleDialog() + } else DialogDefaults.styleWindowsInputDialog("Input Dialog") val input = rememberDialogInput("") DialogInput( - title = "Input Dialog", + style = style, + title = { Text("Input Dialog") }, state = dialog, inputLabel = "Enter some text...", input = input, @@ -194,10 +230,15 @@ fun main() { } ) } + Dialog.Number -> { + val style = if (!useWindowsDialog.value) { + DialogDefaults.styleDialog() + } else DialogDefaults.styleWindowsInputDialog("Number Dialog") val input = rememberDialogInputNumber(0) DialogInputNumber( - title = "Number Dialog", + style = style, + title = { Text("Number Dialog") }, state = dialog, valueLabel = "Enter a valid Integer...", value = input, @@ -210,10 +251,15 @@ fun main() { } ) } + Dialog.NumberPicker -> { + val style = if (!useWindowsDialog.value) { + DialogDefaults.styleDialog() + } else DialogDefaults.styleWindowsNumberDialog("Number Picker Dialog") val value = rememberDialogNumber(0) DialogNumberPicker( - title = "Number Picker Dialog", + style = style, + title = { Text("Number Picker Dialog") }, state = dialog, value = value, setup = NumberPickerSetup( @@ -228,11 +274,16 @@ fun main() { } ) } - Dialog.List -> { + + Dialog.List -> { + val style = if (!useWindowsDialog.value) { + DialogDefaults.styleDialog() + } else DialogDefaults.styleWindowsListDialog("List Dialog") val selected = remember { mutableStateOf(null) } - val items = List(100) { "Item $it"} + val items = List(100) { "Item $it" } DialogList( - title = "List Dialog", + style = style, + title = { Text("List Dialog") }, description = "Some optional description", state = dialog, items = items, @@ -253,6 +304,7 @@ fun main() { } ) } + null -> { // } diff --git a/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/DialogDefaultsExtensions.kt b/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/DialogDefaultsExtensions.kt index 4fb758a..0da0999 100644 --- a/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/DialogDefaultsExtensions.kt +++ b/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/DialogDefaultsExtensions.kt @@ -1,62 +1,12 @@ package com.michaelflisar.composedialogs.core -import androidx.compose.material3.AlertDialogDefaults import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.Shape import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.window.SecureFlagPolicy import com.michaelflisar.composedialogs.core.style.BottomSheetStyle -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle -import com.michaelflisar.composedialogs.core.style.DialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 -/** - * the setup of a dialog that shows as a normal dialog popup - * - * @param swipeDismissable if true, the dialog can be swiped away by an up/down swipe - * @param dismissOnBackPress if true, the dialog can be dismissed by a back press - * @param dismissOnClickOutside if true, the dialog can be dismissed by clicking outside of its borders - * @param usePlatformDefaultWidth if true, platform default width is used - * @param shape the [Shape] of the dialog - * @param containerColor the [Color] of the container - * @param iconContentColor the content [Color] of the icon - * @param titleContentColor the content [Color] of the title - * @param textContentColor the content [Color] of the text - * @param tonalElevation the elevation for the tonal [Color] - */ -@Composable -fun DialogDefaults.styleDialog( - swipeDismissable: Boolean = false, - // DialogProperties - dismissOnBackPress: Boolean = true, - dismissOnClickOutside: Boolean = true, - securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit, - usePlatformDefaultWidth: Boolean = true, - decorFitsSystemWindows: Boolean = true, - // AlertDialog Settings - shape: Shape = AlertDialogDefaults.shape, - containerColor: Color = AlertDialogDefaults.containerColor, - iconContentColor: Color = AlertDialogDefaults.iconContentColor, - titleContentColor: Color = AlertDialogDefaults.titleContentColor, - textContentColor: Color = AlertDialogDefaults.textContentColor, - tonalElevation: Dp = AlertDialogDefaults.TonalElevation -): ComposeDialogStyle = DialogStyle( - swipeDismissable, - // DialogProperties - dismissOnBackPress, - dismissOnClickOutside, - securePolicy, - usePlatformDefaultWidth, - decorFitsSystemWindows, - // AlertDialog Settings - shape, - containerColor, - iconContentColor, - titleContentColor, - textContentColor, - tonalElevation -) private val SheetPeekHeight = 56.dp * 2 // we want peek height for content + fixed buttons so with take 56*2 @@ -83,7 +33,7 @@ fun DialogDefaults.styleBottomSheet( securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit, //usePlatformDefaultWidth: Boolean = true, decorFitsSystemWindows: Boolean = true -): ComposeDialogStyle = BottomSheetStyle( +): ComposeDialogStyle2 = BottomSheetStyle( dragHandle, hideAnimated, resizeContent, diff --git a/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/Platform.android.kt b/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/Platform.android.kt index 5fb66e3..d77917c 100644 --- a/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/Platform.android.kt +++ b/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/Platform.android.kt @@ -3,8 +3,6 @@ package com.michaelflisar.composedialogs.core import android.content.res.Configuration import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope -import androidx.compose.foundation.layout.IntrinsicSize -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListScope @@ -63,13 +61,4 @@ actual fun DialogContentScrollableLazyColumn( actual fun DialogDefaults.specialOptions() : SpecialOptions { return SpecialOptions() -} - -/** - * the special options for a dialog - * - * @param dialogIntrinsicWidthMin if true, the dialog width will use [IntrinsicSize.Min] - */ -actual class SpecialOptions( - val dialogIntrinsicWidthMin: Boolean = false -) \ No newline at end of file +} \ No newline at end of file diff --git a/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/internal/Swipeable.kt b/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/internal/Swipeable.kt deleted file mode 100644 index 3c97f4b..0000000 --- a/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/internal/Swipeable.kt +++ /dev/null @@ -1,84 +0,0 @@ -package com.michaelflisar.composedialogs.core.internal - -import androidx.compose.animation.core.tween -import androidx.compose.animation.rememberSplineBasedDecay -import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.gestures.AnchoredDraggableState -import androidx.compose.foundation.gestures.DraggableAnchors -import androidx.compose.runtime.Composable -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.derivedStateOf -import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.unit.IntSize -import androidx.compose.ui.unit.dp -import com.michaelflisar.composedialogs.core.style.BottomSheetStyle - -internal object Swipeable { - - enum class DragValue { Start, Center, End } - enum class BottomSheetState { Collapsed, Peek, Expanded } - - @OptIn(ExperimentalFoundationApi::class) - @Composable - fun createState( - maxSwipeDistance: Float - ): AnchoredDraggableState { - val anchors = DraggableAnchors { - DragValue.Start at -maxSwipeDistance - DragValue.Center at 0f - DragValue.End at maxSwipeDistance - } - - val decayAnimSpec = rememberSplineBasedDecay() - val dragState = remember { - AnchoredDraggableState( - initialValue = DragValue.Center, - anchors = anchors, - positionalThreshold = { distance: Float -> distance * 0.5f }, - velocityThreshold = { maxSwipeDistance }, - snapAnimationSpec = tween(), - decayAnimationSpec = decayAnimSpec, - confirmValueChange = { true } - ) - } - return dragState - } - - @OptIn(ExperimentalFoundationApi::class) - @Composable - fun createState( - style: BottomSheetStyle, - contentSize: MutableState - ): AnchoredDraggableState { - val density = LocalDensity.current - - val maxSwipeDistance by remember(contentSize.value) { - derivedStateOf { (contentSize.value.height.takeIf { it > 0 } ?: 0f).toFloat() } - } - val peekHeight = - (maxSwipeDistance - with(density) { style.peekHeight.toPx() }).coerceAtLeast(0f) - - - val anchors = DraggableAnchors { - BottomSheetState.Collapsed at maxSwipeDistance - BottomSheetState.Peek at peekHeight - BottomSheetState.Expanded at 0f - } - - val decayAnimSpec = rememberSplineBasedDecay() - val dragState = remember(maxSwipeDistance) { - AnchoredDraggableState( - initialValue = BottomSheetState.Expanded, - anchors = anchors, - positionalThreshold = { distance: Float -> distance * 0.5f }, - velocityThreshold = { maxSwipeDistance }, - snapAnimationSpec = tween(), - decayAnimationSpec = decayAnimSpec, - confirmValueChange = { true } - ) - } - return dragState - } -} \ No newline at end of file diff --git a/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/style/BottomSheetStyle.kt b/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/style/BottomSheetStyle.kt index e822b3c..d637f53 100644 --- a/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/style/BottomSheetStyle.kt +++ b/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/style/BottomSheetStyle.kt @@ -1,9 +1,12 @@ package com.michaelflisar.composedialogs.core.style +import androidx.compose.animation.core.tween +import androidx.compose.animation.rememberSplineBasedDecay import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.gestures.AnchoredDraggableState +import androidx.compose.foundation.gestures.DraggableAnchors import androidx.compose.foundation.gestures.Orientation import androidx.compose.foundation.gestures.anchoredDraggable import androidx.compose.foundation.gestures.animateTo @@ -34,7 +37,6 @@ import androidx.compose.material3.LocalContentColor import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface -import androidx.compose.material3.Text import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider @@ -48,7 +50,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clipToBounds @@ -71,8 +72,6 @@ import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.copied.AlertDialogFlowRow import com.michaelflisar.composedialogs.core.copied.ButtonsCrossAxisSpacing import com.michaelflisar.composedialogs.core.copied.ButtonsMainAxisSpacing -import com.michaelflisar.composedialogs.core.internal.Swipeable -import com.michaelflisar.composedialogs.core.internal.Swipeable.BottomSheetState import com.michaelflisar.composedialogs.core.views.ComposeDialogButton import kotlinx.coroutines.launch import kotlin.math.roundToInt @@ -88,15 +87,14 @@ internal class BottomSheetStyle( securePolicy: SecureFlagPolicy, //usePlatformDefaultWidth: Boolean, decorFitsSystemWindows: Boolean, -) : ComposeDialogStyle { +) : ComposeDialogStyle2 { - override val type = ComposeDialogStyle.Type.BottomSheet + override val type = ComposeDialogStyle2.Type.BottomSheet private val BottomSheetMaxWidth = 640.dp private val BottomSheetTopPadding = 72.dp private val BottomSheetVerticalPaddingPadding = 56.dp - @OptIn(ExperimentalComposeUiApi::class) internal val dialogProperties = DialogProperties( dismissOnBackPress, dismissOnClickOutside, @@ -108,7 +106,7 @@ internal class BottomSheetStyle( @OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class) @Composable override fun Show( - title: String?, + title: (@Composable () -> Unit)?, icon: @Composable (() -> Unit)?, buttons: DialogButtons, options: Options, @@ -138,7 +136,7 @@ internal class BottomSheetStyle( val buttonPressed = remember { mutableStateOf(false) } - val dragState = Swipeable.createState(this, contentSize) + val dragState = createDraggableState(this, contentSize) val dismiss = { if (hideAnimated) { if (state.interactionSource.dismissAllowed.value) { @@ -252,7 +250,7 @@ internal class BottomSheetStyle( @Composable private fun ColumnScope.SheetHeader( - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, dismiss: () -> Boolean ) { @@ -300,7 +298,7 @@ internal class BottomSheetStyle( Box( modifier = if (icon != null) Modifier.align(Alignment.CenterHorizontally) else Modifier ) { - Text(title) + title() } } } @@ -439,4 +437,42 @@ internal class BottomSheetStyle( orientation = Orientation.Vertical ) } + + enum class BottomSheetState { Collapsed, Peek, Expanded } + + @OptIn(ExperimentalFoundationApi::class) + @Composable + private fun createDraggableState( + style: BottomSheetStyle, + contentSize: MutableState + ): AnchoredDraggableState { + val density = LocalDensity.current + + val maxSwipeDistance by remember(contentSize.value) { + derivedStateOf { (contentSize.value.height.takeIf { it > 0 } ?: 0f).toFloat() } + } + val peekHeight = + (maxSwipeDistance - with(density) { style.peekHeight.toPx() }).coerceAtLeast(0f) + + + val anchors = DraggableAnchors { + BottomSheetState.Collapsed at maxSwipeDistance + BottomSheetState.Peek at peekHeight + BottomSheetState.Expanded at 0f + } + + val decayAnimSpec = rememberSplineBasedDecay() + val dragState = remember(maxSwipeDistance) { + AnchoredDraggableState( + initialValue = BottomSheetState.Expanded, + anchors = anchors, + positionalThreshold = { distance: Float -> distance * 0.5f }, + velocityThreshold = { maxSwipeDistance }, + snapAnimationSpec = tween(), + decayAnimationSpec = decayAnimSpec, + confirmValueChange = { true } + ) + } + return dragState + } } \ No newline at end of file diff --git a/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/style/DialogStyle.kt b/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/style/DialogStyle.kt deleted file mode 100644 index eb2f59c..0000000 --- a/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/style/DialogStyle.kt +++ /dev/null @@ -1,267 +0,0 @@ -package com.michaelflisar.composedialogs.core.style - -import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.gestures.Orientation -import androidx.compose.foundation.gestures.anchoredDraggable -import androidx.compose.foundation.gestures.animateTo -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.ColumnScope -import androidx.compose.foundation.layout.IntrinsicSize -import androidx.compose.foundation.layout.offset -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.sizeIn -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.layout.wrapContentHeight -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.rememberCoroutineScope -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.Shape -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.IntOffset -import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.DialogProperties -import androidx.compose.ui.window.SecureFlagPolicy -import com.michaelflisar.composedialogs.core.DialogButtonType -import com.michaelflisar.composedialogs.core.DialogButtons -import com.michaelflisar.composedialogs.core.DialogEvent -import com.michaelflisar.composedialogs.core.DialogState -import com.michaelflisar.composedialogs.core.Options -import com.michaelflisar.composedialogs.core.SpecialOptions -import com.michaelflisar.composedialogs.core.copied.DialogMaxWidth -import com.michaelflisar.composedialogs.core.copied.DialogMinWidth -import com.michaelflisar.composedialogs.core.internal.Swipeable -import com.michaelflisar.composedialogs.core.views.ComposeDialogButton -import kotlinx.coroutines.launch -import kotlin.math.abs -import kotlin.math.roundToInt - -// Wrapper around Dialog because of resizing issues after initial compose: -// Github: https://stackoverflow.com/questions/71285843/how-to-make-dialog-re-measure-when-a-child-size-changes-dynamically/71287474 -// Issue: https://issuetracker.google.com/issues/221643630 - -internal val DialogHorizontalMinMargin = 16.dp -internal val DialogVerticalMinMargin = DialogHorizontalMinMargin - -internal class DialogStyle( - val swipeDismissable: Boolean, - // DialogProperties - dismissOnBackPress: Boolean, - dismissOnClickOutside: Boolean, - securePolicy: SecureFlagPolicy, - usePlatformDefaultWidth: Boolean, - decorFitsSystemWindows: Boolean, - // AlertDialog Settings - val shape: Shape, - val containerColor: Color, - val iconContentColor: Color, - val titleContentColor: Color, - val textContentColor: Color, - val tonalElevation: Dp -) : ComposeDialogStyle { - - override val type = ComposeDialogStyle.Type.Dialog - - private val dialogProperties = DialogProperties( - dismissOnBackPress, - dismissOnClickOutside, - securePolicy, - usePlatformDefaultWidth, - decorFitsSystemWindows - ) - - @Composable - override fun Show( - title: String?, - icon: @Composable (() -> Unit)?, - buttons: DialogButtons, - options: Options, - specialOptions: SpecialOptions, - state: DialogState, - onEvent: (event: DialogEvent) -> Unit, - content: @Composable (ColumnScope.() -> Unit) - ) { - val modifierSwipeDismiss = getSwipeDismissModifier(state, onEvent) - ComposeAlertDialog( - onDismissRequest = { - state.dismiss(onEvent) - }, - confirmButton = { - ComposeDialogButton( - buttons.positive, - DialogButtonType.Positive, - options, - state, - requestDismiss = { - state.dismiss() - }, - onEvent - ) - }, - modifier = Modifier - .wrapContentHeight() - .then(modifierSwipeDismiss), - dismissButton = if (buttons.negative.text.isNotEmpty()) { - { - ComposeDialogButton( - buttons.negative, - DialogButtonType.Negative, - options, - state, - requestDismiss = { - state.dismiss() - }, - onEvent - ) - } - } else null, - icon = icon, - title = title?.let { - { Text(title) } - }, - text = { - val scrollModifier = if (options.wrapContentInScrollableContainer) { - Modifier - .wrapContentHeight() - .verticalScroll(rememberScrollState()) - } else Modifier - Column( - modifier = Modifier - .then(scrollModifier) - .sizeIn(minWidth = DialogMinWidth, maxWidth = DialogMaxWidth) - .then( - if (specialOptions.dialogIntrinsicWidthMin) { - Modifier.width(IntrinsicSize.Min) - } else Modifier - ), - //horizontalAlignment = Alignment.CenterHorizontally - ) { - content() - } - } - ) - } - - @OptIn(ExperimentalFoundationApi::class) - @Composable - private fun getSwipeDismissModifier( - state: DialogState, - onEvent: (event: DialogEvent) -> Unit - ): Modifier { - return if (swipeDismissable) { - val density = LocalDensity.current - - val maxSwipeDistance = with(density) { 96.dp.toPx() } - val dragState = Swipeable.createState(maxSwipeDistance) - - val coroutineScope = rememberCoroutineScope() - - LaunchedEffect(dragState.targetValue ) { - when (dragState.targetValue ) { - Swipeable.DragValue.Center -> { - // ... - } - Swipeable.DragValue.Start, - Swipeable.DragValue.End -> { - if (!state.dismiss(onEvent)) { - // expand again if dismissing is not allowed - coroutineScope.launch { - dragState.animateTo(Swipeable.DragValue.Center) - } - } - } - } - } - - val alpha = 1f - (0.3f * abs(dragState.requireOffset() / maxSwipeDistance)) - - Modifier - .offset { - IntOffset( - 0, - dragState - .requireOffset() - .roundToInt() / 4 - ) - } - .anchoredDraggable( - state = dragState, - //anchors = anchors, - //thresholds = { _, _ -> FractionalThreshold(0.3f) }, - orientation = Orientation.Vertical - ) - .alpha(alpha) - } else Modifier - } - - @Composable - internal fun ComposeAlertDialog( - onDismissRequest: () -> Unit, - confirmButton: @Composable () -> Unit, - modifier: Modifier = Modifier, - dismissButton: @Composable (() -> Unit)? = null, - icon: @Composable (() -> Unit)? = null, - title: @Composable (() -> Unit)? = null, - text: @Composable (() -> Unit)? = null - ) { - val properties = dialogProperties - val (fixedProperties, fixedModifier, fixedModifierInner) = if (properties.usePlatformDefaultWidth) { - Triple( - DialogProperties( - properties.dismissOnBackPress, - properties.dismissOnClickOutside, - false - ), - // outer modifier gets paddings only so that dismiss on click outside works as desired - Modifier - .sizeIn(minWidth = DialogMinWidth, maxWidth = DialogMaxWidth) - //.background(Color.Red) - .padding( - horizontal = DialogHorizontalMinMargin, - vertical = DialogVerticalMinMargin - ) - //.background(Color.Green) - , - Modifier - .sizeIn(minWidth = DialogMinWidth, maxWidth = DialogMaxWidth) - //.background(Color.Blue) - //.padding(horizontal = DialogHorizontalMinMargin, vertical = DialogVerticalMinMargin) - //.background(Color.Yellow) - ) - } else { - Triple( - properties, - Modifier, - Modifier - ) - } - - com.michaelflisar.composedialogs.core.copied.AlertDialog( - onDismissRequest = onDismissRequest, - confirmButton = confirmButton, - modifier = modifier - .wrapContentHeight() - .then(fixedModifier), - modifierInner = modifier - .wrapContentHeight() - .then(fixedModifierInner), - dismissButton = dismissButton, - icon = icon, - title = title, - text = text, - shape = shape, - containerColor = containerColor, - iconContentColor = iconContentColor, - titleContentColor = titleContentColor, - textContentColor = textContentColor, - tonalElevation = tonalElevation, - properties = fixedProperties - ) - } -} \ No newline at end of file diff --git a/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/Dialog.kt b/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/Dialog.kt index 4a928eb..0251dfa 100644 --- a/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/Dialog.kt +++ b/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/Dialog.kt @@ -1,8 +1,14 @@ package com.michaelflisar.composedialogs.core import androidx.compose.foundation.layout.ColumnScope +import androidx.compose.material3.AlertDialogDefaults import androidx.compose.runtime.* -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.window.DialogProperties +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 +import com.michaelflisar.composedialogs.core.style.DialogStyle // ------------------ // defaults functions @@ -14,7 +20,7 @@ import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle * @param state the [DialogState] of the dialog * @param title the optional title of the dialog (an empty title will not be shown) * @param icon the optional icon of the dialog - * @param style the [ComposeDialogStyle] of the dialog - use [DialogDefaults.styleDialog] or [DialogDefaults.styleBottomSheet] + * @param style the [ComposeDialogStyle2] of the dialog - use [DialogDefaults.styleDialog] or [DialogDefaults.styleBottomSheet] * @param buttons the [DialogButtons] of the dialog - use [DialogDefaults.buttons] here [DialogDefaults.buttonsDisabled] * @param options the [Options] of the dialog * @param specialOptions the [SpecialOptions] of the dialog @@ -24,9 +30,9 @@ import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle @Composable fun Dialog( state: DialogState, - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(), + style: ComposeDialogStyle2 = DialogDefaults.defaultDialogStyle(), buttons: DialogButtons = DialogDefaults.buttons(), options: Options = Options(), specialOptions: SpecialOptions = DialogDefaults.specialOptions(), @@ -71,6 +77,45 @@ object DialogDefaults { */ @Composable fun buttonsDisabled() = DialogButtons.DISABLED + + /** + * the setup of a dialog that shows as a normal dialog popup + * + * @param swipeDismissable if true, the dialog can be swiped away by an up/down swipe + * @param dismissOnBackPress if true, the dialog can be dismissed by a back press + * @param dismissOnClickOutside if true, the dialog can be dismissed by clicking outside of its borders + * @param usePlatformDefaultWidth if true, platform default width is used + * @param shape the [Shape] of the dialog + * @param containerColor the [Color] of the container + * @param iconContentColor the content [Color] of the icon + * @param titleContentColor the content [Color] of the title + * @param textContentColor the content [Color] of the text + * @param tonalElevation the elevation for the tonal [Color] + */ + @Composable + fun styleDialog( + swipeDismissable: Boolean = false, + // DialogProperties + dialogProperties: DialogProperties = DialogProperties(), + // AlertDialog Settings + shape: Shape = AlertDialogDefaults.shape, + containerColor: Color = AlertDialogDefaults.containerColor, + iconContentColor: Color = AlertDialogDefaults.iconContentColor, + titleContentColor: Color = AlertDialogDefaults.titleContentColor, + textContentColor: Color = AlertDialogDefaults.textContentColor, + tonalElevation: Dp = AlertDialogDefaults.TonalElevation + ): ComposeDialogStyle2 = DialogStyle( + swipeDismissable, + // DialogProperties + dialogProperties, + // AlertDialog Settings + shape, + containerColor, + iconContentColor, + titleContentColor, + textContentColor, + tonalElevation + ) } // ------------------ @@ -282,3 +327,11 @@ data class Options( val wrapContentInScrollableContainer: Boolean = false ) +/** + * the special options for a dialog + * + * @param dialogIntrinsicWidthMin if true, the dialog width will use [IntrinsicSize.Min] + */ +data class SpecialOptions( + val dialogIntrinsicWidthMin: Boolean = false +) \ No newline at end of file diff --git a/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/Platform.kt b/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/Platform.kt index a1093a1..81dfb71 100644 --- a/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/Platform.kt +++ b/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/Platform.kt @@ -6,7 +6,7 @@ import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 @Composable expect fun stringOk() : String @@ -15,7 +15,7 @@ expect fun stringOk() : String expect fun isLandscape(): Boolean @Composable -expect fun DialogDefaults.defaultDialogStyle(): ComposeDialogStyle +expect fun DialogDefaults.defaultDialogStyle(): ComposeDialogStyle2 @Composable expect fun BackHandler(enabled: Boolean, onBack: () -> Unit) @@ -26,6 +26,4 @@ expect fun DialogContentScrollableColumn(modifier: Modifier = Modifier, content: @Composable expect fun DialogContentScrollableLazyColumn(modifier: Modifier = Modifier, state: LazyListState = rememberLazyListState(), content: LazyListScope.() -> Unit) -expect fun DialogDefaults.specialOptions() : SpecialOptions - -expect class SpecialOptions \ No newline at end of file +expect fun DialogDefaults.specialOptions() : SpecialOptions \ No newline at end of file diff --git a/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/copied/AlertDialog.kt b/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/copied/AlertDialog.kt similarity index 100% rename from library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/copied/AlertDialog.kt rename to library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/copied/AlertDialog.kt diff --git a/library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/copied/AlertDialogConstants.kt b/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/copied/AlertDialogConstants.kt similarity index 100% rename from library/core/src/androidMain/kotlin/com/michaelflisar/composedialogs/core/copied/AlertDialogConstants.kt rename to library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/copied/AlertDialogConstants.kt diff --git a/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/internal/ComposeAlertDialog.kt b/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/internal/ComposeAlertDialog.kt new file mode 100644 index 0000000..cd0e612 --- /dev/null +++ b/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/internal/ComposeAlertDialog.kt @@ -0,0 +1,292 @@ +package com.michaelflisar.composedialogs.core.internal + +import androidx.compose.animation.core.tween +import androidx.compose.animation.rememberSplineBasedDecay +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.gestures.AnchoredDraggableState +import androidx.compose.foundation.gestures.DraggableAnchors +import androidx.compose.foundation.gestures.Orientation +import androidx.compose.foundation.gestures.anchoredDraggable +import androidx.compose.foundation.gestures.animateTo +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope +import androidx.compose.foundation.layout.IntrinsicSize +import androidx.compose.foundation.layout.offset +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.sizeIn +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.wrapContentHeight +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.DialogProperties +import com.michaelflisar.composedialogs.core.DialogButtonType +import com.michaelflisar.composedialogs.core.DialogButtons +import com.michaelflisar.composedialogs.core.DialogEvent +import com.michaelflisar.composedialogs.core.DialogState +import com.michaelflisar.composedialogs.core.Options +import com.michaelflisar.composedialogs.core.SpecialOptions +import com.michaelflisar.composedialogs.core.copied.AlertDialog +import com.michaelflisar.composedialogs.core.copied.DialogMaxWidth +import com.michaelflisar.composedialogs.core.copied.DialogMinWidth +import com.michaelflisar.composedialogs.core.views.ComposeDialogButton +import kotlinx.coroutines.launch +import kotlin.math.abs +import kotlin.math.roundToInt + +// Wrapper around Dialog because of resizing issues after initial compose: +// Github: https://stackoverflow.com/questions/71285843/how-to-make-dialog-re-measure-when-a-child-size-changes-dynamically/71287474 +// Issue: https://issuetracker.google.com/issues/221643630 + +internal val DialogHorizontalMinMargin = 16.dp +internal val DialogVerticalMinMargin = DialogHorizontalMinMargin + +internal object ComposeAlertDialog { + + class Data( + // Settings + val swipeDismissable: Boolean, + // DialogProperties + val dialogProperties: DialogProperties, + // Style + val shape: Shape, + val containerColor: Color, + val iconContentColor: Color, + val titleContentColor: Color, + val textContentColor: Color, + val tonalElevation: Dp + ) + + enum class DragValue { Start, Center, End } + +} + +@Composable +internal fun ComposeAlertDialog( + data: ComposeAlertDialog.Data, + title: (@Composable () -> Unit)?, + icon: @Composable (() -> Unit)?, + buttons: DialogButtons, + options: Options, + specialOptions: SpecialOptions, + state: DialogState, + onEvent: (event: DialogEvent) -> Unit, + content: @Composable (ColumnScope.() -> Unit) +) { + val modifierSwipeDismiss = getSwipeDismissModifier(state, onEvent, data.swipeDismissable) + ComposeAlertDialog( + data = data, + onDismissRequest = { + state.dismiss(onEvent) + }, + confirmButton = { + ComposeDialogButton( + buttons.positive, + DialogButtonType.Positive, + options, + state, + requestDismiss = { + state.dismiss() + }, + onEvent + ) + }, + modifier = Modifier + .wrapContentHeight() + .then(modifierSwipeDismiss), + dismissButton = if (buttons.negative.text.isNotEmpty()) { + { + ComposeDialogButton( + buttons.negative, + DialogButtonType.Negative, + options, + state, + requestDismiss = { + state.dismiss() + }, + onEvent + ) + } + } else null, + icon = icon, + title = title, + text = { + val scrollModifier = if (options.wrapContentInScrollableContainer) { + Modifier + .wrapContentHeight() + .verticalScroll(rememberScrollState()) + } else Modifier + Column( + modifier = Modifier + .then(scrollModifier) + .sizeIn(minWidth = DialogMinWidth, maxWidth = DialogMaxWidth) + .then( + if (specialOptions.dialogIntrinsicWidthMin) { + Modifier.width(IntrinsicSize.Min) + } else Modifier + ), + //horizontalAlignment = Alignment.CenterHorizontally + ) { + content() + } + } + ) +} + +@OptIn(ExperimentalFoundationApi::class) +@Composable +private fun getSwipeDismissModifier( + state: DialogState, + onEvent: (event: DialogEvent) -> Unit, + swipeDismissable: Boolean +): Modifier { + return if (swipeDismissable) { + val density = LocalDensity.current + + val maxSwipeDistance = with(density) { 96.dp.toPx() } + val dragState = createDraggableState(maxSwipeDistance) + + val coroutineScope = rememberCoroutineScope() + + LaunchedEffect(dragState.targetValue) { + when (dragState.targetValue) { + ComposeAlertDialog.DragValue.Center -> { + // ... + } + + ComposeAlertDialog.DragValue.Start, + ComposeAlertDialog.DragValue.End -> { + if (!state.dismiss(onEvent)) { + // expand again if dismissing is not allowed + coroutineScope.launch { + dragState.animateTo(ComposeAlertDialog.DragValue.Center) + } + } + } + } + } + + val alpha = 1f - (0.3f * abs(dragState.requireOffset() / maxSwipeDistance)) + + Modifier + .offset { + IntOffset( + 0, + dragState + .requireOffset() + .roundToInt() / 4 + ) + } + .anchoredDraggable( + state = dragState, + //anchors = anchors, + //thresholds = { _, _ -> FractionalThreshold(0.3f) }, + orientation = Orientation.Vertical + ) + .alpha(alpha) + } else Modifier +} + + +@OptIn(ExperimentalFoundationApi::class) +@Composable +private fun createDraggableState( + maxSwipeDistance: Float +): AnchoredDraggableState { + val anchors = DraggableAnchors { + ComposeAlertDialog.DragValue.Start at -maxSwipeDistance + ComposeAlertDialog.DragValue.Center at 0f + ComposeAlertDialog.DragValue.End at maxSwipeDistance + } + + val decayAnimSpec = rememberSplineBasedDecay() + val dragState = remember { + AnchoredDraggableState( + initialValue = ComposeAlertDialog.DragValue.Center, + anchors = anchors, + positionalThreshold = { distance: Float -> distance * 0.5f }, + velocityThreshold = { maxSwipeDistance }, + snapAnimationSpec = tween(), + decayAnimationSpec = decayAnimSpec, + confirmValueChange = { true } + ) + } + return dragState +} + +@Composable +private fun ComposeAlertDialog( + data: ComposeAlertDialog.Data, + onDismissRequest: () -> Unit, + confirmButton: @Composable () -> Unit, + modifier: Modifier = Modifier, + dismissButton: @Composable (() -> Unit)? = null, + icon: @Composable (() -> Unit)? = null, + title: @Composable (() -> Unit)? = null, + text: @Composable (() -> Unit)? = null +) { + val properties = data.dialogProperties + val (fixedProperties, fixedModifier, fixedModifierInner) = if (properties.usePlatformDefaultWidth) { + Triple( + DialogProperties( + properties.dismissOnBackPress, + properties.dismissOnClickOutside, + false + ), + // outer modifier gets paddings only so that dismiss on click outside works as desired + Modifier + .sizeIn(minWidth = DialogMinWidth, maxWidth = DialogMaxWidth) + //.background(Color.Red) + .padding( + horizontal = DialogHorizontalMinMargin, + vertical = DialogVerticalMinMargin + ) + //.background(Color.Green) + , + Modifier + .sizeIn(minWidth = DialogMinWidth, maxWidth = DialogMaxWidth) + //.background(Color.Blue) + //.padding(horizontal = DialogHorizontalMinMargin, vertical = DialogVerticalMinMargin) + //.background(Color.Yellow) + ) + } else { + Triple( + properties, + Modifier, + Modifier + ) + } + + AlertDialog( + onDismissRequest = onDismissRequest, + confirmButton = confirmButton, + modifier = modifier + .wrapContentHeight() + .then(fixedModifier), + modifierInner = modifier + .wrapContentHeight() + .then(fixedModifierInner), + dismissButton = dismissButton, + icon = icon, + title = title, + text = text, + shape = data.shape, + containerColor = data.containerColor, + iconContentColor = data.iconContentColor, + titleContentColor = data.titleContentColor, + textContentColor = data.textContentColor, + tonalElevation = data.tonalElevation, + properties = fixedProperties + ) +} \ No newline at end of file diff --git a/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/style/ComposeDialogStyle.kt b/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/style/ComposeDialogStyle2.kt similarity index 91% rename from library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/style/ComposeDialogStyle.kt rename to library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/style/ComposeDialogStyle2.kt index 2d106d7..ae9618b 100644 --- a/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/style/ComposeDialogStyle.kt +++ b/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/style/ComposeDialogStyle2.kt @@ -8,13 +8,13 @@ import com.michaelflisar.composedialogs.core.DialogState import com.michaelflisar.composedialogs.core.Options import com.michaelflisar.composedialogs.core.SpecialOptions -interface ComposeDialogStyle { +interface ComposeDialogStyle2 { val type: Type @Composable fun Show( - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, buttons: DialogButtons, options: Options, diff --git a/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/style/DialogStyle.kt b/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/style/DialogStyle.kt new file mode 100644 index 0000000..0cf8f1b --- /dev/null +++ b/library/core/src/commonMain/kotlin/com/michaelflisar/composedialogs/core/style/DialogStyle.kt @@ -0,0 +1,55 @@ +package com.michaelflisar.composedialogs.core.style + +import androidx.compose.foundation.layout.ColumnScope +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.window.DialogProperties +import com.michaelflisar.composedialogs.core.DialogButtons +import com.michaelflisar.composedialogs.core.DialogEvent +import com.michaelflisar.composedialogs.core.DialogState +import com.michaelflisar.composedialogs.core.Options +import com.michaelflisar.composedialogs.core.SpecialOptions +import com.michaelflisar.composedialogs.core.internal.ComposeAlertDialog + +internal class DialogStyle( + swipeDismissable: Boolean, + // DialogProperties + dialogProperties: DialogProperties, + // AlertDialog Settings + shape: Shape, + containerColor: Color, + iconContentColor: Color, + titleContentColor: Color, + textContentColor: Color, + tonalElevation: Dp +) : ComposeDialogStyle2 { + + override val type = ComposeDialogStyle2.Type.Dialog + + private val data = ComposeAlertDialog.Data( + swipeDismissable = swipeDismissable, + dialogProperties = dialogProperties, + shape = shape, + containerColor = containerColor, + iconContentColor = iconContentColor, + titleContentColor = titleContentColor, + textContentColor = textContentColor, + tonalElevation = tonalElevation + ) + + @Composable + override fun Show( + title: (@Composable () -> Unit)?, + icon: @Composable (() -> Unit)?, + buttons: DialogButtons, + options: Options, + specialOptions: SpecialOptions, + state: DialogState, + onEvent: (event: DialogEvent) -> Unit, + content: @Composable (ColumnScope.() -> Unit) + ) { + ComposeAlertDialog(data, title, icon, buttons, options, specialOptions, state, onEvent, content) + } +} \ No newline at end of file diff --git a/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/DialogDefaultsExtensions.kt b/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/DialogDefaultsExtensions.kt index 7579eab..1a0b1b1 100644 --- a/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/DialogDefaultsExtensions.kt +++ b/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/DialogDefaultsExtensions.kt @@ -1,13 +1,19 @@ package com.michaelflisar.composedialogs.core import androidx.compose.runtime.Composable -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle -import com.michaelflisar.composedialogs.core.style.DialogStyle +import androidx.compose.ui.Alignment +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.WindowPosition +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 +import com.michaelflisar.composedialogs.core.style.DialogStyleDesktop -/** - * the setup of a dialog that shows as a normal dialog popup - */ @Composable -fun DialogDefaults.styleDialog(): ComposeDialogStyle { - return DialogStyle() +fun DialogDefaults.styleWindowsDialog( + dialogTitle: String, + position: WindowPosition = WindowPosition(Alignment.Center), + width: Dp = 800.dp, + height: Dp = 600.dp +): ComposeDialogStyle2 { + return DialogStyleDesktop(DialogStyleDesktopOtions(dialogTitle, position, width, height)) } \ No newline at end of file diff --git a/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/DialogStyleDesktopOtions.kt b/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/DialogStyleDesktopOtions.kt new file mode 100644 index 0000000..862e8a1 --- /dev/null +++ b/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/DialogStyleDesktopOtions.kt @@ -0,0 +1,11 @@ +package com.michaelflisar.composedialogs.core + +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.window.WindowPosition + +data class DialogStyleDesktopOtions( + val dialogTitle: String, + val position: WindowPosition, + val width: Dp, + val height: Dp +) \ No newline at end of file diff --git a/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/Platform.jvm.kt b/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/Platform.jvm.kt index ec51eff..972ec8c 100644 --- a/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/Platform.jvm.kt +++ b/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/Platform.jvm.kt @@ -20,6 +20,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.DialogProperties import androidx.compose.ui.window.WindowPosition @Composable @@ -86,17 +87,4 @@ actual fun DialogContentScrollableLazyColumn( actual fun DialogDefaults.specialOptions() : SpecialOptions { return SpecialOptions() -} - -/** - * the special options for a dialog - * - * @param position the initial window position - * @param width the initial window width - * @param height the initial window height - */ -actual data class SpecialOptions( - val position: WindowPosition = WindowPosition(Alignment.Center), - val width: Dp = 800.dp, - val height: Dp = 600.dp -) \ No newline at end of file +} \ No newline at end of file diff --git a/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/style/DialogStyle.kt b/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/style/DialogStyleDesktop.kt similarity index 90% rename from library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/style/DialogStyle.kt rename to library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/style/DialogStyleDesktop.kt index a54d329..00d4559 100644 --- a/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/style/DialogStyle.kt +++ b/library/core/src/jvmMain/kotlin/com/michaelflisar/composedialogs/core/style/DialogStyleDesktop.kt @@ -16,18 +16,21 @@ import com.michaelflisar.composedialogs.core.DialogButtons import com.michaelflisar.composedialogs.core.DialogContentScrollableColumn import com.michaelflisar.composedialogs.core.DialogEvent import com.michaelflisar.composedialogs.core.DialogState +import com.michaelflisar.composedialogs.core.DialogStyleDesktopOtions import com.michaelflisar.composedialogs.core.Options import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.copied.AlertDialogContent import com.michaelflisar.composedialogs.core.views.ComposeDialogButton -internal class DialogStyle : ComposeDialogStyle { +class DialogStyleDesktop( + val desktopOptions: DialogStyleDesktopOtions +) : ComposeDialogStyle2 { - override val type = ComposeDialogStyle.Type.Dialog + override val type = ComposeDialogStyle2.Type.Dialog @Composable override fun Show( - title: String?, + title: (@Composable () -> Unit)?, icon: (@Composable () -> Unit)?, buttons: DialogButtons, options: Options, @@ -37,16 +40,16 @@ internal class DialogStyle : ComposeDialogStyle { content: @Composable (ColumnScope.() -> Unit) ) { val dialogState = androidx.compose.ui.window.rememberDialogState( - position = specialOptions.position, - width = specialOptions.width, - height = specialOptions.height + position = desktopOptions.position, + width = desktopOptions.width, + height = desktopOptions.height ) DialogWindow( visible = state.showing, onCloseRequest = { state.dismiss(onEvent) }, - title = title ?: "", + title = desktopOptions.dialogTitle, state = dialogState, content = { AlertDialogContent( diff --git a/library/core/src/nativeMain/kotlin/com/michaelflisar/composedialogs/core/Platform.native.kt b/library/core/src/nativeMain/kotlin/com/michaelflisar/composedialogs/core/Platform.native.kt index 9ae6966..9648456 100644 --- a/library/core/src/nativeMain/kotlin/com/michaelflisar/composedialogs/core/Platform.native.kt +++ b/library/core/src/nativeMain/kotlin/com/michaelflisar/composedialogs/core/Platform.native.kt @@ -11,7 +11,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 @Composable actual fun isLandscape() = false @@ -20,7 +20,7 @@ actual fun isLandscape() = false actual fun stringOk() = "OK" @Composable -actual fun DialogDefaults.defaultDialogStyle(): ComposeDialogStyle = TODO() +actual fun DialogDefaults.defaultDialogStyle(): ComposeDialogStyle2 = TODO() @Composable actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) { @@ -58,6 +58,4 @@ actual fun DialogContentScrollableLazyColumn( actual fun DialogDefaults.specialOptions() : SpecialOptions { return SpecialOptions() -} - -actual class SpecialOptions \ No newline at end of file +} \ No newline at end of file diff --git a/library/modules/billing/src/main/java/com/michaelflisar/composedialogs/dialogs/billing/DialogBilling.kt b/library/modules/billing/src/main/java/com/michaelflisar/composedialogs/dialogs/billing/DialogBilling.kt index 033ce9c..cff40d4 100644 --- a/library/modules/billing/src/main/java/com/michaelflisar/composedialogs/dialogs/billing/DialogBilling.kt +++ b/library/modules/billing/src/main/java/com/michaelflisar/composedialogs/dialogs/billing/DialogBilling.kt @@ -42,7 +42,7 @@ import com.michaelflisar.composedialogs.core.DialogState import com.michaelflisar.composedialogs.core.DialogUtil import com.michaelflisar.composedialogs.core.Options import com.michaelflisar.composedialogs.core.defaultDialogStyle -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.kotbilling.KotBilling import com.michaelflisar.kotbilling.classes.Product import com.michaelflisar.kotbilling.classes.ProductType @@ -75,9 +75,9 @@ fun DialogBilling( products: List, texts: DialogBilling.Texts = DialogBillingDefaults.texts(), // Base Dialog - Optional - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(), + style: ComposeDialogStyle2 = DialogDefaults.defaultDialogStyle(), //buttons: DialogButtons = DialogDefaults.buttons(), //options: Options = Options(), onEvent: (event: DialogEvent) -> Unit = {} diff --git a/library/modules/color/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/Platform.android.kt b/library/modules/color/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/Platform.android.kt deleted file mode 100644 index d5c98d3..0000000 --- a/library/modules/color/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/Platform.android.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.michaelflisar.composedialogs.dialogs.color - -import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions -import com.michaelflisar.composedialogs.core.specialOptions - -actual fun DialogDefaults.defaultColorDialogSpecialOptions(): SpecialOptions { - return DialogDefaults.specialOptions() -} \ No newline at end of file diff --git a/library/modules/color/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/DialogColor.kt b/library/modules/color/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/DialogColor.kt index f599154..ce4eb80 100644 --- a/library/modules/color/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/DialogColor.kt +++ b/library/modules/color/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/DialogColor.kt @@ -33,7 +33,8 @@ import com.michaelflisar.composedialogs.core.Options import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.defaultDialogStyle import com.michaelflisar.composedialogs.core.isLandscape -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.specialOptions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.dialogs.color.DialogColorDefaults.texts import com.michaelflisar.composedialogs.dialogs.color.classes.ColorStateSaver import com.michaelflisar.composedialogs.dialogs.color.classes.ColorStateSaverNullable @@ -71,12 +72,12 @@ fun DialogColor( gridSize: Int = if (isLandscape()) 6 else 4, labelStyle: DialogColor.LabelStyle = DialogColor.LabelStyle.Value, // Base Dialog - Optional - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(), + style: ComposeDialogStyle2 = DialogDefaults.defaultDialogStyle(), buttons: DialogButtons = DialogDefaults.buttons(), options: Options = Options(), - specialOptions: SpecialOptions = DialogDefaults.defaultColorDialogSpecialOptions(), + specialOptions: SpecialOptions = DialogDefaults.specialOptions(), onEvent: (event: DialogEvent) -> Unit = {} ) { // saved dialog state diff --git a/library/modules/color/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/Platform.kt b/library/modules/color/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/Platform.kt deleted file mode 100644 index f815a64..0000000 --- a/library/modules/color/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/Platform.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.michaelflisar.composedialogs.dialogs.color - -import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions - -expect fun DialogDefaults.defaultColorDialogSpecialOptions(): SpecialOptions \ No newline at end of file diff --git a/library/modules/color/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/Platform.jvm.kt b/library/modules/color/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/Platform.jvm.kt deleted file mode 100644 index 76ec2cf..0000000 --- a/library/modules/color/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/Platform.jvm.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.michaelflisar.composedialogs.dialogs.color - -import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions - -actual fun DialogDefaults.defaultColorDialogSpecialOptions(): SpecialOptions { - return DialogDefaults.specialOptionsColorDialog() -} \ No newline at end of file diff --git a/library/modules/color/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/SpecialOptionsExtension.kt b/library/modules/color/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/SpecialOptionsExtension.kt index 9932da3..4f4011a 100644 --- a/library/modules/color/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/SpecialOptionsExtension.kt +++ b/library/modules/color/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/SpecialOptionsExtension.kt @@ -1,14 +1,21 @@ package com.michaelflisar.composedialogs.dialogs.color +import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.window.WindowPosition import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions +import com.michaelflisar.composedialogs.core.DialogStyleDesktopOtions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 +import com.michaelflisar.composedialogs.core.style.DialogStyleDesktop -fun DialogDefaults.specialOptionsColorDialog( +@Composable +fun DialogDefaults.styleWindowsColorDialog( + dialogTitle: String, position: WindowPosition = WindowPosition(Alignment.Center), width: Dp = 600.dp, height: Dp = 550.dp -) = SpecialOptions(position, width, height) \ No newline at end of file +): ComposeDialogStyle2 { + return DialogStyleDesktop(DialogStyleDesktopOtions(dialogTitle, position, width, height)) +} \ No newline at end of file diff --git a/library/modules/color/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/Platform.native.kt b/library/modules/color/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/Platform.native.kt deleted file mode 100644 index d5c98d3..0000000 --- a/library/modules/color/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/color/Platform.native.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.michaelflisar.composedialogs.dialogs.color - -import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions -import com.michaelflisar.composedialogs.core.specialOptions - -actual fun DialogDefaults.defaultColorDialogSpecialOptions(): SpecialOptions { - return DialogDefaults.specialOptions() -} \ No newline at end of file diff --git a/library/modules/date/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.android.kt b/library/modules/date/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.android.kt index 7c5cb23..3b7bd6f 100644 --- a/library/modules/date/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.android.kt +++ b/library/modules/date/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.android.kt @@ -12,10 +12,6 @@ import java.time.format.FormatStyle import java.time.format.TextStyle import java.util.Locale -actual fun DialogDefaults.defaultDateDialogSpecialOptions(): SpecialOptions { - return specialOptions() -} - actual fun defaultFormatterWeekDayLabel(dayOfWeek: DayOfWeek): String { return dayOfWeek.getDisplayName( TextStyle.SHORT, diff --git a/library/modules/date/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/DialogDate.kt b/library/modules/date/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/DialogDate.kt index 24925d8..4b16352 100644 --- a/library/modules/date/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/DialogDate.kt +++ b/library/modules/date/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/DialogDate.kt @@ -39,7 +39,8 @@ import com.michaelflisar.composedialogs.core.Options import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.defaultDialogStyle import com.michaelflisar.composedialogs.core.isLandscape -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.specialOptions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.dialogs.date.classes.CalendarPageData import com.michaelflisar.composedialogs.dialogs.date.classes.DateViewState import com.michaelflisar.composedialogs.dialogs.date.composables.CalendarHeader @@ -76,12 +77,12 @@ fun DialogDate( dateRange: DialogDate.Range = DialogDateDefaults.dateRange(), setup: DialogDate.Setup = DialogDateDefaults.setup(), // Base Dialog - Optional - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(), + style: ComposeDialogStyle2 = DialogDefaults.defaultDialogStyle(), buttons: DialogButtons = DialogDefaults.buttons(), options: Options = Options(), - specialOptions: SpecialOptions = DialogDefaults.defaultDateDialogSpecialOptions(), + specialOptions: SpecialOptions = DialogDefaults.specialOptions(), onEvent: (event: DialogEvent) -> Unit = {} ) { val landscape = isLandscape() @@ -155,7 +156,7 @@ fun DialogDate( Box( modifier = Modifier.align(Alignment.CenterHorizontally) ) { - Text(title) + title() } } Spacer(modifier = Modifier.height(8.dp)) @@ -170,7 +171,14 @@ fun DialogDate( ) if (todayPage != null && setup.buttonToday != null) { Spacer(modifier = Modifier.height(8.dp)) - CalendarTodayButton(setup.buttonToday, date, todayPage!!, today, pagerState, viewState) + CalendarTodayButton( + setup.buttonToday, + date, + todayPage!!, + today, + pagerState, + viewState + ) } } Spacer(modifier = Modifier.width(8.dp)) diff --git a/library/modules/date/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.kt b/library/modules/date/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.kt index f84e356..2cd708d 100644 --- a/library/modules/date/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.kt +++ b/library/modules/date/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.kt @@ -6,8 +6,6 @@ import kotlinx.datetime.DayOfWeek import kotlinx.datetime.LocalDate import kotlinx.datetime.Month -expect fun DialogDefaults.defaultDateDialogSpecialOptions(): SpecialOptions - expect fun defaultFormatterWeekDayLabel(dayOfWeek: DayOfWeek): String expect fun defaultFormatterSelectedDate(date: LocalDate): String expect fun defaultFormatterSelectedMonth(month: Month): String diff --git a/library/modules/date/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/composables/CalendarHeader.kt b/library/modules/date/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/composables/CalendarHeader.kt index c308ec3..8e1738b 100644 --- a/library/modules/date/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/composables/CalendarHeader.kt +++ b/library/modules/date/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/composables/CalendarHeader.kt @@ -10,9 +10,9 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.pager.PagerState import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material.icons.filled.ArrowDropDown -import androidx.compose.material.icons.filled.KeyboardArrowLeft -import androidx.compose.material.icons.filled.KeyboardArrowRight import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -96,7 +96,7 @@ internal fun HeaderItem( onClick = { onDownClick?.invoke() }, enabled = onDownClick != null ) { - Icon(Icons.Default.KeyboardArrowLeft, null) + Icon(Icons.AutoMirrored.Filled.KeyboardArrowLeft, null) } } } @@ -134,7 +134,7 @@ internal fun HeaderItem( onClick = { onUpClick?.invoke() }, enabled = onUpClick != null ) { - Icon(Icons.Default.KeyboardArrowRight, null) + Icon(Icons.AutoMirrored.Filled.KeyboardArrowRight, null) } } } diff --git a/library/modules/date/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.jvm.kt b/library/modules/date/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.jvm.kt index eea22d8..3b7bd6f 100644 --- a/library/modules/date/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.jvm.kt +++ b/library/modules/date/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.jvm.kt @@ -12,10 +12,6 @@ import java.time.format.FormatStyle import java.time.format.TextStyle import java.util.Locale -actual fun DialogDefaults.defaultDateDialogSpecialOptions(): SpecialOptions { - return specialOptionsDateDialog() -} - actual fun defaultFormatterWeekDayLabel(dayOfWeek: DayOfWeek): String { return dayOfWeek.getDisplayName( TextStyle.SHORT, diff --git a/library/modules/date/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/SpecialOptionsExtension.kt b/library/modules/date/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/SpecialOptionsExtension.kt index 2c0e129..a0b8835 100644 --- a/library/modules/date/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/SpecialOptionsExtension.kt +++ b/library/modules/date/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/SpecialOptionsExtension.kt @@ -1,14 +1,21 @@ package com.michaelflisar.composedialogs.dialogs.date +import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.window.WindowPosition import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions +import com.michaelflisar.composedialogs.core.DialogStyleDesktopOtions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 +import com.michaelflisar.composedialogs.core.style.DialogStyleDesktop -fun DialogDefaults.specialOptionsDateDialog( +@Composable +fun DialogDefaults.styleWindowsDateDialog( + dialogTitle: String, position: WindowPosition = WindowPosition(Alignment.Center), width: Dp = 600.dp, height: Dp = 600.dp -) = SpecialOptions(position, width, height) \ No newline at end of file +): ComposeDialogStyle2 { + return DialogStyleDesktop(DialogStyleDesktopOtions(dialogTitle, position, width, height)) +} \ No newline at end of file diff --git a/library/modules/date/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.native.kt b/library/modules/date/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.native.kt index 608efbb..476ecbf 100644 --- a/library/modules/date/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.native.kt +++ b/library/modules/date/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/date/Platform.native.kt @@ -8,10 +8,6 @@ import kotlinx.datetime.LocalDate import kotlinx.datetime.Month import kotlinx.datetime.format -actual fun DialogDefaults.defaultDateDialogSpecialOptions(): SpecialOptions { - return specialOptions() -} - actual fun defaultFormatterWeekDayLabel(dayOfWeek: DayOfWeek): String { return dayOfWeek.name } diff --git a/library/modules/info/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/Platform.android.kt b/library/modules/info/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/Platform.android.kt deleted file mode 100644 index 7081151..0000000 --- a/library/modules/info/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/Platform.android.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.michaelflisar.composedialogs.dialogs.info - -import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions -import com.michaelflisar.composedialogs.core.specialOptions - -actual fun DialogDefaults.defaultInfoDialogSpecialOptions(): SpecialOptions { - return specialOptions() -} \ No newline at end of file diff --git a/library/modules/info/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/DialogInfo.kt b/library/modules/info/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/DialogInfo.kt index c954dc2..7f9b87f 100644 --- a/library/modules/info/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/DialogInfo.kt +++ b/library/modules/info/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/DialogInfo.kt @@ -4,7 +4,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import com.michaelflisar.composedialogs.core.* -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 /** * Shows a dialog with an info text and an optional label for that info @@ -24,12 +24,12 @@ fun DialogInfo( // Custom - Optional infoLabel: String = "", // Base Dialog - Optional - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(), + style: ComposeDialogStyle2 = DialogDefaults.defaultDialogStyle(), buttons: DialogButtons = DialogDefaults.buttons(), options: Options = Options(), - specialOptions: SpecialOptions = DialogDefaults.defaultInfoDialogSpecialOptions(), + specialOptions: SpecialOptions = DialogDefaults.specialOptions(), onEvent: (event: DialogEvent) -> Unit = {} ) { Dialog(state, title, icon, style, buttons, options, specialOptions, onEvent = onEvent) { diff --git a/library/modules/info/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/Platform.kt b/library/modules/info/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/Platform.kt deleted file mode 100644 index f690aba..0000000 --- a/library/modules/info/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/Platform.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.michaelflisar.composedialogs.dialogs.info - -import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions - -expect fun DialogDefaults.defaultInfoDialogSpecialOptions(): SpecialOptions \ No newline at end of file diff --git a/library/modules/info/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/Platform.jvm.kt b/library/modules/info/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/Platform.jvm.kt deleted file mode 100644 index cd4659b..0000000 --- a/library/modules/info/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/Platform.jvm.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.michaelflisar.composedialogs.dialogs.info - -import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions -import com.michaelflisar.composedialogs.core.specialOptions - -actual fun DialogDefaults.defaultInfoDialogSpecialOptions(): SpecialOptions { - return specialOptionsInfoDialog() -} \ No newline at end of file diff --git a/library/modules/info/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/SpecialOptionsExtension.kt b/library/modules/info/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/SpecialOptionsExtension.kt index d994466..9a73d01 100644 --- a/library/modules/info/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/SpecialOptionsExtension.kt +++ b/library/modules/info/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/SpecialOptionsExtension.kt @@ -1,14 +1,21 @@ package com.michaelflisar.composedialogs.dialogs.info +import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.window.WindowPosition import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions +import com.michaelflisar.composedialogs.core.DialogStyleDesktopOtions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 +import com.michaelflisar.composedialogs.core.style.DialogStyleDesktop -fun DialogDefaults.specialOptionsInfoDialog( +@Composable +fun DialogDefaults.styleWindowsInfoDialog( + dialogTitle: String, position: WindowPosition = WindowPosition(Alignment.Center), width: Dp = 600.dp, height: Dp = 200.dp -) = SpecialOptions(position, width, height) \ No newline at end of file +): ComposeDialogStyle2 { + return DialogStyleDesktop(DialogStyleDesktopOtions(dialogTitle, position, width, height)) +} \ No newline at end of file diff --git a/library/modules/info/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/Platform.native.kt b/library/modules/info/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/Platform.native.kt deleted file mode 100644 index 7081151..0000000 --- a/library/modules/info/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/info/Platform.native.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.michaelflisar.composedialogs.dialogs.info - -import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions -import com.michaelflisar.composedialogs.core.specialOptions - -actual fun DialogDefaults.defaultInfoDialogSpecialOptions(): SpecialOptions { - return specialOptions() -} \ No newline at end of file diff --git a/library/modules/input/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.android.kt b/library/modules/input/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.android.kt index c3b7ae2..9fc070a 100644 --- a/library/modules/input/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.android.kt +++ b/library/modules/input/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.android.kt @@ -5,8 +5,4 @@ import com.michaelflisar.composedialogs.core.DialogDefaults import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.specialOptions -actual fun DialogDefaults.defaultInputDialogSpecialOptions(): SpecialOptions { - return specialOptions() -} - internal actual val DialogStyleModifier: Modifier = Modifier \ No newline at end of file diff --git a/library/modules/input/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/DialogInput.kt b/library/modules/input/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/DialogInput.kt index 64574f2..2369ff1 100644 --- a/library/modules/input/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/DialogInput.kt +++ b/library/modules/input/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/DialogInput.kt @@ -19,7 +19,8 @@ import com.michaelflisar.composedialogs.core.DialogState import com.michaelflisar.composedialogs.core.Options import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.defaultDialogStyle -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.specialOptions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.dialogs.input.composables.DialogInputTextField /** @@ -69,18 +70,18 @@ fun DialogInput( selectionState: DialogInput.SelectionState = DialogInput.SelectionState.Default, onTextStateChanged: (valid: Boolean, text: String) -> Unit = { _, _ -> }, // Base Dialog - Optional - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(), + style: ComposeDialogStyle2 = DialogDefaults.defaultDialogStyle(), buttons: DialogButtons = DialogDefaults.buttons(), - specialOptions: SpecialOptions = DialogDefaults.defaultInputDialogSpecialOptions(), + specialOptions: SpecialOptions = DialogDefaults.specialOptions(), options: Options = Options(), onEvent: (event: DialogEvent) -> Unit = {} ) { Dialog(state, title, icon, style, buttons, options, specialOptions, onEvent = onEvent) { val modifier = when (style.type) { - ComposeDialogStyle.Type.BottomSheet -> Modifier.fillMaxWidth() - ComposeDialogStyle.Type.Dialog -> DialogStyleModifier + ComposeDialogStyle2.Type.BottomSheet -> Modifier.fillMaxWidth() + ComposeDialogStyle2.Type.Dialog -> DialogStyleModifier } DialogInputTextField( modifier, diff --git a/library/modules/input/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/DialogInputNumber.kt b/library/modules/input/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/DialogInputNumber.kt index f704da2..e0be462 100644 --- a/library/modules/input/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/DialogInputNumber.kt +++ b/library/modules/input/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/DialogInputNumber.kt @@ -20,7 +20,8 @@ import com.michaelflisar.composedialogs.core.DialogState import com.michaelflisar.composedialogs.core.Options import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.defaultDialogStyle -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.specialOptions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.dialogs.input.composables.DialogInputTextField /** @@ -69,18 +70,18 @@ fun DialogInputNumber( selectionState: DialogInput.SelectionState = DialogInput.SelectionState.Default, onValueStateChanged: (valid: Boolean, value: T?) -> Unit = { _, _ -> }, // Base Dialog - Optional - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(), + style: ComposeDialogStyle2 = DialogDefaults.defaultDialogStyle(), buttons: DialogButtons = DialogDefaults.buttons(), options: Options = Options(), - specialOptions: SpecialOptions = DialogDefaults.defaultInputDialogSpecialOptions(), + specialOptions: SpecialOptions = DialogDefaults.specialOptions(), onEvent: (event: DialogEvent) -> Unit = {} ) { Dialog(state, title, icon, style, buttons, options, specialOptions, onEvent = onEvent) { val modifier = when (style.type) { - ComposeDialogStyle.Type.BottomSheet -> Modifier.fillMaxWidth() - ComposeDialogStyle.Type.Dialog -> DialogStyleModifier + ComposeDialogStyle2.Type.BottomSheet -> Modifier.fillMaxWidth() + ComposeDialogStyle2.Type.Dialog -> DialogStyleModifier } val stringInput = rememberSaveable { mutableStateOf(value.value.toString()) } diff --git a/library/modules/input/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.kt b/library/modules/input/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.kt index a6238c9..5703bd3 100644 --- a/library/modules/input/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.kt +++ b/library/modules/input/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.kt @@ -4,6 +4,4 @@ import androidx.compose.ui.Modifier import com.michaelflisar.composedialogs.core.DialogDefaults import com.michaelflisar.composedialogs.core.SpecialOptions -expect fun DialogDefaults.defaultInputDialogSpecialOptions(): SpecialOptions - internal expect val DialogStyleModifier: Modifier \ No newline at end of file diff --git a/library/modules/input/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.jvm.kt b/library/modules/input/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.jvm.kt index 52ae9ab..c515972 100644 --- a/library/modules/input/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.jvm.kt +++ b/library/modules/input/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.jvm.kt @@ -6,8 +6,4 @@ import com.michaelflisar.composedialogs.core.DialogDefaults import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.specialOptions -actual fun DialogDefaults.defaultInputDialogSpecialOptions(): SpecialOptions { - return specialOptionsInputDialog() -} - internal actual val DialogStyleModifier: Modifier = Modifier.fillMaxWidth() \ No newline at end of file diff --git a/library/modules/input/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/SpecialOptionsExtension.kt b/library/modules/input/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/SpecialOptionsExtension.kt index 85c5106..f2b7562 100644 --- a/library/modules/input/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/SpecialOptionsExtension.kt +++ b/library/modules/input/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/SpecialOptionsExtension.kt @@ -1,14 +1,21 @@ package com.michaelflisar.composedialogs.dialogs.input +import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.window.WindowPosition import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions +import com.michaelflisar.composedialogs.core.DialogStyleDesktopOtions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 +import com.michaelflisar.composedialogs.core.style.DialogStyleDesktop -fun DialogDefaults.specialOptionsInputDialog( +@Composable +fun DialogDefaults.styleWindowsInputDialog( + dialogTitle: String, position: WindowPosition = WindowPosition(Alignment.Center), width: Dp = 400.dp, - height: Dp = 200.dp -) = SpecialOptions(position, width, height) \ No newline at end of file + height: Dp = 225.dp +): ComposeDialogStyle2 { + return DialogStyleDesktop(DialogStyleDesktopOtions(dialogTitle, position, width, height)) +} \ No newline at end of file diff --git a/library/modules/input/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.native.kt b/library/modules/input/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.native.kt index c3b7ae2..9fc070a 100644 --- a/library/modules/input/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.native.kt +++ b/library/modules/input/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/input/Platform.native.kt @@ -5,8 +5,4 @@ import com.michaelflisar.composedialogs.core.DialogDefaults import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.specialOptions -actual fun DialogDefaults.defaultInputDialogSpecialOptions(): SpecialOptions { - return specialOptions() -} - internal actual val DialogStyleModifier: Modifier = Modifier \ No newline at end of file diff --git a/library/modules/list/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/list/DialogList.kt b/library/modules/list/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/list/DialogList.kt index 1649c72..e3e417c 100644 --- a/library/modules/list/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/list/DialogList.kt +++ b/library/modules/list/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/list/DialogList.kt @@ -38,7 +38,7 @@ import com.michaelflisar.composedialogs.core.Options import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.defaultDialogStyle import com.michaelflisar.composedialogs.core.specialOptions -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.dialogs.list.composables.DialogListContent import com.michaelflisar.composedialogs.dialogs.list.composables.DialogListItem import com.michaelflisar.composedialogs.dialogs.list.composables.DialogListTrailingContent @@ -73,9 +73,9 @@ fun DialogList( description: String = "", filter: DialogList.Filter? = null, // Base Dialog - Optional - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(), + style: ComposeDialogStyle2 = DialogDefaults.defaultDialogStyle(), buttons: DialogButtons = DialogDefaults.buttons(), options: Options = Options(), specialOptions: SpecialOptions = DialogDefaults.specialOptions(), @@ -138,9 +138,9 @@ fun DialogList( description: String = "", filter: DialogList.Filter? = null, // Base Dialog - Optional - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(), + style: ComposeDialogStyle2 = DialogDefaults.defaultDialogStyle(), buttons: DialogButtons = DialogDefaults.buttons(), options: Options = Options(), specialOptions: SpecialOptions = DialogDefaults.specialOptions(), @@ -178,9 +178,9 @@ private fun DialogList( description: String, filter: DialogList.Filter? = null, // Base Dialog - Optional - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle, + style: ComposeDialogStyle2, buttons: DialogButtons, options: Options, specialOptions: SpecialOptions, diff --git a/library/modules/list/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/list/SpecialOptionsExtension.kt b/library/modules/list/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/list/SpecialOptionsExtension.kt new file mode 100644 index 0000000..8444b18 --- /dev/null +++ b/library/modules/list/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/list/SpecialOptionsExtension.kt @@ -0,0 +1,21 @@ +package com.michaelflisar.composedialogs.dialogs.list + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.WindowPosition +import com.michaelflisar.composedialogs.core.DialogDefaults +import com.michaelflisar.composedialogs.core.DialogStyleDesktopOtions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 +import com.michaelflisar.composedialogs.core.style.DialogStyleDesktop + +@Composable +fun DialogDefaults.styleWindowsListDialog( + dialogTitle: String, + position: WindowPosition = WindowPosition(Alignment.Center), + width: Dp = 800.dp, + height: Dp = 600.dp +): ComposeDialogStyle2 { + return DialogStyleDesktop(DialogStyleDesktopOtions(dialogTitle, position, width, height)) +} \ No newline at end of file diff --git a/library/modules/number/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.android.kt b/library/modules/number/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.android.kt index daa230f..5c70da0 100644 --- a/library/modules/number/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.android.kt +++ b/library/modules/number/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.android.kt @@ -5,8 +5,4 @@ import com.michaelflisar.composedialogs.core.DialogDefaults import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.specialOptions -actual fun DialogDefaults.defaultNumberDialogSpecialOptions(): SpecialOptions { - return specialOptions() -} - internal actual val DialogStyleModifier: Modifier = Modifier \ No newline at end of file diff --git a/library/modules/number/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/DialogNumberPicker.kt b/library/modules/number/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/DialogNumberPicker.kt index 0d2b7d8..d77854d 100644 --- a/library/modules/number/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/DialogNumberPicker.kt +++ b/library/modules/number/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/DialogNumberPicker.kt @@ -26,7 +26,8 @@ import com.michaelflisar.composedialogs.core.DialogState import com.michaelflisar.composedialogs.core.Options import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.defaultDialogStyle -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.specialOptions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.dialogs.number.composables.PickerIcon import com.michaelflisar.composedialogs.dialogs.number.utils.NumberUtil @@ -69,19 +70,19 @@ fun DialogNumberPicker( textStyle: TextStyle = MaterialTheme.typography.bodyMedium, onValueStateChanged: (value: T) -> Unit = { }, // Base Dialog - Optional - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(), + style: ComposeDialogStyle2 = DialogDefaults.defaultDialogStyle(), buttons: DialogButtons = DialogDefaults.buttons(), options: Options = Options(), - specialOptions: SpecialOptions = DialogDefaults.defaultNumberDialogSpecialOptions(), + specialOptions: SpecialOptions = DialogDefaults.specialOptions(), onEvent: (event: DialogEvent) -> Unit = {} ) { Dialog(state, title, icon, style, buttons, options, specialOptions, onEvent = onEvent) { val modifier = when (style.type) { - ComposeDialogStyle.Type.BottomSheet -> Modifier.fillMaxWidth() - ComposeDialogStyle.Type.Dialog -> DialogStyleModifier + ComposeDialogStyle2.Type.BottomSheet -> Modifier.fillMaxWidth() + ComposeDialogStyle2.Type.Dialog -> DialogStyleModifier } Row( diff --git a/library/modules/number/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.kt b/library/modules/number/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.kt index cccf9c5..a017725 100644 --- a/library/modules/number/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.kt +++ b/library/modules/number/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.kt @@ -4,6 +4,4 @@ import androidx.compose.ui.Modifier import com.michaelflisar.composedialogs.core.DialogDefaults import com.michaelflisar.composedialogs.core.SpecialOptions -expect fun DialogDefaults.defaultNumberDialogSpecialOptions(): SpecialOptions - internal expect val DialogStyleModifier: Modifier \ No newline at end of file diff --git a/library/modules/number/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.jvm.kt b/library/modules/number/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.jvm.kt index cce053a..95b4888 100644 --- a/library/modules/number/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.jvm.kt +++ b/library/modules/number/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.jvm.kt @@ -5,8 +5,4 @@ import androidx.compose.ui.Modifier import com.michaelflisar.composedialogs.core.DialogDefaults import com.michaelflisar.composedialogs.core.SpecialOptions -actual fun DialogDefaults.defaultNumberDialogSpecialOptions(): SpecialOptions { - return specialOptionsNumberDialog() -} - internal actual val DialogStyleModifier: Modifier = Modifier.fillMaxWidth() \ No newline at end of file diff --git a/library/modules/number/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/SpecialOptionsExtension.kt b/library/modules/number/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/SpecialOptionsExtension.kt index db9068d..fcd7fd9 100644 --- a/library/modules/number/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/SpecialOptionsExtension.kt +++ b/library/modules/number/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/SpecialOptionsExtension.kt @@ -1,14 +1,21 @@ package com.michaelflisar.composedialogs.dialogs.number +import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.window.WindowPosition import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions +import com.michaelflisar.composedialogs.core.DialogStyleDesktopOtions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 +import com.michaelflisar.composedialogs.core.style.DialogStyleDesktop -fun DialogDefaults.specialOptionsNumberDialog( +@Composable +fun DialogDefaults.styleWindowsNumberDialog( + dialogTitle: String, position: WindowPosition = WindowPosition(Alignment.Center), width: Dp = 400.dp, height: Dp = 200.dp -) = SpecialOptions(position, width, height) \ No newline at end of file +): ComposeDialogStyle2 { + return DialogStyleDesktop(DialogStyleDesktopOtions(dialogTitle, position, width, height)) +} \ No newline at end of file diff --git a/library/modules/number/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.native.kt b/library/modules/number/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.native.kt index daa230f..5c70da0 100644 --- a/library/modules/number/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.native.kt +++ b/library/modules/number/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/number/Platform.native.kt @@ -5,8 +5,4 @@ import com.michaelflisar.composedialogs.core.DialogDefaults import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.specialOptions -actual fun DialogDefaults.defaultNumberDialogSpecialOptions(): SpecialOptions { - return specialOptions() -} - internal actual val DialogStyleModifier: Modifier = Modifier \ No newline at end of file diff --git a/library/modules/progress/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/Platform.android.kt b/library/modules/progress/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/Platform.android.kt deleted file mode 100644 index 7cac585..0000000 --- a/library/modules/progress/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/Platform.android.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.michaelflisar.composedialogs.dialogs.progress - -import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions -import com.michaelflisar.composedialogs.core.specialOptions - -actual fun DialogDefaults.defaultProgressDialogSpecialOptions(): SpecialOptions { - return specialOptions() -} \ No newline at end of file diff --git a/library/modules/progress/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/DialogProgress.kt b/library/modules/progress/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/DialogProgress.kt index d3a075d..27c19b5 100644 --- a/library/modules/progress/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/DialogProgress.kt +++ b/library/modules/progress/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/DialogProgress.kt @@ -22,7 +22,8 @@ import com.michaelflisar.composedialogs.core.DialogState import com.michaelflisar.composedialogs.core.Options import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.defaultDialogStyle -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.specialOptions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 /** * Shows a dialog with an optional label and a progress indicator @@ -43,11 +44,11 @@ fun DialogProgress( content: (@Composable ColumnScope.() -> Unit)? = null, progressStyle: DialogProgress.Style = DialogProgress.Style.Indeterminate(), // Base Dialog - Optional - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(), + style: ComposeDialogStyle2 = DialogDefaults.defaultDialogStyle(), buttons: DialogButtons = DialogDefaults.buttons(), - specialOptions: SpecialOptions = DialogDefaults.defaultProgressDialogSpecialOptions(), + specialOptions: SpecialOptions = DialogDefaults.specialOptions(), options: Options = Options(), onEvent: (event: DialogEvent) -> Unit = {} ) { diff --git a/library/modules/progress/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/Platform.kt b/library/modules/progress/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/Platform.kt deleted file mode 100644 index 4d3a2b8..0000000 --- a/library/modules/progress/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/Platform.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.michaelflisar.composedialogs.dialogs.progress - -import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions - -expect fun DialogDefaults.defaultProgressDialogSpecialOptions(): SpecialOptions \ No newline at end of file diff --git a/library/modules/progress/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/Platform.jvm.kt b/library/modules/progress/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/Platform.jvm.kt deleted file mode 100644 index 688c9a5..0000000 --- a/library/modules/progress/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/Platform.jvm.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.michaelflisar.composedialogs.dialogs.progress - -import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions -import com.michaelflisar.composedialogs.core.specialOptions - -actual fun DialogDefaults.defaultProgressDialogSpecialOptions(): SpecialOptions { - return specialOptionsProgressDialog() -} \ No newline at end of file diff --git a/library/modules/progress/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/SpecialOptionsExtension.kt b/library/modules/progress/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/SpecialOptionsExtension.kt index 73ae046..65fbab0 100644 --- a/library/modules/progress/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/SpecialOptionsExtension.kt +++ b/library/modules/progress/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/SpecialOptionsExtension.kt @@ -1,14 +1,21 @@ package com.michaelflisar.composedialogs.dialogs.progress +import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.window.WindowPosition import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions +import com.michaelflisar.composedialogs.core.DialogStyleDesktopOtions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 +import com.michaelflisar.composedialogs.core.style.DialogStyleDesktop -fun DialogDefaults.specialOptionsProgressDialog( +@Composable +fun DialogDefaults.styleWindowsProgressDialog( + dialogTitle: String, position: WindowPosition = WindowPosition(Alignment.Center), width: Dp = 600.dp, height: Dp = 200.dp -) = SpecialOptions(position, width, height) \ No newline at end of file +): ComposeDialogStyle2 { + return DialogStyleDesktop(DialogStyleDesktopOtions(dialogTitle, position, width, height)) +} \ No newline at end of file diff --git a/library/modules/progress/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/Platform.native.kt b/library/modules/progress/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/Platform.native.kt deleted file mode 100644 index 7cac585..0000000 --- a/library/modules/progress/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/progress/Platform.native.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.michaelflisar.composedialogs.dialogs.progress - -import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions -import com.michaelflisar.composedialogs.core.specialOptions - -actual fun DialogDefaults.defaultProgressDialogSpecialOptions(): SpecialOptions { - return specialOptions() -} \ No newline at end of file diff --git a/library/modules/time/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.android.kt b/library/modules/time/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.android.kt index 1f23524..7f0274f 100644 --- a/library/modules/time/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.android.kt +++ b/library/modules/time/src/androidMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.android.kt @@ -10,8 +10,4 @@ import com.michaelflisar.composedialogs.core.specialOptions @Composable actual fun is24HourFormat(): Boolean { return DateFormat.is24HourFormat(LocalContext.current) -} - -actual fun DialogDefaults.defaultTimeDialogSpecialOptions(): SpecialOptions { - return specialOptions() } \ No newline at end of file diff --git a/library/modules/time/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/DialogTime.kt b/library/modules/time/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/DialogTime.kt index aaf5187..12245bb 100644 --- a/library/modules/time/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/DialogTime.kt +++ b/library/modules/time/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/DialogTime.kt @@ -14,7 +14,7 @@ import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import com.michaelflisar.composedialogs.core.* -import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 import com.michaelflisar.composedialogs.dialogs.time.utils.TimeUtil import kotlinx.datetime.LocalTime @@ -37,12 +37,12 @@ fun DialogTime( // Custom - Optional setup: DialogTime.Setup = DialogTimeDefaults.setup(), // Base Dialog - Optional - title: String? = null, + title: (@Composable () -> Unit)? = null, icon: (@Composable () -> Unit)? = null, - style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(), + style: ComposeDialogStyle2 = DialogDefaults.defaultDialogStyle(), buttons: DialogButtons = DialogDefaults.buttons(), options: Options = Options(), - specialOptions: SpecialOptions = DialogDefaults.defaultTimeDialogSpecialOptions(), + specialOptions: SpecialOptions = DialogDefaults.specialOptions(), onEvent: (event: DialogEvent) -> Unit = {} ) { //if (!setup.seconds) { diff --git a/library/modules/time/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.kt b/library/modules/time/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.kt index 1df6012..f6186bb 100644 --- a/library/modules/time/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.kt +++ b/library/modules/time/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.kt @@ -4,7 +4,5 @@ import androidx.compose.runtime.Composable import com.michaelflisar.composedialogs.core.DialogDefaults import com.michaelflisar.composedialogs.core.SpecialOptions -expect fun DialogDefaults.defaultTimeDialogSpecialOptions(): SpecialOptions - @Composable expect fun is24HourFormat(): Boolean \ No newline at end of file diff --git a/library/modules/time/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.jvm.kt b/library/modules/time/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.jvm.kt index 74a6826..0c91376 100644 --- a/library/modules/time/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.jvm.kt +++ b/library/modules/time/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.jvm.kt @@ -5,9 +5,6 @@ import com.michaelflisar.composedialogs.core.DialogDefaults import com.michaelflisar.composedialogs.core.SpecialOptions import com.michaelflisar.composedialogs.core.specialOptions -actual fun DialogDefaults.defaultTimeDialogSpecialOptions(): SpecialOptions { - return specialOptionsTimeDialog() -} @Composable actual fun is24HourFormat(): Boolean { return true diff --git a/library/modules/time/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/SpecialOptionsExtension.kt b/library/modules/time/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/SpecialOptionsExtension.kt index 786c18a..65ddbf5 100644 --- a/library/modules/time/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/SpecialOptionsExtension.kt +++ b/library/modules/time/src/jvmMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/SpecialOptionsExtension.kt @@ -1,14 +1,21 @@ package com.michaelflisar.composedialogs.dialogs.time +import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.window.WindowPosition import com.michaelflisar.composedialogs.core.DialogDefaults -import com.michaelflisar.composedialogs.core.SpecialOptions +import com.michaelflisar.composedialogs.core.DialogStyleDesktopOtions +import com.michaelflisar.composedialogs.core.style.ComposeDialogStyle2 +import com.michaelflisar.composedialogs.core.style.DialogStyleDesktop -fun DialogDefaults.specialOptionsTimeDialog( +@Composable +fun DialogDefaults.styleWindowsTimeDialog( + dialogTitle: String, position: WindowPosition = WindowPosition(Alignment.Center), width: Dp = 300.dp, height: Dp = 260.dp -) = SpecialOptions(position, width, height) \ No newline at end of file +): ComposeDialogStyle2 { + return DialogStyleDesktop(DialogStyleDesktopOtions(dialogTitle, position, width, height)) +} \ No newline at end of file diff --git a/library/modules/time/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.native.kt b/library/modules/time/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.native.kt index 1bab350..1ef70ea 100644 --- a/library/modules/time/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.native.kt +++ b/library/modules/time/src/nativeMain/kotlin/com/michaelflisar/composedialogs/dialogs/time/Platform.native.kt @@ -8,8 +8,4 @@ import com.michaelflisar.composedialogs.core.specialOptions @Composable actual fun is24HourFormat(): Boolean { return false -} - -actual fun DialogDefaults.defaultTimeDialogSpecialOptions(): SpecialOptions { - return specialOptions() } \ No newline at end of file