
Enables support for diverse screen sizes and orientations through a unified API. Facilitates adaptive UI design, screen observation, and customizes status and navigation bar colors.
KMPWindowManager is available on mavenCentral().
implementation("io.github.abdelrahmanesam:KMPWindowManager:${latest-version}")// use WindowManagerViewControllerWrapper to start observing your ios changes
fun MainViewController(): WindowManagerViewControllerWrapper {
return App()
}// add observeScreenChanges in your onCreate
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
observeScreenChanges()
}
// clearScreenObserver in onDestroy
override fun onDestroy() {
super.onDestroy()
clearScreenObserver()
}@Composable
fun RootComposable(modifier: Modifier = Modifier) {
//start collecting your screenData and change it to adaptiveUIType
val screenData = screenData.collectAsStateWithLifecycle()
val adaptiveType =screenData.value?.toAdaptiveLayoutScreenType()
when (adaptiveType) {
is ScreenOnly -> {
FirstScreen(modifier = Modifier.fillMaxSize().background(color = Color.Cyan))
}
is ListOneThirdAndDetailThirds -> {
AdaptiveLayoutListOneThirdAndDetailTwoThirds(
firstComposable = {
FirstScreen(
modifier = Modifier.fillMaxSize().background(color = Color.Cyan)
)
},
secondComposable = {
SecondScreen(
modifier = Modifier.fillMaxSize().background(color = Color.Red)
)
}
)
}
is ListHalfAndDetailHalf -> {
AdaptiveLayoutListHalfAndDetailHalf(
firstComposable = {
FirstScreen(
modifier = Modifier.fillMaxSize().background(color = Color.Cyan)
)
},
secondComposable = {
SecondScreen(
modifier = Modifier.fillMaxSize().background(color = Color.Red)
)
}
)
}
is ListAndDetailStacked -> {
AdaptiveLayoutListAndDetailStacked(
firstComposable = {
FirstScreen(modifier = Modifier.fillMaxSize().background(color = Color.Cyan))
},
secondComposable = {
SecondScreen(modifier = Modifier.fillMaxSize().background(color = Color.Red))
}
)
}
else -> {
FirstScreen(modifier = Modifier.fillMaxSize().background(color = Color.Cyan))
}
}
}ChangeStatusBarColor(color = Color.Red)//note that due to limitations in ios you need to change your
// statusBarColor too if you need to change your home indicator color
// or your statusBarColor will be the same as your home indicator color
ChangeBottomNavigationColor(color = Color.Red)KMPWindowManager is available on mavenCentral().
implementation("io.github.abdelrahmanesam:KMPWindowManager:${latest-version}")// use WindowManagerViewControllerWrapper to start observing your ios changes
fun MainViewController(): WindowManagerViewControllerWrapper {
return App()
}// add observeScreenChanges in your onCreate
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
observeScreenChanges()
}
// clearScreenObserver in onDestroy
override fun onDestroy() {
super.onDestroy()
clearScreenObserver()
}@Composable
fun RootComposable(modifier: Modifier = Modifier) {
//start collecting your screenData and change it to adaptiveUIType
val screenData = screenData.collectAsStateWithLifecycle()
val adaptiveType =screenData.value?.toAdaptiveLayoutScreenType()
when (adaptiveType) {
is ScreenOnly -> {
FirstScreen(modifier = Modifier.fillMaxSize().background(color = Color.Cyan))
}
is ListOneThirdAndDetailThirds -> {
AdaptiveLayoutListOneThirdAndDetailTwoThirds(
firstComposable = {
FirstScreen(
modifier = Modifier.fillMaxSize().background(color = Color.Cyan)
)
},
secondComposable = {
SecondScreen(
modifier = Modifier.fillMaxSize().background(color = Color.Red)
)
}
)
}
is ListHalfAndDetailHalf -> {
AdaptiveLayoutListHalfAndDetailHalf(
firstComposable = {
FirstScreen(
modifier = Modifier.fillMaxSize().background(color = Color.Cyan)
)
},
secondComposable = {
SecondScreen(
modifier = Modifier.fillMaxSize().background(color = Color.Red)
)
}
)
}
is ListAndDetailStacked -> {
AdaptiveLayoutListAndDetailStacked(
firstComposable = {
FirstScreen(modifier = Modifier.fillMaxSize().background(color = Color.Cyan))
},
secondComposable = {
SecondScreen(modifier = Modifier.fillMaxSize().background(color = Color.Red))
}
)
}
else -> {
FirstScreen(modifier = Modifier.fillMaxSize().background(color = Color.Cyan))
}
}
}ChangeStatusBarColor(color = Color.Red)//note that due to limitations in ios you need to change your
// statusBarColor too if you need to change your home indicator color
// or your statusBarColor will be the same as your home indicator color
ChangeBottomNavigationColor(color = Color.Red)