mirror of
https://github.com/AChep/keyguard-app.git
synced 2025-01-04 18:59:15 +01:00
fix: Add empty Tooltip implementation for Android platform
This commit is contained in:
parent
bb979cb52d
commit
4d6a9a7ec8
@ -0,0 +1,20 @@
|
||||
package com.artemchep.keyguard.ui.tooltip
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxScope
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
@Composable
|
||||
actual fun <T : Any> Tooltip(
|
||||
modifier: Modifier,
|
||||
valueOrNull: T?,
|
||||
tooltip: @Composable BoxScope.(T) -> Unit,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier,
|
||||
) {
|
||||
content()
|
||||
}
|
||||
}
|
@ -1,60 +1,13 @@
|
||||
package com.artemchep.keyguard.ui.tooltip
|
||||
|
||||
import androidx.compose.foundation.TooltipArea
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxScope
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.contentColorFor
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.artemchep.keyguard.ui.surface.LocalSurfaceColor
|
||||
import com.artemchep.keyguard.ui.theme.Dimens
|
||||
import com.artemchep.keyguard.ui.theme.verticalPaddingHalf
|
||||
|
||||
@Composable
|
||||
fun <T : Any> Tooltip(
|
||||
expect fun <T : Any> Tooltip(
|
||||
modifier: Modifier = Modifier,
|
||||
valueOrNull: T?,
|
||||
tooltip: @Composable BoxScope.(T) -> Unit,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
TooltipArea(
|
||||
modifier = modifier,
|
||||
tooltip = {
|
||||
if (valueOrNull != null) {
|
||||
val backgroundColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
val contentColor = contentColorFor(backgroundColor)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.background(
|
||||
color = backgroundColor,
|
||||
shape = MaterialTheme.shapes.medium,
|
||||
)
|
||||
.padding(
|
||||
horizontal = Dimens.horizontalPadding,
|
||||
vertical = Dimens.verticalPaddingHalf,
|
||||
)
|
||||
.widthIn(
|
||||
max = 320.dp,
|
||||
),
|
||||
) {
|
||||
CompositionLocalProvider(
|
||||
LocalSurfaceColor provides backgroundColor,
|
||||
LocalContentColor provides contentColor,
|
||||
LocalTextStyle provides MaterialTheme.typography.bodyMedium,
|
||||
) {
|
||||
tooltip(valueOrNull)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
content = content,
|
||||
)
|
||||
}
|
||||
)
|
||||
|
@ -0,0 +1,60 @@
|
||||
package com.artemchep.keyguard.ui.tooltip
|
||||
|
||||
import androidx.compose.foundation.TooltipArea
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxScope
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.contentColorFor
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.artemchep.keyguard.ui.surface.LocalSurfaceColor
|
||||
import com.artemchep.keyguard.ui.theme.Dimens
|
||||
import com.artemchep.keyguard.ui.theme.verticalPaddingHalf
|
||||
|
||||
@Composable
|
||||
actual fun <T : Any> Tooltip(
|
||||
modifier: Modifier,
|
||||
valueOrNull: T?,
|
||||
tooltip: @Composable BoxScope.(T) -> Unit,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
TooltipArea(
|
||||
modifier = modifier,
|
||||
tooltip = {
|
||||
if (valueOrNull != null) {
|
||||
val backgroundColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
val contentColor = contentColorFor(backgroundColor)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.background(
|
||||
color = backgroundColor,
|
||||
shape = MaterialTheme.shapes.medium,
|
||||
)
|
||||
.padding(
|
||||
horizontal = Dimens.horizontalPadding,
|
||||
vertical = Dimens.verticalPaddingHalf,
|
||||
)
|
||||
.widthIn(
|
||||
max = 320.dp,
|
||||
),
|
||||
) {
|
||||
CompositionLocalProvider(
|
||||
LocalSurfaceColor provides backgroundColor,
|
||||
LocalContentColor provides contentColor,
|
||||
LocalTextStyle provides MaterialTheme.typography.bodyMedium,
|
||||
) {
|
||||
tooltip(valueOrNull)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
content = content,
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue
Block a user