-
Notifications
You must be signed in to change notification settings - Fork 4
KompotConfig
This class configures the behaviour of the Kompot framework. You assign it in the fragment that will be a host of the Kompot's screens and flows:
class AppKompotFragment : KompotFragment() {
override fun config(): KompotConfig = KompotConfig(
rootFlow = RootFlowImpl(),
)
}
data class KompotConfig(
val rootFlow: RootFlow<*, *>,
@LayoutRes val defaultFlowLayout: Int? = R.layout.base_flow_container,
val trimCacheThreshold: Int = DEFAULT_TRIM_CACHE_THRESHOLD,
val savedStateEnabled: Boolean = true,
val fullScreenEnabled: Boolean = true,
)
rootFlow
→ an instance of a root flow of your app
defaultFlowLayout
→ Flow hosts sequences of screens and therefore needs to have a container that will be a parent for those screens. defaultFlowLayout
is a resource id of the XML layout that will be used by default for all flows opened with the framework. If no layout is specified, then R.layout.base_flow_container
will be used by default for the flows. You can override a flow layout by specifying layout id for your flow:
override val layoutId = R.layout.flow_bridge_root
trimCacheThreshold
→ Framework caches screens and flows that are visible on the screen or reside in the back stack (if a default cache strategy for the screen is not overwritten). To limit the number of screens and flows that the framework keeps in a cache, you need to specify trimCacheThreshold. If a number of opened components exceeds this limit, the oldest screens will be cleared from a cache. In that way, a framework will keep the size of cache less or equal to trimCacheThreshold.
savedStateEnabled
→ denotes if the Kompot framework should restore the state of flows and screens when a parent fragment is restored from the saved state. true
by default
fullScreenEnabled
→ whether the framework should configure an activity window for a fullscreen. true
by default.