terrakok / Cicerone

🚦 Cicerone is a lightweight library that makes the navigation in an Android app easy.
Other
2.58k stars 218 forks source link

Feature/add new methods fragment 1.2.0 #110

Closed aasitnikov closed 4 years ago

aasitnikov commented 4 years ago

Closes #109

adolgiy commented 4 years ago

Amazed with this cool and simple implementation of FragmentFactory support!

class ProfileScreen(private val id: ProfileId) : SupportAppScreen() {

    override fun getFragmentParams() = ProfileFragment.params(id)
}

class ProfileFragment : Fragment() {
    companion object {
        private const val ID = "id"
        fun params(id: ProfileId) = FragmentParams(
            ProfileFragment::class.java,
            Bundle().apply { putString(ID, id.value) }
    }
}
aasitnikov commented 4 years ago

@adolgiy Glad to hear it) By the way, you can use bundleOf() from core-ktx for even more concise code: bundleOf(ID to id.value)