Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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 @@ -30,6 +30,8 @@ import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.input.key.type
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.CanvasBasedWindow
import com.bumble.appyx.demos.appyxSample
Expand All @@ -47,6 +49,8 @@ import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch

private val containerShape = RoundedCornerShape(8)

@OptIn(ExperimentalComposeUiApi::class)
fun main() {
val events: Channel<Unit> = Channel()
Expand All @@ -58,11 +62,9 @@ fun main() {
}
}

private val containerShape = RoundedCornerShape(8)

@Composable
private fun CakeApp(events: Channel<Unit>, navigator: Navigator) {
AppyxSampleAppTheme(darkTheme = true, themeTypography = webTypography) {
AppyxSampleAppTheme(darkTheme = true) {
val requester = remember { FocusRequester() }
var hasFocus by remember { mutableStateOf(false) }

Expand All @@ -81,7 +83,7 @@ private fun CakeApp(events: Channel<Unit>, navigator: Navigator) {
.onFocusChanged { hasFocus = it.hasFocus },
color = MaterialTheme.colorScheme.background,
) {
CompositionLocalProvider(LocalNavigator provides navigator) {
ProvideScopeConfiguration(navigator, screenSize) {
BlackContainer {
WebNodeHost(
screenSize = screenSize,
Expand Down Expand Up @@ -123,6 +125,27 @@ private fun BlackContainer(content: @Composable () -> Unit) {
}
}

@Composable
private fun ProvideScopeConfiguration(
navigator: Navigator,
screenSize: ScreenSize,
body: @Composable () -> Unit
) {
CompositionLocalProvider(
LocalDensity provides screenSize.calculateDensityFromScreenSize(),
LocalNavigator provides navigator,
) {
Comment thread
zsoltk marked this conversation as resolved.
Outdated
body()
}
}

private fun ScreenSize.calculateDensityFromScreenSize(): Density =
if (widthDp.value < 1500) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be a proportional value coerced in (0.75f, 4f)?

Density(1.2f, 1f)
} else {
Density(1.8f, 1.2f)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks weird to me. Why is it specifically 1500? Why specifically 1.2f, 1f, 1.8f, 1.2f? The issue title also implies dynamic, but this looks more two static cases rather?


private fun onKeyEvent(
keyEvent: KeyEvent,
events: Channel<Unit>,
Expand Down

This file was deleted.