generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 9
/
PaddingValuesExtensions.kt
48 lines (44 loc) · 1.86 KB
/
PaddingValuesExtensions.kt
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
package com.bitwarden.authenticator.ui.platform.base.util
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.calculateEndPadding
import androidx.compose.foundation.layout.calculateStartPadding
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.LayoutDirection
/**
* Compares the top, bottom, start, and end values to another [PaddingValues] and returns a new
* 'PaddingValues' using the maximum values of each property respectively.
*
* @param other The other values to compare against.
*/
fun PaddingValues.max(
other: PaddingValues,
direction: LayoutDirection,
): PaddingValues = PaddingValues(
top = maxOf(calculateTopPadding(), other.calculateTopPadding()),
bottom = maxOf(calculateBottomPadding(), other.calculateBottomPadding()),
start = maxOf(calculateStartPadding(direction), other.calculateStartPadding(direction)),
end = maxOf(calculateEndPadding(direction), other.calculateEndPadding(direction)),
)
/**
* Compares the top, bottom, start, and end values to a [WindowInsets] and returns a new
* 'PaddingValues' using the maximum values of each property respectively.
*
* @param windowInsets The [WindowInsets] to compare against.
*/
@Composable
fun PaddingValues.max(
windowInsets: WindowInsets,
): PaddingValues = max(windowInsets.asPaddingValues())
/**
* Compares the top, bottom, start, and end values to another [PaddingValues] and returns a new
* 'PaddingValues' using the maximum values of each property respectively.
*
* @param other The other [PaddingValues] to compare against.
*/
@Composable
fun PaddingValues.max(
other: PaddingValues,
): PaddingValues = max(other, LocalLayoutDirection.current)