Skip to content

Commit

Permalink
added desktop and compose dialog for jvm target + moved back to title…
Browse files Browse the repository at this point in the history
… composable for all dialogs
  • Loading branch information
Michael Flisar authored and Michael Flisar committed Oct 25, 2024
1 parent 0a74cfb commit 40d9976
Show file tree
Hide file tree
Showing 75 changed files with 799 additions and 783 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,21 +20,21 @@ 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)
}
}

@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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
) {
Expand Down Expand Up @@ -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) {
Expand All @@ -126,7 +127,7 @@ private fun RowScope.DemoDialogDate1(

@Composable
private fun RowScope.DemoDialogTime1(
style: ComposeDialogStyle,
style: ComposeDialogStyle2,
icon: (@Composable () -> Unit)?,
is24Hours: Boolean
) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

Expand All @@ -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,
Expand Down Expand Up @@ -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

Expand All @@ -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,
Expand All @@ -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

Expand All @@ -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,
Expand All @@ -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
) {
Expand All @@ -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,
Expand Down
Loading

0 comments on commit 40d9976

Please sign in to comment.