Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Another option is to provide a setContent
like API specifically for Fragments.
E.g., an extension like:
fun Fragment.content(content: @Composable () -> Unit): ComposeView {
return ComposeView(requireContext()).apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent(content)
}
}
which would let you write a Fragment like:
class ExampleFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
) = content {
// Write your @Composable content here
val viewModel: ExampleViewModel = viewModel()
// or extract it into a separate, testable method
ExampleComposable(viewModel)
}
}
ha...@googlemail.com <ha...@googlemail.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit a066a43da39b518751bcbd5baed63decb657f3bb
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Jan 16 22:11:03 2024
Add Fragment Compose module in Androidx
Adding Fragment Compose module using the create_project.py script.
RelNote: n/a
Test: ./gradlew updateApi
Bug: 258046948
Change-Id: Ia35d149c8ab0d78331206accf53e25a717f97291
M docs-tip-of-tree/build.gradle
A fragment/fragment-compose/api/current.txt
A fragment/fragment-compose/api/res-current.txt
A fragment/fragment-compose/api/restricted_current.txt
A fragment/fragment-compose/build.gradle
A fragment/fragment-compose/src/main/java/androidx/fragment/androidx-fragment-fragment-compose-documentation.md
M settings.gradle
https://android-review.googlesource.com/2912225
Branch: androidx-main
commit a066a43da39b518751bcbd5baed63decb657f3bb
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Jan 16 22:11:03 2024
Add Fragment Compose module in Androidx
Adding Fragment Compose module using the create_project.py script.
RelNote: n/a
Test: ./gradlew updateApi
Bug: 258046948
Change-Id: Ia35d149c8ab0d78331206accf53e25a717f97291
M docs-tip-of-tree/build.gradle
A fragment/fragment-compose/api/current.txt
A fragment/fragment-compose/api/res-current.txt
A fragment/fragment-compose/api/restricted_current.txt
A fragment/fragment-compose/build.gradle
A fragment/fragment-compose/src/main/java/androidx/fragment/androidx-fragment-fragment-compose-documentation.md
M settings.gradle
il...@google.com <il...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 561cb75bdf7e971f0ba2dec3cdc3286e1b415ecf
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Jan 16 23:53:00 2024
Add Fragment.content extension
Provides an easy integration for providing Compose content inside of a
Fragment that sets the ComposeView and ViewCompositionStrategy.
RelNote: "The new Fragment Compose module provides a Fragment.content
extension function to handle setting a Fragment's view in Compose."
Test: added test
Bug: 258046948
Change-Id: Ia166527918517593e94bcae239ff714df4dc00ad
M fragment/fragment-compose/api/current.txt
M fragment/fragment-compose/api/restricted_current.txt
M fragment/fragment-compose/build.gradle
A fragment/fragment-compose/src/androidTest/AndroidManifest.xml
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/FragmentTest.kt
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/test/TestActivity.kt
A fragment/fragment-compose/src/androidTest/res/layout/activity_main.xml
A fragment/fragment-compose/src/main/java/androidx/fragment/compose/Fragment.kt
https://android-review.googlesource.com/2911416
Branch: androidx-main
commit 561cb75bdf7e971f0ba2dec3cdc3286e1b415ecf
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Jan 16 23:53:00 2024
Add Fragment.content extension
Provides an easy integration for providing Compose content inside of a
Fragment that sets the ComposeView and ViewCompositionStrategy.
RelNote: "The new Fragment Compose module provides a Fragment.content
extension function to handle setting a Fragment's view in Compose."
Test: added test
Bug: 258046948
Change-Id: Ia166527918517593e94bcae239ff714df4dc00ad
M fragment/fragment-compose/api/current.txt
M fragment/fragment-compose/api/restricted_current.txt
M fragment/fragment-compose/build.gradle
A fragment/fragment-compose/src/androidTest/AndroidManifest.xml
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/FragmentTest.kt
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/test/TestActivity.kt
A fragment/fragment-compose/src/androidTest/res/layout/activity_main.xml
A fragment/fragment-compose/src/main/java/androidx/fragment/compose/Fragment.kt
bo...@gmail.com <bo...@gmail.com> #5
This has been fixed internally and will be available in the Fragment 1.7.0-alpha09
release.
il...@google.com <il...@google.com>
il...@google.com <il...@google.com> #6
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.wear.protolayout:protolayout-material-core:1.1.0-rc01
androidx.wear.tiles:tiles-tooling:1.3.0-rc01
androidx.wear.tiles:tiles-tooling-preview:1.3.0-rc01
lb...@gmail.com <lb...@gmail.com> #7
@6 Can't confirm. Seems it still exists. Here:
Description
Library version: 1.0.0-alpha03
When setting a new NavGraph to NavController, the back stack is not resetted.
From the documentation, "Any current navigation graph data will be replaced."
If a NavGraph is already setted then the back stack containts the default destination. In calling NavGraph.setGraph(NavGraph) and in the new graph, the destination is different, then the new destination is not displayed because back stack is not resetted.
Is it expected feature or not?