Skip to content

Commit ef51a06

Browse files
committed
Merge branch '318-slider-adjustments-for-multiple-gas-stations-in-range' into 'master'
Resolve "Slider adjustments for multiple gas stations in range" Closes #318 See merge request pace/mobile/android/pace-cloud-sdk!347
2 parents 9db1c71 + 0346b77 commit ef51a06

File tree

4 files changed

+44
-38
lines changed

4 files changed

+44
-38
lines changed

library/src/main/java/cloud/pace/sdk/appkit/app/api/AppRepository.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ class AppRepositoryImpl(
143143
textBackgroundColor = manifest?.themeColor,
144144
display = manifest?.display,
145145
poiId = it.key,
146-
distance = distance
146+
distance = distance,
147+
brandUrl = appUrl
147148
)
148149
}
149150
}

library/src/main/java/cloud/pace/sdk/appkit/app/drawer/ui/AppDrawerHost.kt

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ fun AppDrawerHost(
3939
)
4040
}
4141

42-
@OptIn(KoinInternalApi::class)
4342
@Composable
4443
fun 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+
}

library/src/main/java/cloud/pace/sdk/appkit/app/drawer/ui/AppDrawerHostView.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import androidx.compose.runtime.Composable
66
import androidx.compose.runtime.getValue
77
import androidx.compose.runtime.mutableStateOf
88
import androidx.compose.runtime.setValue
9-
import androidx.compose.ui.Modifier
109
import androidx.compose.ui.platform.AbstractComposeView
1110
import cloud.pace.sdk.appkit.AppKit.defaultAppCallback
1211

@@ -20,9 +19,6 @@ class AppDrawerHostView @JvmOverloads constructor(
2019

2120
@Composable
2221
override fun Content() {
23-
AppDrawerHost(
24-
modifier = Modifier,
25-
callback = callback
26-
)
22+
AppDrawerHost(callback = callback)
2723
}
2824
}

library/src/main/java/cloud/pace/sdk/appkit/model/App.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ data class App(
1111
val textColor: String? = null,
1212
val display: String? = null,
1313
val poiId: String? = null,
14-
val distance: Int? = null
14+
val distance: Int? = null,
15+
val brandUrl: String? = null
1516
)

0 commit comments

Comments
 (0)