Android
How to add a new screen
Appkit allows to add extra screens to generic main screen flow. This is useful when you want to add a new feature to the app that is not part of the main flow.
Create a new screen
To create a new screen, you need to create a class that implements the Screen
interface.
class MyScreen : Screen {
override val id: Int = 0
override val analyticsName: String = "MyScreen"
override val name: TextRes = TextRes.Resource(R.string.my_screen_name)
override val iconResId: Int = R.drawable.ic_my_screen
override val fragment: (Context) -> Fragment = {
MyFragment()
}
override val order: Int = 0
}
Create a new TapProvider
to expose the new screen to the Appkit
To expose the new screen to the Appkit, you need to create a new ScreenProvider
that will provide the
new screen.
class MyScreenProvider : ScreenProvider {
val screens: List<Screen> = listOf(MyScreen())
}
Add the new screen to the SdkInitializer
To add the new screen to the Appkit, you need to add the new ScreenProvider
to the SdkInitializer
.
context.installHumaSdk(
appkit {
// Add the new screen provider to a set of existing screen providers
addScreenProviders(MyScreenProvider())
// or replace the existing screen providers with the new one
setScreenProviders(MyScreenProvider())
}
)
How to control the order of screens
Set the order of screens in the Screen
implementation
You can control the order of screens by setting the order
property of the screen. The screen with the
lowest order will be displayed first.
class MyScreen : Screen {
// other properties
override val order: Int = 0
}
Set the order of screens in the ScreenOrderProvider
implementation
You can control the order of screens by setting the order in the ScreenOrderProvider
implementation.
class MyScreenOrderProvider : ScreenOrderProvider {
fun orderScreens(screens: List<Screen>): List<Screen> {
return screens.sortedBy { your_ordering_logic }
}
}
Add the new ScreenOrderProvider
to the SdkInitializer
To add the new ScreenOrderProvider
to the Appkit, you need to add it to the SdkInitializer
.
context.installHumaSdk(
appkit {
screenOrderProvider = MyScreenOrderProvider()
}
)