-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
CrossAxisAlignment
modifier available for items within LazyList
- Loading branch information
Showing
10 changed files
with
104 additions
and
33 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
30 changes: 30 additions & 0 deletions
30
...layout-compose/src/commonMain/kotlin/app/cash/redwood/lazylayout/compose/LazyItemScope.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,30 @@ | ||
/* | ||
* Copyright (C) 2023 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package app.cash.redwood.lazylayout.compose | ||
|
||
import androidx.compose.runtime.Stable | ||
import app.cash.redwood.LayoutScopeMarker | ||
import app.cash.redwood.Modifier | ||
import app.cash.redwood.layout.api.CrossAxisAlignment | ||
|
||
@LayoutScopeMarker | ||
public interface LazyItemScope { | ||
@Stable | ||
public fun Modifier.alignment(alignment: CrossAxisAlignment): Modifier = | ||
then(AlignmentImpl(alignment)) | ||
} | ||
|
||
internal object LazyItemScopeImpl : LazyItemScope |
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
19 changes: 19 additions & 0 deletions
19
...-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/lazylayout/compose/modifier.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,19 @@ | ||
package app.cash.redwood.lazylayout.compose | ||
|
||
import app.cash.redwood.layout.api.CrossAxisAlignment | ||
import app.cash.redwood.layout.modifier.Alignment | ||
|
||
internal class AlignmentImpl( | ||
override val alignment: CrossAxisAlignment, | ||
) : Alignment { | ||
override fun equals(other: Any?): Boolean = other is Alignment | ||
&& other.alignment == alignment | ||
|
||
override fun hashCode(): Int { | ||
var hash = 17 | ||
hash = 31 * hash + alignment.hashCode() | ||
return hash | ||
} | ||
|
||
override fun toString(): String = """Alignment(alignment=$alignment)""" | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...ut.view_ViewLazyListTest_layoutWithMarginAndDifferentAlignments[LTR,Column].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ut.view_ViewLazyListTest_layoutWithMarginAndDifferentAlignments[RTL,Column].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.