Skip to content

Commit dddcd20

Browse files
committed
This commit resolves an issue where content on the Settings and Measurement Type Detail screens could be cut off on smaller displays.
1 parent 67fa05d commit dddcd20

3 files changed

Lines changed: 62 additions & 49 deletions

File tree

android_app/app/src/main/java/com/health/openscale/ui/navigation/AppNavigation.kt

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import androidx.compose.foundation.layout.padding
3535
import androidx.compose.foundation.layout.size
3636
import androidx.compose.foundation.layout.width
3737
import androidx.compose.foundation.lazy.LazyColumn
38+
import androidx.compose.foundation.lazy.items
3839
import androidx.compose.foundation.lazy.itemsIndexed
3940
import androidx.compose.foundation.selection.selectable
4041
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -397,7 +398,9 @@ fun AppNavigation(sharedViewModel: SharedViewModel) {
397398
.fillMaxWidth()
398399
) {
399400
Image(
400-
painter = if (BuildConfig.BUILD_TYPE == "beta" || BuildConfig.BUILD_TYPE == "oss") painterResource(id = R.drawable.ic_launcher_beta_foreground) else painterResource(id = R.drawable.ic_launcher_foreground) ,
401+
painter = if (BuildConfig.BUILD_TYPE == "beta" || BuildConfig.BUILD_TYPE == "oss") painterResource(
402+
id = R.drawable.ic_launcher_beta_foreground
403+
) else painterResource(id = R.drawable.ic_launcher_foreground),
401404
contentDescription = stringResource(R.string.app_logo_content_description),
402405
modifier = Modifier.size(64.dp)
403406
)
@@ -410,56 +413,58 @@ fun AppNavigation(sharedViewModel: SharedViewModel) {
410413
Spacer(modifier = Modifier.height(8.dp)) // Spacing after the header
411414

412415
// Drawer Items: Dynamically created for each main route.
413-
mainRoutes.forEach { route ->
414-
// Add a divider before the "Settings" item for visual separation.
415-
if (route == Routes.SETTINGS) {
416-
HorizontalDivider(
417-
modifier = Modifier
418-
.fillMaxWidth()
419-
.padding(horizontal = 16.dp, vertical = 8.dp)
420-
)
421-
}
416+
LazyColumn() {
417+
items(mainRoutes, key = {it}) { route ->
418+
// Add a divider before the "Settings" item for visual separation.
419+
if (route == Routes.SETTINGS) {
420+
HorizontalDivider(
421+
modifier = Modifier
422+
.fillMaxWidth()
423+
.padding(horizontal = 16.dp, vertical = 8.dp)
424+
)
425+
}
422426

423-
val titleResId = Routes.getTitleResourceId(route)
424-
val titleText = if (titleResId != Routes.NO_TITLE_RESOURCE_ID) {
425-
stringResource(id = titleResId)
426-
} else {
427-
route // Fallback to the raw route string if no title resource ID is defined.
428-
}
427+
val titleResId = Routes.getTitleResourceId(route)
428+
val titleText = if (titleResId != Routes.NO_TITLE_RESOURCE_ID) {
429+
stringResource(id = titleResId)
430+
} else {
431+
route // Fallback to the raw route string if no title resource ID is defined.
432+
}
429433

430-
NavigationDrawerItem(
431-
icon = {
432-
Icon(
433-
imageVector = getIconForRoute(route),
434-
contentDescription = titleText // Provides accessibility for the icon.
435-
)
436-
},
437-
label = { Text(titleText) },
438-
selected = currentRoute == route, // Highlights the item if it's the current route.
439-
onClick = {
440-
navController.navigate(route) {
441-
// Pop up to the start destination of the graph to avoid building up a large back stack.
442-
popUpTo(navController.graph.startDestinationId) {
443-
saveState = true // Save the state of popped destinations.
434+
NavigationDrawerItem(
435+
icon = {
436+
Icon(
437+
imageVector = getIconForRoute(route),
438+
contentDescription = titleText // Provides accessibility for the icon.
439+
)
440+
},
441+
label = { Text(titleText) },
442+
selected = currentRoute == route, // Highlights the item if it's the current route.
443+
onClick = {
444+
navController.navigate(route) {
445+
// Pop up to the start destination of the graph to avoid building up a large back stack.
446+
popUpTo(navController.graph.startDestinationId) {
447+
saveState = true // Save the state of popped destinations.
448+
}
449+
// Avoid multiple copies of the same destination when reselecting the same item.
450+
launchSingleTop = true
451+
// Restore state when reselecting a previously visited item.
452+
restoreState = true
444453
}
445-
// Avoid multiple copies of the same destination when reselecting the same item.
446-
launchSingleTop = true
447-
// Restore state when reselecting a previously visited item.
448-
restoreState = true
449-
}
450-
scope.launch { drawerState.close() } // Close the drawer after selection.
451-
},
452-
colors = NavigationDrawerItemDefaults.colors(
453-
// Custom colors for selected and unselected drawer items.
454-
selectedIconColor = Blue,
455-
selectedTextColor = Blue,
456-
selectedContainerColor = Color.Transparent, // No background for the selected item itself.
457-
458-
unselectedIconColor = White,
459-
unselectedTextColor = White,
460-
unselectedContainerColor = Color.Transparent
454+
scope.launch { drawerState.close() } // Close the drawer after selection.
455+
},
456+
colors = NavigationDrawerItemDefaults.colors(
457+
// Custom colors for selected and unselected drawer items.
458+
selectedIconColor = Blue,
459+
selectedTextColor = Blue,
460+
selectedContainerColor = Color.Transparent, // No background for the selected item itself.
461+
462+
unselectedIconColor = White,
463+
unselectedTextColor = White,
464+
unselectedContainerColor = Color.Transparent
465+
)
461466
)
462-
)
467+
}
463468
}
464469
}
465470
}

android_app/app/src/main/java/com/health/openscale/ui/screen/settings/MeasurementTypeDetailScreen.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ import androidx.compose.foundation.layout.heightIn
3131
import androidx.compose.foundation.layout.padding
3232
import androidx.compose.foundation.layout.size
3333
import androidx.compose.foundation.layout.widthIn
34+
import androidx.compose.foundation.rememberScrollState
3435
import androidx.compose.foundation.shape.CircleShape
36+
import androidx.compose.foundation.verticalScroll
3537
import androidx.compose.material.icons.Icons
3638
import androidx.compose.material.icons.filled.Save
3739
import androidx.compose.material.icons.outlined.Info
@@ -344,7 +346,10 @@ fun MeasurementTypeDetailScreen(
344346

345347

346348
Column(
347-
modifier = Modifier.padding(16.dp).fillMaxSize(),
349+
modifier = Modifier
350+
.padding(16.dp)
351+
.fillMaxSize()
352+
.verticalScroll(rememberScrollState()),
348353
verticalArrangement = Arrangement.spacedBy(16.dp)
349354
) {
350355
OutlinedSettingRow(label = stringResource(R.string.measurement_type_label_enabled)) {

android_app/app/src/main/java/com/health/openscale/ui/screen/settings/SettingsScreen.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import androidx.compose.foundation.layout.Column
2222
import androidx.compose.foundation.layout.fillMaxSize
2323
import androidx.compose.foundation.layout.fillMaxWidth
2424
import androidx.compose.foundation.layout.padding
25+
import androidx.compose.foundation.rememberScrollState
26+
import androidx.compose.foundation.verticalScroll
2527
import androidx.compose.material.icons.Icons
2628
import androidx.compose.material.icons.automirrored.filled.ShowChart
2729
import androidx.compose.material.icons.filled.Bluetooth
@@ -140,7 +142,8 @@ fun SettingsScreen(
140142
modifier = Modifier
141143
.fillMaxSize()
142144
.padding(all = 8.dp) // Add some overall padding to the column
143-
) {
145+
.verticalScroll(rememberScrollState())
146+
) {
144147
items.forEach { item ->
145148
Card(
146149
modifier = Modifier

0 commit comments

Comments
 (0)