{"id":13610104,"url":"https://github.com/inshiro/skate","last_synced_at":"2025-04-12T22:32:48.161Z","repository":{"id":149561961,"uuid":"175593657","full_name":"inshiro/skate","owner":"inshiro","description":"Android fragment stack controller","archived":false,"fork":false,"pushed_at":"2019-03-23T03:21:35.000Z","size":163,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-01T19:54:20.660Z","etag":null,"topics":["android","fragment","kotlin"],"latest_commit_sha":null,"homepage":null,"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/inshiro.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2019-03-14T09:51:57.000Z","updated_at":"2022-10-03T16:44:18.000Z","dependencies_parsed_at":"2024-04-19T12:15:40.347Z","dependency_job_id":null,"html_url":"https://github.com/inshiro/skate","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inshiro%2Fskate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inshiro%2Fskate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inshiro%2Fskate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inshiro%2Fskate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inshiro","download_url":"https://codeload.github.com/inshiro/skate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223549117,"owners_count":17163600,"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","fragment","kotlin"],"created_at":"2024-08-01T19:01:41.224Z","updated_at":"2024-11-07T16:30:40.481Z","avatar_url":"https://github.com/inshiro.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# Skate\n[![Release](https://jitpack.io/v/inshiro/skate.svg)](https://jitpack.io/#inshiro/skate) [![GitHub license](https://img.shields.io/badge/license-Apache_2-blue.svg)](LICENSE) [![Platform](https://img.shields.io/badge/platform-AndroidX-green.svg)](https://developer.android.com/jetpack/androidx) [![Kotlin](https://img.shields.io/badge/Kotlin-1.3.21-orange.svg)](https://kotlinlang.org)\n\n\nSkate is a fragment manager controller that allows you to easily navigate from one fragment to another. Simple and seamless. Just like it should be. \n\n`FragmentManager` has an unfriendly behavior to work with so Skate uses its own stack and backstack to manage fragments. The stack is pushed or popped *only* when a fragment is *added* or *removed*. Otherwise, any modifications are applied accordingly. In my opinion, this should be the intended behavior. \n\n- No reflection\n- Add/attach/show | Remove/detach/hide fragments\n- Commit with state save\n- Save and restore flow\n- Listen to visibility changes\n- Lifecycle aware\n- Extremely lightweight and fast\n\n## Setup\n```gradle\nallprojects {\n    repositories {\n\t    maven { url 'https://jitpack.io' }\n    }\n}\n```\n```gradle\ndependencies {\n    implementation 'com.github.inshiro:skate:0.2.1'\n}\n```\n\n## Initialize\n```kotlin\nclass MainActivity : AppCompatActivity() {\n\n\tprivate lateinit var skate: Skate\n\t\n\toverride fun onCreate(savedInstanceState: Bundle?) {\n\t\tsuper.onCreate(savedInstanceState)\n\t\t\n\t\t// ...\n\t\t\n\t\tskate = startSkating(savedInstanceState)\n\t\tskate.fragmentManager = supportFragmentManager\n\t\tskate.container = R.id.main_container\n\t\tfragment.mode = Skate.SINGLETON // optional\n\t\n\t}\n\t\n\toverride fun onBackPressed() {\n\t\tif (!skate.back)\n\t\t    super.onBackPressed()\n\t}\n}\n```\n\n## Usages\n```kotlin\n// Showing\nfragment.show()\n\n// Hiding\nfragment.hide()\n\n// Navigating\nskate to fragment\n```\n\n### Modes\nSkate has 3 modes it operates on. The default is `FACTORY`. \n```kotlin\n// add-remove\nSkate.FACTORY = 0\n\n// attach-detach\nSkate.SPARING = 1\n\n// show-hide\nSkate.SINGLETON = 2\n```\nThe mode is obtained from `Fragment.mode` This determines the fragment's behavior on show or hide.\n\nIf you show, Skate will hide. Add, remove. etc...\n```kotlin\nfragment.mode = Skate.SINGLETON\n\nmainFragment.mode = Skate.SPARING\n```\n\n### Settings\nAt any given time you can set the global settings before showing or hiding a fragment.\n```kotlin\nskate.fragmentManager = supportFragmentManager\nskate.container = R.id.main_container // id of your view\n\n// Animations\nskate.animationStart = android.R.animator.fade_in\nskate.animationEnd = android.R.animator.fade_out\n```\n### Back stack\nBy default, fragments are added to the back stack. When going back, if there is currently a visible fragment, it gets hidden.\n### Listening\nTo listen to visibility changes, add an implementation of `Skate.OnNavigateListener` to `setOnNavigateListener`.\n```kotlin\nskate.setOnNavigateListener(object : Skate.OnNavigateListener {\n    override fun onHide() { }\n\n    override fun onShow() { }\n\n    override fun onBackPressed(current: Fragment?) { }\n})\n```\n### Operations\nSometimes you have lots of fragments you want to work with.\n```kotlin\nskate.operate {\n   hide(BillingFragment)\n   hide(PaymentFragment)\n   hide(DetailFragment1)\n   show(MainFragment)\n}\n```\n### Logging\nSkate provides a bit of information about fragment visibility during runtime which might help in debugging visibility-related issues. To enable logging, pass an implementation of `Skate.Logger` to the `Skate.logger` property or use the default `SkateLogger`.\n```kotlin\nSkate.logger = SkateLogger\n```\n\n## Activity Lifecycle\nIf your application requires a call to any of Skate's methods in an Activity lifecycle method other than `onCreate()`, do it in either `FragmentActivity#onResumeFragments()` or `Activity#onPostResume()`. These two methods are guaranteed to be called after the Activity has been restored to its original state, and therefore avoid the possibility of state loss all together.\n See this [blog](https://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html) for more detail.\n\n\nLicense\n-------\n\n    Copyright 2019 inshiro\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finshiro%2Fskate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finshiro%2Fskate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finshiro%2Fskate/lists"}