-
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 #70 from ltttttttttttt/dev
Dev
- Loading branch information
Showing
10 changed files
with
123 additions
and
40 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
53 changes: 53 additions & 0 deletions
53
.../compose_views/chain_scrollable_component/mode/ChainAfterContentNestedScrollConnection.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,53 @@ | ||
/* | ||
* Copyright lt 2023 | ||
* | ||
* 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 com.lt.compose_views.chain_scrollable_component.mode | ||
|
||
import androidx.compose.ui.geometry.Offset | ||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection | ||
import androidx.compose.ui.input.nestedscroll.NestedScrollSource | ||
import androidx.compose.ui.unit.Velocity | ||
import com.lt.compose_views.chain_scrollable_component.ChainScrollableComponentState | ||
import com.lt.compose_views.util.midOf | ||
|
||
/** | ||
* creator: lt 2022/9/29 [email protected] | ||
* effect : 对应[ChainMode.ChainAfterContent]的[NestedScrollConnection] | ||
* warning: | ||
*/ | ||
internal class ChainAfterContentNestedScrollConnection( | ||
val state: ChainScrollableComponentState, | ||
) : NestedScrollConnection { | ||
|
||
override fun onPostScroll( | ||
consumed: Offset, | ||
available: Offset, | ||
source: NestedScrollSource | ||
): Offset { | ||
val delta = if (state.orientationIsHorizontal) available.x else available.y | ||
val newOffset = state.getScrollPositionValue() + delta | ||
state.setScrollPosition(midOf(state.minPx, newOffset, state.maxPx)) | ||
return Offset.Zero | ||
} | ||
|
||
override suspend fun onPostFling(consumed: Velocity, available: Velocity): Velocity { | ||
val delta = if (state.orientationIsHorizontal) available.x else available.y | ||
if (state.callOnScrollStop(delta)) return super.onPostFling(consumed, available) | ||
val newOffset = state.getScrollPositionValue() + delta | ||
state.animateToScrollPosition(midOf(state.minPx, newOffset, state.maxPx)) | ||
return super.onPostFling(consumed, available) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,7 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
package com.lt.compose_views.chain_scrollable_component | ||
|
||
import androidx.compose.foundation.ExperimentalFoundationApi | ||
package com.lt.compose_views.chain_scrollable_component.mode | ||
|
||
/** | ||
* creator: lt 2022/9/29 [email protected] | ||
|
@@ -29,12 +27,17 @@ enum class ChainMode { | |
* 内容区域优先 | ||
* Content first | ||
*/ | ||
@ExperimentalFoundationApi//todo 暂时有问题,先不放开 | ||
ContentFirst, | ||
|
||
/** | ||
* 联动区域优先 | ||
* Chain content first | ||
*/ | ||
ChainContentFirst, | ||
|
||
/** | ||
* 内容区域无法滑动后联动区域再滑动 | ||
* Chain after content | ||
*/ | ||
ChainAfterContent, | ||
} |
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
Oops, something went wrong.