Skip to content

Commit

Permalink
Implement HandlerNavigation
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Sep 5, 2024
1 parent 0dfe3a9 commit 13e4701
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import io.getstream.server.driven.core.model.Handler
import io.getstream.server.driven.core.model.HandlerAction
import io.getstream.server.driven.core.model.HandlerNavigation
import io.getstream.server.driven.core.model.HandlerType

@Composable
Expand All @@ -29,17 +30,23 @@ fun Modifier.consumeHandler(
): Modifier {
if (handler == null) return this

val action = if (handler.actions[HandlerAction.NAVIGATION.value] == "to") {
{ navigator }
} else {
{}
}
handler.actions.forEach { element ->
val action =
if (element.key == HandlerAction.NAVIGATION.value &&
element.value == HandlerNavigation.TO.value
) {
{ navigator }
} else {
{}
}

return then(
if (handler.type == HandlerType.CLICK.value) {
val newModifier = if (handler.type == HandlerType.CLICK.value) {
Modifier.clickable { action.invoke() }
} else {
Modifier
}
)

then(newModifier)
}
return this
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ enum class HandlerType(val value: String) {
enum class HandlerAction(val value: String) {
NAVIGATION("navigation")
}

enum class HandlerNavigation(val value: String) {
TO("to")
}

0 comments on commit 13e4701

Please sign in to comment.