https://github.com/mvojtkovszky/singleactivitynavigation
A single activity application framework with straightforward navigation controls, allowing seamless movement between fragments through different containers using a single line of code.
https://github.com/mvojtkovszky/singleactivitynavigation
android android-library android-navigation kotlin kotlin-android single-activity single-activity-pattern
Last synced: 2 days ago
JSON representation
A single activity application framework with straightforward navigation controls, allowing seamless movement between fragments through different containers using a single line of code.
- Host: GitHub
- URL: https://github.com/mvojtkovszky/singleactivitynavigation
- Owner: mvojtkovszky
- License: apache-2.0
- Created: 2020-10-21T11:23:58.000Z (over 4 years ago)
- Default Branch: develop
- Last Pushed: 2024-11-05T10:41:07.000Z (6 months ago)
- Last Synced: 2025-04-03T19:03:37.037Z (24 days ago)
- Topics: android, android-library, android-navigation, kotlin, kotlin-android, single-activity, single-activity-pattern
- Language: Kotlin
- Homepage:
- Size: 7.15 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# SingleActivityNavigation
A single activity application framework with straightforward navigation controls, allowing seamless
movement between fragments through different containers using a single line of code.
## How does it work?
Your (single) activity must extend from BaseSingleActivity and all your fragments extend from BaseSingleFragment.
Then you can simply move between fragments from either activity or fragment.``` kotlin
// take any fragment(s) of your choosing
val myFragment = MyFragment()// multiple ways to navigate through back stack
// notice how we can use same fragment and seamlessly put it into any container
navigateBack()
navigateBackTo("fragment name")
navigateBackToRoot()
navigateTo(myFragment)
navigateToRoot(myFragment)
navigateToBottomSheed(myFragment)
navigateToDialog(myFragment)
dismissOpenBottomSheet()
dismissOpenDialog()
```
Make use of many convenience methods to help you control the state of your app
``` kotlin
getCurrentFragment()?.let {
when (it.fragmentType) {
// this fragment is root, came into existence with navigateToRoot() call
FragmentType.ROOT -> TODO()
// this fragment is default, came into existence with navigateTo() call, no special flags
FragmentType.DEFAULT -> TODO()
// this fragment is also default, but was flagged as modal during navigateTo() call
FragmentType.MODAL -> TODO()
// this fragment is a dialog, came into existence with navigateToDialog() call
FragmentType.DIALOG -> TODO()
// this fragment is a dialog, came into existence with navigateToBottomSheet() call
FragmentType.BOTTOM_SHEET -> TODO()
}
}
```
Let the fragment define behavioural patterns of it's own by overriding open properties:
``` kotlin
open val isModal: Boolean
open val mustBeValidToInvokeNavigation: Boolean
open val overridesBackPress: Boolean
open val animationEnter: Int
open val animationExit: Int
open val animationPopEnter: Int
open val animationPopExit: Int
```
And much more:
* Master/detail implementation support.
* Safe instance state recreation.
* Custom transition animations based on fragment type.
* Make sure to check out example app to help you get started.## Nice! How do I get started?
Make sure root build.gradle repositories include JitPack
``` gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```And SingleActivityNavigation dependency is added to app build.gradle
``` gradle
dependencies {
implementation 'com.github.mvojtkovszky:SingleActivityNavigation:$latest_version'
}
```