{"id":28408722,"url":"https://github.com/ssseasonnn/butterfly","last_synced_at":"2025-06-30T04:32:50.392Z","repository":{"id":50722898,"uuid":"452103571","full_name":"ssseasonnn/Butterfly","owner":"ssseasonnn","description":"Butterfly is a navigation framework based on Coroutine + Annotation + Ksp. Support navigation for Activity, Fragment, DialogFragment and Compose.","archived":false,"fork":false,"pushed_at":"2024-05-31T08:15:01.000Z","size":676,"stargazers_count":222,"open_issues_count":3,"forks_count":17,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-02T12:42:52.519Z","etag":null,"topics":["android","component","coroutines","kotlin","navigation"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ssseasonnn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-26T01:38:57.000Z","updated_at":"2025-05-16T09:14:33.000Z","dependencies_parsed_at":"2023-12-01T10:24:03.765Z","dependency_job_id":"5244aa4b-e2d9-48a0-acc0-44fdcb5aa86b","html_url":"https://github.com/ssseasonnn/Butterfly","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/ssseasonnn/Butterfly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssseasonnn%2FButterfly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssseasonnn%2FButterfly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssseasonnn%2FButterfly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssseasonnn%2FButterfly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssseasonnn","download_url":"https://codeload.github.com/ssseasonnn/Butterfly/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssseasonnn%2FButterfly/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262710165,"owners_count":23351945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","component","coroutines","kotlin","navigation"],"created_at":"2025-06-02T04:10:45.697Z","updated_at":"2025-06-30T04:32:50.383Z","avatar_url":"https://github.com/ssseasonnn.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](Butterfly.png)\n\n[![](https://jitpack.io/v/ssseasonnn/Butterfly.svg)](https://jitpack.io/#ssseasonnn/Butterfly)\n\n# Butterfly\n\n*Read this in other languages: [中文](README.zh.md), [English](README.md), [Change Log](CHANGELOG.md)*\n\nButterfly is a versatile component-based navigation framework based on `Coroutine + Annotation + Ksp`.\nNot only does it support navigation for Activity, Fragment, and DialogFragment, but it also supports navigation for Compose pages.\n\nButterfly supports configuring startup modes for Fragment and Composite navigation, including Standard mode navigation\nClearTop clears stack top mode navigation and SingleTop reuse mode navigation.\n\nButterfly provides a unified fallback stack for managing all types of page navigation, using standard fallback APIs to reduce developer workload.\n\nButterfly also provides a powerful framework for inter component communication, allowing for true component decoupling without any dependencies between components.\n\n\n## Feature List\n\nThe butterfly provides these features：\n\n✅ Support navigation to Activity \u003cbr\u003e\n✅ Support navigation to Fragment \u003cbr\u003e\n✅ Support navigation to DialogFragment \u003cbr\u003e\n✅ Support navigation to Compose \u003cbr\u003e\n✅ Support navigation to Action \u003cbr\u003e\n✅ Support parameter transfer and parse \u003cbr\u003e\n✅ Support interceptor \u003cbr\u003e\n✅ Support backstack \u003cbr\u003e\n✅ Support group manage \u003cbr\u003e\n✅ Support launch mode，such as SingleTop、ClearTop \u003cbr\u003e\n✅ Support component communicate \u003cbr\u003e\n\n## Installation\n\n```kotlin\n// Add jitpack repository\nrepositories {\n  maven { url(\"https://jitpack.io\") }\n}\n```\n\n```kotlin\n// First, declare the KSP plugin in your top level build.gradle.kts file.\nplugins {\n    id(\"com.google.devtools.ksp\") version \"1.8.10-1.0.9\" apply false\n}\n\n// Then, enable KSP in your module-level build.gradle.kts file:\nplugins {\n    id(\"com.google.devtools.ksp\")\n}\n\n\n// Then, add Butterfly dependencies.\ndependencies {\n  implementation(\"com.github.ssseasonnn.Butterfly:butterfly:1.3.0\")\n  ksp(\"com.github.ssseasonnn.Butterfly:compiler:1.3.0\")\n\n  //for compose\n  implementation(\"com.github.ssseasonnn.Butterfly:butterfly-compose:1.3.0\")\n}\n```\n\n## Basic Usage\n\n### Navigation\n\nButterfly support navigation for Activity、Fragment and DialogFragment and Compose component.\n\n```kotlin\n@Destination(\"test/activity\")\nclass TestActivity : AppCompatActivity()\n\n@Destination(\"test/fragment\")\nclass TestFragment : Fragment()\n\n@Destination(\"test/dialog\")\nclass TestDialogFragment : DialogFragment()\n\n@Destination(\"test/compose\")\n@Composable\nfun HomeScreen() {}\n\n//Navigation\nButterfly.of(context).navigate(\"test/xxx\")\n\n//Navigation and get result\nButterfly.of(context).navigate(\"test/xxx\") {\n    val result = it.getStringExtra(\"result\")\n    binding.tvResult.text = result\n}\n```\n\n### Communication\n\nButterfly implements component-based communication through `Evade` and `EvadeImpl` \nannotations. And the communication between components without any dependence \nis supported by dynamic agent technology.\n\nFor example, two components, `Home` and `Dashboard`, component `Dashboard` need to call the method in the component `Home`:\n\n```mermaid\nflowchart TD\n\tA(Main App) --\u003e B(Component Home)\n\tA(Main App) --\u003e C(Component Dashboard)\n```\n\n```kotlin\n//Define the Api that needs to access the Home in the component Dashboard and add the @ Evade annotation\n@Evade\ninterface DashboardCallHomeApi {\n    fun showHome(fragmentManager: FragmentManager, container: Int)\n}\n\n\n//Implement the corresponding Api in the component Home and add the @ EvadeImpl annotation\n@EvadeImpl\nclass DashboardCallHomeApiImpl {  //The implementation class name must end with Impl\n    val TAG = \"home_tag\"\n\n    //For the implementation of HomeApi, the method name and parameters must be the same\n    fun showHome(fragmentManager: FragmentManager, container: Int) {\n        val homeFragment = HomeFragment()\n        fragmentManager.beginTransaction()\n            .replace(container, homeFragment, TAG)\n            .commit()\n    }\n}\n\n//You can then invoke the interface in the component Home in the component Dashboard:\nval dashboardCallHomeApi = Butterfly.evade\u003cDashboardCallHomeApi\u003e()\ndashboardCallHomeApi.showHome(supportFragmentManager, R.id.container)\n```\n\n## Documentation\n\nSee examples and browse complete documentation at the Butterfly Wiki: [wiki](https://github.com/ssseasonnn/Butterfly/wiki)\n\nIf you still have questions, feel free to create a new issue.\n\n\n## License\n\n\u003e ```\n\u003e Copyright 2022 Season.Zlc\n\u003e\n\u003e Licensed under the Apache License, Version 2.0 (the \"License\");\n\u003e you may not use this file except in compliance with the License.\n\u003e You may obtain a copy of the License at\n\u003e\n\u003e    http://www.apache.org/licenses/LICENSE-2.0\n\u003e\n\u003e Unless required by applicable law or agreed to in writing, software\n\u003e distributed under the License is distributed on an \"AS IS\" BASIS,\n\u003e WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\u003e See the License for the specific language governing permissions and\n\u003e limitations under the License.\n\u003e ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssseasonnn%2Fbutterfly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssseasonnn%2Fbutterfly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssseasonnn%2Fbutterfly/lists"}