Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crossfade composable and finiteAnimationSpec common functions support #460

Merged
merged 4 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ object Attrs {
const val attrAlignment = "alignment"
const val attrAlpha = "alpha"
const val attrAlwaysShowLabel = "alwaysShowLabel"
const val attrAnimationSpec = "animationSpec"
const val attrAutoCorrect = "autoCorrect"
const val attrBeyondBoundsPageCount = "beyondBoundsPageCount"
const val attrBorder = "border"
Expand Down Expand Up @@ -100,8 +101,10 @@ object Attrs {
const val attrMinSize = "minSize"
const val attrMinValue = "minValue"
const val attrNavigate = "navigate"
const val attrOverflow = "overflow"
const val attrOffsetMillis = "offsetMillis"
const val attrOffsetType = "offsetType"
const val attrOnDismissRequest = "onDismissRequest"
const val attrOverflow = "overflow"
const val attrPageCount = "pageCount"
const val attrPageSize = "pageSize"
const val attrPageSpacing = "pageSpacing"
Expand Down Expand Up @@ -151,6 +154,7 @@ object Attrs {
const val attrStrokeCap = "strokeCap"
const val attrStrokeWidth = "strokeWidth"
const val attrStyle = "style"
const val attrTargetState = "targetState"
const val attrTemplate = "template"
const val attrText = "text"
const val attrTextAlign = "textAlign"
Expand All @@ -169,6 +173,7 @@ object Attrs {
const val attrUserScrollEnabled = "userScrollEnabled"
const val attrVerticalAlignment = "verticalAlignment"
const val attrVerticalArrangement = "verticalArrangement"
const val attrViewId = "viewId"
const val attrVisible = "visible"
const val attrVisualTransformation = "visualTransformation"
const val attrUnselectedContentColor = "unselectedContentColor"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ object ComposableTypes {
const val badgedBox = "BadgedBox"
const val basicAlertDialog = "BasicAlertDialog"
const val box = "Box"
const val boxWithConstraints = "BoxWithConstraints"
const val bottomAppBar = "BottomAppBar"
const val bottomSheetScaffold = "BottomSheetScaffold"
const val button = "Button"
Expand All @@ -17,6 +18,7 @@ object ComposableTypes {
const val checkbox = "CheckBox"
const val circularProgressIndicator = "CircularProgressIndicator"
const val column = "Column"
const val crossfade = "Crossfade"
const val datePicker = "DatePicker"
const val datePickerDialog = "DatePickerDialog"
const val dateRangePicker = "DateRangePicker"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ object EnterExitTransitionFunctions {
const val slideInHorizontally = "slideInHorizontally"

// Argument names used for the functions above
const val argAnimationSpec = "animationSpec"
const val argClip = "clip"
const val argExpandFrom = "expandFrom"
const val argHeight = "height"
Expand Down Expand Up @@ -300,6 +301,11 @@ object SnackbarDurationValues {
const val short = "short"
}

object StartOffsetTypeValues {
const val delay = "Delay"
const val fastForward = "FastForward"
}

object StrokeCapValues {
const val round = "round"
const val square = "square"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import org.phoenixframework.Message
import org.phoenixframework.liveview.data.core.CoreNodeElement
import org.phoenixframework.liveview.ui.modifiers.ModifiersParser
import org.phoenixframework.liveview.data.repository.Repository
import org.phoenixframework.liveview.data.service.ChannelService
import org.phoenixframework.liveview.data.service.SocketService
import org.phoenixframework.liveview.ui.registry.ComposableNodeFactory
import org.phoenixframework.liveview.domain.data.ComposableTreeNode
import org.phoenixframework.liveview.lib.Document
import org.phoenixframework.liveview.lib.Node
import org.phoenixframework.liveview.lib.NodeRef
import org.phoenixframework.liveview.ui.modifiers.ModifiersParser
import org.phoenixframework.liveview.ui.registry.ComposableNodeFactory

internal class LiveViewCoordinator(
internal val httpBaseUrl: String,
Expand Down Expand Up @@ -84,7 +84,7 @@ internal class LiveViewCoordinator(
repository.loadStyleData()?.let { styleFileContentAsString ->
ModifiersParser.fromStyleFile(
styleFileContentAsString,
::pushEvent
null,
)
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ abstract class ComposableView<CP : ComposableProperties>(protected open val prop
internal const val EVENT_TYPE_SUBMIT = "submit"

internal const val KEY_PHX_VALUE = "value"

private val viewValues = mutableMapOf<String, Any>()

fun saveViewValue(viewId: String, value: Any) {
viewValues[viewId] = value
}

fun removeViewValue(viewId: String) {
viewValues.remove(viewId)
}

fun getViewValue(viewId: String): Any? {
return viewValues[viewId]
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import org.phoenixframework.liveview.data.constants.ModifierArgs.argBorder
import org.phoenixframework.liveview.data.constants.ModifierArgs.argBrush
import org.phoenixframework.liveview.data.constants.ModifierArgs.argColor
Expand All @@ -32,7 +31,7 @@ fun Modifier.borderFromStyle(arguments: List<ModifierDataAdapter.ArgumentData>):
if (arg != null) borderColor = colorFromArgument(arg)

arg = borderArguments.find { it.name == argWidth }
if (arg != null) borderWidth = (arg.intValue ?: 0).dp
if (arg != null) borderWidth = dpFromArgument(arg)

arg = borderArguments.find { it.name == argBorder }
if (arg != null) borderStroke = borderStrokeFromArgument(arg)
Expand All @@ -56,10 +55,10 @@ fun Modifier.borderFromStyle(arguments: List<ModifierDataAdapter.ArgumentData>):
borderArgument.type == typeShape ->
borderShape = shapeFromArgument(borderArgument)

borderArgument.isInt ->
borderWidth = (borderArgument.intValue ?: 0).dp
borderArgument.isDot || borderArgument.isAtom -> {
if (borderWidth == null)
borderWidth = dpFromArgument(borderArgument)

borderArgument.isDot -> {
val b = brushFromArgument(borderArgument)
if (b != null) borderBrush = b

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,27 @@ class ModifierDataAdapter(tupleExpression: ElixirParser.TupleExprContext) {
)

companion object {
private const val TypeAtom = "Atom"
private const val TypeBoolean = "Boolean"
private const val TypeDot = "."
private const val TypeFloat = "Float"
private const val TypeInt = "Int"
private const val TypeList = "List"
private const val TypeString = "String"
private const val TypeUnary = "Unary"
private const val TypeUndefined = "<undefined>"
internal const val TypeAtom = "Atom"
internal const val TypeBoolean = "Boolean"
internal const val TypeDot = "."
internal const val TypeFloat = "Float"
internal const val TypeInt = "Int"
internal const val TypeLambdaValue = "lambdaValue"
internal const val TypeList = "List"
internal const val TypeString = "String"
internal const val TypeUnary = "Unary"
internal const val TypeUndefined = "<undefined>"

// TODO We're just supporting primitive types from now
fun typeFromClass(value: Any?): String {
return when (value) {
is Boolean -> TypeBoolean
is Float, is Double -> TypeFloat
is Int -> TypeInt
is String -> TypeString
else -> TypeString
}
}
}
}

Loading
Loading