-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSpacers.kt
More file actions
82 lines (74 loc) · 2.09 KB
/
Spacers.kt
File metadata and controls
82 lines (74 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package to.bitkit.ui.components
import androidx.annotation.FloatRange
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import to.bitkit.ui.theme.Insets
import to.bitkit.ui.theme.TopBarHeight
@Composable
fun VerticalSpacer(
height: Dp,
modifier: Modifier = Modifier,
) {
Spacer(modifier = modifier then Modifier.height(height))
}
@Composable
fun ColumnScope.VerticalSpacer(
minHeight: Dp,
maxHeight: Dp,
modifier: Modifier = Modifier,
) {
Spacer(
modifier = modifier then Modifier
.weight(1f)
.sizeIn(minHeight = minHeight, maxHeight = maxHeight)
)
}
@Composable
fun HorizontalSpacer(
width: Dp,
modifier: Modifier = Modifier,
) {
Spacer(modifier = modifier then Modifier.width(width))
}
@Suppress("ComposeMultipleContentEmitters")
@Composable
fun ColumnScope.FillHeight(
modifier: Modifier = Modifier,
@FloatRange weight: Float = 1f,
fill: Boolean = true,
min: Dp = 0.dp,
) {
if (min > 0.dp) Spacer(modifier = modifier then Modifier.height(min))
Spacer(modifier = modifier then Modifier.weight(weight, fill = fill))
}
@Suppress("ComposeMultipleContentEmitters")
@Composable
fun RowScope.FillWidth(
modifier: Modifier = Modifier,
@FloatRange weight: Float = 1f,
fill: Boolean = true,
min: Dp = 0.dp,
) {
if (min > 0.dp) Spacer(modifier = modifier then Modifier.width(min))
Spacer(modifier = modifier then Modifier.weight(weight, fill = fill))
}
@Composable
fun StatusBarSpacer(modifier: Modifier = Modifier) {
Spacer(
modifier = modifier.height(Insets.Top),
)
}
@Composable
fun TopBarSpacer(modifier: Modifier = Modifier) {
Spacer(
modifier = modifier.height(TopBarHeight),
)
}