-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from ltttttttttttt/dev
Add NoInlineLayout
- Loading branch information
Showing
4 changed files
with
69 additions
and
28 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
41 changes: 41 additions & 0 deletions
41
compose_views/src/commonMain/kotlin/com/lt/compose_views/other/NoInlineLayout.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,41 @@ | ||
package com.lt.compose_views.other | ||
|
||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
|
||
/** | ||
* creator: lt 2022/11/19 lt.dygzs@qq.com | ||
* effect : 不内联的Layout布局,可以减少重组范围以减少不必要的重组,但会增加函数栈 | ||
* warning: 非必要情况请使用官方内联的Layout布局 | ||
*/ | ||
@Composable | ||
fun ColumnWithNoInline( | ||
modifier: Modifier = Modifier, | ||
verticalArrangement: Arrangement.Vertical = Arrangement.Top, | ||
horizontalAlignment: Alignment.Horizontal = Alignment.Start, | ||
content: @Composable ColumnScope.() -> Unit | ||
) { | ||
Column(modifier, verticalArrangement, horizontalAlignment, content) | ||
} | ||
|
||
@Composable | ||
fun BoxWithNoInline( | ||
modifier: Modifier = Modifier, | ||
contentAlignment: Alignment = Alignment.TopStart, | ||
propagateMinConstraints: Boolean = false, | ||
content: @Composable BoxScope.() -> Unit | ||
) { | ||
Box(modifier, contentAlignment, propagateMinConstraints, content) | ||
} | ||
|
||
@Composable | ||
fun RowWithNoInline( | ||
modifier: Modifier = Modifier, | ||
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start, | ||
verticalAlignment: Alignment.Vertical = Alignment.Top, | ||
content: @Composable RowScope.() -> Unit | ||
) { | ||
Row(modifier, horizontalArrangement, verticalAlignment, content) | ||
} |