这是indexloc提供的服务,不要输入任何密码
Skip to content

Hold reference to scope in AppState #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libraryVersion.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# limitations under the License.
#
groupId=com.tunjid.treenav
treenav_version=0.0.13a
strings_version=0.0.13a
compose_version=0.0.13a
treenav_version=0.0.14
strings_version=0.0.14
compose_version=0.0.14
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,8 @@ fun App(
}
},
) {
val filteredPaneOrder by remember {
derivedStateOf { appState.filteredPaneOrder(this) }
}
appState.splitLayoutState.visibleCount = filteredPaneOrder.size
appState.panedNavHostScope = this
appState.splitLayoutState.visibleCount = appState.filteredPaneOrder.size
SplitLayout(
state = appState.splitLayoutState,
modifier = Modifier
Expand All @@ -190,7 +188,7 @@ fun App(
)
},
itemContent = { index ->
val pane = filteredPaneOrder[index]
val pane = appState.filteredPaneOrder[index]
Destination(pane)
if (pane == ThreePane.Primary) Destination(ThreePane.TransientPrimary)
}
Expand Down Expand Up @@ -275,6 +273,7 @@ class AppState(
)
private val paneInteractionSourceList = mutableStateListOf<MutableInteractionSource>()
private val paneRenderOrder = listOf(
ThreePane.Tertiary,
ThreePane.Secondary,
ThreePane.Primary,
)
Expand All @@ -294,11 +293,12 @@ class AppState(
internal val isPreviewingBack
get() = !backPreviewState.progress.isNaN()

fun filteredPaneOrder(
panedNavHostScope: PanedNavHostScope<ThreePane, SampleDestination>
): List<ThreePane> {
val order = paneRenderOrder.filter { panedNavHostScope.nodeFor(it) != null }
return order
internal var panedNavHostScope by mutableStateOf<PanedNavHostScope<ThreePane, SampleDestination>?>(
null
)

val filteredPaneOrder: List<ThreePane> by derivedStateOf {
paneRenderOrder.filter { panedNavHostScope?.nodeFor(it) != null }
}

fun setTab(destination: SampleDestination.NavTabs) {
Expand Down