@@ -39,7 +39,6 @@ fun AppDrawerHost(
3939 )
4040}
4141
42- @OptIn(KoinInternalApi ::class )
4342@Composable
4443fun AppDrawerHost (
4544 modifier : Modifier = Modifier ,
@@ -48,43 +47,52 @@ fun AppDrawerHost(
4847 AppDrawer (app, appCount, callback)
4948 }
5049) {
51- PACETheme {
52- CompositionLocalProvider (
53- LocalKoinApplication provides KoinConfig .cloudSDKKoinApp.koin ,
54- LocalKoinScope provides KoinConfig .cloudSDKKoinApp.koin.scopeRegistry.rootScope
50+ AppDrawerHost { apps ->
51+ BoxWithConstraints (
52+ modifier = modifier ,
53+ contentAlignment = Alignment . BottomEnd
5554 ) {
56- val viewModel = koinViewModel<AppDrawerViewModel >()
55+ val space = dimensionResource(id = R .dimen.app_drawer_spacing)
56+ val drawerHeight = dimensionResource(id = R .dimen.app_drawer_height)
57+ val size = remember(maxHeight) {
58+ // Calculate number of elements that fit into max height
59+ maxHeight.div(space + drawerHeight).toInt().coerceAtLeast(0 )
60+ }
5761
58- BoxWithConstraints (
59- modifier = modifier,
60- contentAlignment = Alignment .BottomEnd
62+ Column (
63+ verticalArrangement = Arrangement .spacedBy(
64+ space = space,
65+ alignment = Alignment .Bottom
66+ ),
67+ horizontalAlignment = Alignment .End
6168 ) {
62- val space = dimensionResource(id = R .dimen.app_drawer_spacing)
63- val drawerHeight = dimensionResource(id = R .dimen.app_drawer_height)
64- val size = remember(maxHeight) {
65- // Calculate number of elements that fit into max height
66- maxHeight.div(space + drawerHeight).toInt().coerceAtLeast(0 )
67- }
68-
69- Column (
70- verticalArrangement = Arrangement .spacedBy(
71- space = space,
72- alignment = Alignment .Bottom
73- ),
74- horizontalAlignment = Alignment .End
75- ) {
76- val apps by viewModel.apps.collectAsStateWithLifecycle(minActiveState = Lifecycle .State .RESUMED )
77- val maxApps = apps.take(size)
69+ val maxApps = apps.take(size)
7870
79- maxApps.forEach {
80- appDrawer(it, maxApps.size)
81- }
71+ maxApps.forEach {
72+ appDrawer(it, maxApps.size)
73+ }
8274
83- LaunchedEffect (maxApps, callback) {
84- callback.onShow(maxApps)
85- }
75+ LaunchedEffect (maxApps, callback) {
76+ callback.onShow(maxApps)
8677 }
8778 }
8879 }
8980 }
9081}
82+
83+ @OptIn(KoinInternalApi ::class )
84+ @Composable
85+ fun AppDrawerHost (
86+ content : @Composable (apps: List <App >) -> Unit
87+ ) {
88+ PACETheme {
89+ CompositionLocalProvider (
90+ LocalKoinApplication provides KoinConfig .cloudSDKKoinApp.koin,
91+ LocalKoinScope provides KoinConfig .cloudSDKKoinApp.koin.scopeRegistry.rootScope
92+ ) {
93+ val viewModel = koinViewModel<AppDrawerViewModel >()
94+ val apps by viewModel.apps.collectAsStateWithLifecycle(minActiveState = Lifecycle .State .RESUMED )
95+ content(apps)
96+ }
97+ }
98+ }
0 commit comments