Closed iainism closed 3 months ago
Good day.
do you have some additional details, like the snippet of code you try to execute?
The LibsSupportFragment
is part of the aboutlibraries
module which you include: https://github.com/mikepenz/AboutLibraries/blob/develop/aboutlibraries/src/main/java/com/mikepenz/aboutlibraries/ui/LibsSupportFragment.kt#L42
Which is built with the LibsBuilder
and returned via the supportFragment
API:
https://github.com/mikepenz/AboutLibraries/blob/develop/aboutlibraries/src/main/java/com/mikepenz/aboutlibraries/LibsBuilder.kt#L416
Used like this: https://github.com/mikepenz/AboutLibraries/blob/develop/app/src/main/java/com/mikepenz/aboutlibraries/sample/FragmentActivity.kt#L163-L170C74
Hi, thank you for the fast reply.
I have this:
class AboutLibsFragment : LibsSupportFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
with(Bundle()) {
putSerializable("data", LibsBuilder())
val fragment = LibsBuilder()
.withVersionShown(true)
.withLicenseShown(true)
.withLicenseDialog(true)
.supportFragment()
val fragmentManager = requireActivity().supportFragmentManager
fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit()
return libsFragmentCompat.onCreateView(inflater.context, inflater, container, savedInstanceState, this) //libsFragmentCompat is unresolved
}
}
}
Hmm it looks you are wrapping the fragment in a fragment.
The module already exposes a navigation target: https://github.com/mikepenz/AboutLibraries/blob/803e72afb8549a5d3f6e501d5cff58e9b69b22e3/aboutlibraries/src/main/res/navigation/aboutlibs_navigation.xml#L2
which takes the LibsBuilder
as an argument.
So none of the above code would be required
OK, so is it possible to create the LibsBuilder
in another fragment to configure it, and then pass it with SafeArgs?
*by "to configure it", I mean to get equivalent to the following:
val fragment = LibsBuilder()
.withVersionShown(true)
.withLicenseShown(true)
.withLicenseDialog(true)
.supportFragment()
yes. you can use the navigation target in your nav graph, and then navigate to it just by passing in the LibsBuiler
.
val libsBuilder = LibsBuilder()
.withVersionShown(true)
.withLicenseShown(true)
.withLicenseDialog(true)
Hi, sorry, I've simply not managed to get my AboutLibsFragment
to show any content, and I'm now out of ideas. (I know it should be straightforward, somehow I'm just not getting it though!) :shrug:
At the moment, in the fragment (AboutFragment
) where the user may select to view the AboutLibsFragment
I have:
override fun navigateToAboutLibs(v: View) {
val data = LibsBuilder()
.withVersionShown(true)
.withLicenseShown(true)
.withLicenseDialog(true)
val action = AboutFragmentDirections.aboutLibsFragment(data)
v.findNavController().navigate(action)
}
Which is my attempt to pass the LibsBuilder
in. Can you please provide a snippet that shows how to use the LibsBuilder
in context?
The MaterialDrawer
library sample app has a NavController
and navigates to the aboutlibraries fragment:
It includes the aboutlibs destination in the nav graph: https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/res/navigation/navigation.xml#L64
and then navigates to it providing the LibsBuilder
(as Serializeable) as data
when navigating
About this issue
I'm trying to reboot an old project (no compose, and first built not long after Jetpack was released), and have in the past used code similar to:
https://github.com/mikepenz/AboutLibraries/pull/531/files#diff-d63c8456e793a2f644e6d36c804b7904baea2c5df547c67b78925e5ce1333858R11
To use About Libraries with Navigation.
I have so far worked out that I need to now
requireActvity().supportFragmentManager
before being able to resolve,supportFragmentManager
. However, I haven't yet worked out how I can getlibsFragmentCompat
to resolve. Can anyone help please?I guess I am missing a dependency, so far I have:
Details
Checklist