-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(AboutScreen): padding + system navbar transparency
- Loading branch information
1 parent
f314283
commit 3931771
Showing
6 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/src/main/kotlin/com/aliucord/manager/ui/util/paddings/CompositePaddingValues.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.aliucord.manager.ui.util.paddings | ||
|
||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.runtime.Stable | ||
import androidx.compose.ui.unit.LayoutDirection | ||
|
||
/** | ||
* Add the values of two [PaddingValues] together. | ||
*/ | ||
fun PaddingValues.add(values: PaddingValues): PaddingValues = | ||
CompositePaddingValues(this, values) | ||
|
||
@Stable | ||
private class CompositePaddingValues( | ||
private val valuesA: PaddingValues, | ||
private val valuesB: PaddingValues, | ||
) : PaddingValues { | ||
override fun calculateBottomPadding() = | ||
valuesA.calculateBottomPadding() + valuesB.calculateBottomPadding() | ||
|
||
override fun calculateLeftPadding(layoutDirection: LayoutDirection) = | ||
valuesA.calculateLeftPadding(layoutDirection) + valuesB.calculateLeftPadding(layoutDirection) | ||
|
||
override fun calculateRightPadding(layoutDirection: LayoutDirection) = | ||
valuesA.calculateRightPadding(layoutDirection) + valuesB.calculateRightPadding(layoutDirection) | ||
|
||
override fun calculateTopPadding() = | ||
valuesA.calculateTopPadding() + valuesB.calculateTopPadding() | ||
} |
54 changes: 54 additions & 0 deletions
54
app/src/main/kotlin/com/aliucord/manager/ui/util/paddings/ExcludePaddingValues.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.aliucord.manager.ui.util.paddings | ||
|
||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.WindowInsetsSides | ||
import androidx.compose.runtime.Stable | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.LayoutDirection | ||
|
||
typealias PaddingValuesSides = WindowInsetsSides | ||
|
||
/** | ||
* Remove particular side values from [PaddingValues]. | ||
*/ | ||
fun PaddingValues.exclude(sides: PaddingValuesSides): PaddingValues = | ||
ExcludePaddingValues(this, sides) | ||
|
||
@Stable | ||
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") | ||
private class ExcludePaddingValues( | ||
private val values: PaddingValues, | ||
private val excludeSides: PaddingValuesSides, | ||
) : PaddingValues { | ||
override fun calculateBottomPadding(): Dp { | ||
return if (!excludeSides.hasAny(PaddingValuesSides.Bottom)) { | ||
values.calculateBottomPadding() | ||
} else { | ||
Dp.Hairline | ||
} | ||
} | ||
|
||
override fun calculateLeftPadding(layoutDirection: LayoutDirection): Dp { | ||
return if (!excludeSides.hasAny(PaddingValuesSides.Left)) { | ||
values.calculateLeftPadding(layoutDirection) | ||
} else { | ||
Dp.Hairline | ||
} | ||
} | ||
|
||
override fun calculateRightPadding(layoutDirection: LayoutDirection): Dp { | ||
return if (!excludeSides.hasAny(PaddingValuesSides.Right)) { | ||
values.calculateRightPadding(layoutDirection) | ||
} else { | ||
Dp.Hairline | ||
} | ||
} | ||
|
||
override fun calculateTopPadding(): Dp { | ||
return if (!excludeSides.hasAny(PaddingValuesSides.Top)) { | ||
values.calculateTopPadding() | ||
} else { | ||
Dp.Hairline | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters