All Projects → hakobast → Flowzard

hakobast / Flowzard

Isolates navigation from UI and Business logic with simple wizard like mechanism.

Programming Languages

kotlin
9241 projects
flow
126 projects

Projects that are alternatives of or similar to Flowzard

go router
The purpose of the go_router for Flutter is to use declarative routes to reduce complexity, regardless of the platform you're targeting (mobile, web, desktop), handling deep linking from Android, iOS and the web while still allowing an easy-to-use developer experience.
Stars: ✭ 380 (+675.51%)
Mutual labels:  router, navigation
Hybrid Navigation
React Native Navigation that supports seamless navigation between Native and React.
Stars: ✭ 258 (+426.53%)
Mutual labels:  router, navigation
react-native-boilerplate
Ready-made structure of your next React Native application within a few minutes.
Stars: ✭ 36 (-26.53%)
Mutual labels:  router, navigation
Parrot
Web router specially designed for building SPAs using Meteor
Stars: ✭ 75 (+53.06%)
Mutual labels:  router, navigation
Auto route library
Flutter route generator
Stars: ✭ 434 (+785.71%)
Mutual labels:  router, navigation
Helm
A graph-based SwiftUI router
Stars: ✭ 64 (+30.61%)
Mutual labels:  router, navigation
browser
Routing and Navigation for browser apps
Stars: ✭ 31 (-36.73%)
Mutual labels:  router, navigation
Android Router
An android componentization protocol framework, used for decoupling complex project. Android高性能轻量级路由框架
Stars: ✭ 208 (+324.49%)
Mutual labels:  router, navigation
Route Composer
Protocol oriented, Cocoa UI abstractions based library that helps to handle view controllers composition, navigation and deep linking tasks in the iOS application. Can be used as the universal replacement for the Coordinator pattern.
Stars: ✭ 362 (+638.78%)
Mutual labels:  router, navigation
React Native Simple Router
A community maintained router component for React Native
Stars: ✭ 266 (+442.86%)
Mutual labels:  router, navigation
qlevar router
Manage you project Routes. Create nested routes. Simply navigation without context to your pages. Change only one sub widget in your page when navigating to new route.
Stars: ✭ 51 (+4.08%)
Mutual labels:  router, navigation
React Router Navigation
⛵️ A complete navigation library for React Native, React DOM and React Router
Stars: ✭ 498 (+916.33%)
Mutual labels:  router, navigation
Swiftuirouter
Routing in SwiftUI
Stars: ✭ 242 (+393.88%)
Mutual labels:  router, navigation
navigation-skeleton
This component allows you to show skeletons of pages during navigation process.
Stars: ✭ 16 (-67.35%)
Mutual labels:  router, navigation
Marshroute
Marshroute is an iOS Library for making your Routers simple but extremely powerful
Stars: ✭ 208 (+324.49%)
Mutual labels:  router, navigation
universal-router
↩️ Router for every occasions
Stars: ✭ 64 (+30.61%)
Mutual labels:  router, navigation
React Router Native Stack
A stack navigation component for react-router-native
Stars: ✭ 171 (+248.98%)
Mutual labels:  router, navigation
Arouter
💪 A framework for assisting in the renovation of Android componentization (帮助 Android App 进行组件化改造的路由框架)
Stars: ✭ 13,587 (+27628.57%)
Mutual labels:  router, navigation
Frontexpress
An Express.js-Style router for the front-end
Stars: ✭ 263 (+436.73%)
Mutual labels:  router, navigation
Router
🛣 Simple Navigation for iOS
Stars: ✭ 438 (+793.88%)
Mutual labels:  router, navigation

Flowzard

Download Android Weekly Android Arsenal

Features

Isolates navigation from UI and Business logic by providing simple navigation mechanism.

Encapsulates exact implementation. It means navigation can be organized across Activities, Fragments or Views.

Survives configuration changes, can save his state and restore after process kill.

Usage

Gradle:

implementation 'com.github.hakobast:flowzard:0.1'

Create flows.

object Flows {
	const val LOGIN = "login"
}

class MainFlow(flowManager: FlowManager) : Flow(flowManager) {

	override fun onMessage(code: String, message: Any) {
		super.onMessage(code, message)
		if(code == "main" && message == "login"){
		    newFlow(Flows.LOGIN)
		} 
	}
}

class LoginFlow(flowManager: FlowManager) : Flow(flowManager) {

    override fun onCreate(savedInstance: DataBunch?, data: DataBunch?) {
        super.onCreate(savedInstance, data)
        router.navigateTo("sign-up")
    }
    
	override fun onMessage(code: String, message: Any) {
		super.onMessage(code, message)
		if(code == "sign-up"){
		    when(message){
		        "complete" -> endFlow()
		        "have-account" -> router.navigateTo("login")
		    }
		}else if(code == "login" && message == "complete"){
		    endFlow()
		}
	}
}

Extend Flow manager

class DefaultFlowManager : FlowManager() {

	override fun createMainFlow(): Flow {
		return MainFlow(this)
	}

	override fun createFlow(id: String): Flow {
		return when (id) {
			Flows.LOGIN -> LoginFlow(this)
			else -> throw RuntimeException("Cannot find flow for id=$id")
		}
	}
}

and provide it in Application class.

class App : Application(), FlowManagerProvider {
    private val flowManager = DefaultFlowManager() 
    override fun getProvideManager(): FlowManager {
        return flowManager
    }
}

Create flow Activity.

class MainActivity : FlowActivity() {

    override val navigator: Navigator
        get() = object : SimpleFlowNavigator(this) {

            override fun getActivityIntent(id: String, data: Any?): Intent {
                return when (id) {
                    Flows.LOGIN -> Intent(activity, LoginActivity::class.java)
                    else -> throw RuntimeException("Cannot find activity for id=$id")
                }
            }
        }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        loginButton.setOnClickListener {
            flow.sendMessage("main", "login")
        }
    }
}

By default library provides FlowActivity.kt to easily integrate flowzard via activities.

Flowzard functionality

Flow provides navigation(with results) across flows.

protected fun newFlow(id: String, requestCode: Int? = null, data: Any? = null) // creates new flow
protected fun endFlow(result: Result? = null) // finishes current flow
protected open fun onFlowResult(requestCode: Int, result: Result) // receives result from flow 

Flow also lets screens to send/receive messages to/from flow.

protected fun sendMessageFromFlow(code: String, message: Any) // send message to screen.
protected open fun onMessage(code: String, message: Any) // receives result from screen.
fun sendMessage(code: String, message: Any) // send message from screen.
fun setMessageListener(code: String, listener: MessageHandler) // register to messages in screen.
fun removeMessageListener(code: String) // unregister from messages in screen.

Navigation in flow between screens via Router using kotlin version of Cicerone.

fun navigateTo(screenKey: String, data: Any? = null) // adds new screen to backstack
fun replace(screenKey: String, data: Any? = null) // replaces current screen with new one
fun add(screenKey: String, data: Any? = null) // adds new screen
fun setTo(screenKey: String, data: Any? = null) // clears backstack and adds new screen to it
fun exit() // clears backstack
fun backTo(screenKey: String) // pops backstack until screen.
fun back() // pops backstack

Surviving configuration changes and process death

The Api built having in mind configuration change and process death problems. Flows survive configuration changes and restores its state when process dies.

Sample projects

Contact

Thanks

  • Special thanks to guys who created Cicerone for big inspiration.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].