mirror of
https://github.com/openflocon/Flocon.git
synced 2026-05-06 05:18:41 +00:00
fix: [PREVIEW] android preview fix (#66)
* fix: [PREVIEW] android preview fix * fix: [PREVIEW] android preview fix --------- Co-authored-by: Florent Champigny <florent@bere.al>
This commit is contained in:
parent
2dc5daba01
commit
6f6623fff2
5 changed files with 83 additions and 16 deletions
|
|
@ -0,0 +1,18 @@
|
|||
package io.github.openflocon.flocondesktop.common.ui.window
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
actual fun createFloconWindowState(): FloconWindowState {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
actual fun FloconWindow(
|
||||
title: String,
|
||||
state: FloconWindowState,
|
||||
onCloseRequest: () -> Unit,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
TODO()
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package io.github.openflocon.flocondesktop.common.ui.window
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
interface FloconWindowState
|
||||
|
||||
expect fun createFloconWindowState(): FloconWindowState
|
||||
|
||||
@Composable
|
||||
expect fun FloconWindow(
|
||||
title: String,
|
||||
state: FloconWindowState,
|
||||
onCloseRequest: () -> Unit,
|
||||
content: @Composable () -> Unit,
|
||||
)
|
||||
|
|
@ -25,11 +25,9 @@ import androidx.compose.runtime.setValue
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.WindowState
|
||||
import com.sebastianneubauer.jsontree.search.rememberSearchState
|
||||
import flocondesktop.composeapp.generated.resources.Res
|
||||
import flocondesktop.composeapp.generated.resources.app_icon
|
||||
import io.github.openflocon.flocondesktop.common.ui.window.FloconWindow
|
||||
import io.github.openflocon.flocondesktop.common.ui.window.FloconWindowState
|
||||
import io.github.openflocon.flocondesktop.features.network.ui.model.NetworkJsonUi
|
||||
import io.github.openflocon.library.designsystem.FloconTheme
|
||||
import io.github.openflocon.library.designsystem.components.FloconIcon
|
||||
|
|
@ -38,12 +36,11 @@ import io.github.openflocon.library.designsystem.components.FloconJsonTree
|
|||
import io.github.openflocon.library.designsystem.components.FloconSurface
|
||||
import io.github.openflocon.library.designsystem.components.FloconTextField
|
||||
import kotlinx.coroutines.launch
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
|
||||
@Composable
|
||||
fun NetworkJsonScreen(
|
||||
json: NetworkJsonUi,
|
||||
state: WindowState,
|
||||
state: FloconWindowState,
|
||||
onCloseRequest: () -> Unit
|
||||
) {
|
||||
var query by remember { mutableStateOf("") }
|
||||
|
|
@ -56,9 +53,8 @@ fun NetworkJsonScreen(
|
|||
searchState.query = query
|
||||
}
|
||||
|
||||
Window(
|
||||
FloconWindow(
|
||||
title = "Body",
|
||||
icon = painterResource(Res.drawable.app_icon),
|
||||
state = state,
|
||||
onCloseRequest = onCloseRequest
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -23,10 +23,9 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.WindowPlacement
|
||||
import androidx.compose.ui.window.WindowPosition
|
||||
import androidx.compose.ui.window.WindowState
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import io.github.openflocon.flocondesktop.common.ui.window.FloconWindowState
|
||||
import io.github.openflocon.flocondesktop.common.ui.window.createFloconWindowState
|
||||
import io.github.openflocon.flocondesktop.features.network.ui.NetworkAction
|
||||
import io.github.openflocon.flocondesktop.features.network.ui.NetworkUiState
|
||||
import io.github.openflocon.flocondesktop.features.network.ui.NetworkViewModel
|
||||
|
|
@ -145,7 +144,7 @@ fun NetworkScreen(
|
|||
}
|
||||
}
|
||||
|
||||
val states = remember { mutableStateMapOf<NetworkJsonUi, WindowState>() }
|
||||
val states = remember { mutableStateMapOf<NetworkJsonUi, FloconWindowState>() }
|
||||
|
||||
|
||||
LaunchedEffect(uiState.contentState.detailJsons) {
|
||||
|
|
@ -155,10 +154,7 @@ fun NetworkScreen(
|
|||
deletedJson.forEach { states.remove(it) }
|
||||
addedJson.forEach {
|
||||
states.put(
|
||||
it, WindowState(
|
||||
placement = WindowPlacement.Floating,
|
||||
position = WindowPosition(Alignment.Center)
|
||||
)
|
||||
it, createFloconWindowState()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package io.github.openflocon.flocondesktop.common.ui.window
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.WindowPlacement
|
||||
import androidx.compose.ui.window.WindowPosition
|
||||
import androidx.compose.ui.window.WindowState
|
||||
import flocondesktop.composeapp.generated.resources.Res
|
||||
import flocondesktop.composeapp.generated.resources.app_icon
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
|
||||
data class FloconWindowStateDesktop(
|
||||
val windowState: WindowState
|
||||
) : FloconWindowState
|
||||
|
||||
actual fun createFloconWindowState(): FloconWindowState {
|
||||
return FloconWindowStateDesktop(
|
||||
WindowState(
|
||||
placement = WindowPlacement.Floating,
|
||||
position = WindowPosition(Alignment.Center)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
actual fun FloconWindow(
|
||||
title: String,
|
||||
state: FloconWindowState,
|
||||
onCloseRequest: () -> Unit,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
Window(
|
||||
title = title,
|
||||
icon = painterResource(Res.drawable.app_icon),
|
||||
state = (state as FloconWindowStateDesktop).windowState,
|
||||
onCloseRequest = onCloseRequest,
|
||||
) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue