Skip to content

Commit

Permalink
Create Screen & LazyScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
yasanglass committed Feb 29, 2024
1 parent 2358ebf commit 19858f8
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package glass.yasan.concrete.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import glass.yasan.concrete.theme.ConcreteTheme

@Composable
public fun LazyScreen(
content: LazyListScope.() -> Unit,
modifier: Modifier = Modifier,
topBar: (@Composable () -> Unit)? = null,
bottomBar: (@Composable () -> Unit)? = null,
) {
Column(
modifier = modifier
.background(ConcreteTheme.colors.layer.midground)
.fillMaxSize(),
) {
if (topBar != null) {
Column(
modifier = Modifier
.background(ConcreteTheme.colors.layer.foreground)
) {
topBar()
Divider()
}
}
LazyColumn(
modifier = Modifier.weight(1f),
content = content,
)
if (bottomBar != null) {
Column(
modifier = Modifier
.background(ConcreteTheme.colors.layer.foreground)
) {
Divider()
bottomBar()
}
}
}
}
46 changes: 46 additions & 0 deletions concrete/src/main/kotlin/glass/yasan/concrete/component/Screen.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package glass.yasan.concrete.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import glass.yasan.concrete.theme.ConcreteTheme

@Composable
public fun Screen(
content: @Composable ColumnScope.() -> Unit,
modifier: Modifier = Modifier,
topBar: (@Composable () -> Unit)? = null,
bottomBar: (@Composable () -> Unit)? = null,
) {
Column(
modifier = modifier
.background(ConcreteTheme.colors.layer.midground)
.fillMaxSize(),
) {
if (topBar != null) {
Column(
modifier = Modifier
.background(ConcreteTheme.colors.layer.foreground)
) {
topBar()
Divider()
}
}
Column(
modifier = Modifier.weight(1f),
content = content,
)
if (bottomBar != null) {
Column(
modifier = Modifier
.background(ConcreteTheme.colors.layer.foreground)
) {
Divider()
bottomBar()
}
}
}
}

0 comments on commit 19858f8

Please sign in to comment.