Skip to content

Commit 23f17c0

Browse files
committed
Make the behaviors of the Mode buttons and functions more consistent
1 parent d89aaab commit 23f17c0

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

core/xr/src/main/java/com/android/developers/androidify/xr/SpatialUiModes.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import androidx.compose.ui.graphics.vector.ImageVector
2727
import androidx.compose.ui.res.stringResource
2828
import androidx.compose.ui.res.vectorResource
2929
import androidx.compose.ui.unit.dp
30-
import androidx.xr.compose.platform.SpatialCapabilities
3130
import androidx.xr.scenecore.scene
3231

3332
/** Check if the device is XR-enabled, but is not yet rendering spatial UI. */
@@ -38,9 +37,8 @@ fun couldRequestFullSpace(): Boolean {
3837

3938
/** Check if the device is XR-enabled and is rendering spatial UI. */
4039
@Composable
41-
fun SpatialCapabilities.couldRequestHomeSpace(): Boolean {
42-
if (!LocalSpatialConfiguration.current.hasXrSpatialFeature) return false
43-
return isSpatialUiEnabled
40+
fun couldRequestHomeSpace(): Boolean {
41+
return LocalSpatialConfiguration.current.hasXrSpatialFeature && LocalSpatialCapabilities.current.isSpatialUiEnabled
4442
}
4543

4644
/** Default styling for an IconButton with a home space button and behavior. */
@@ -68,19 +66,26 @@ fun RequestHomeSpaceIconButton(
6866
}
6967
}
7068

71-
/** Default styling for an TopAppBar Button with a full space button and behavior. */
69+
/** Default styling for an IconButton with a full space button and behavior. */
7270
@Composable
73-
fun RequestFullSpaceIconButton(modifier: Modifier = Modifier) {
71+
fun RequestFullSpaceIconButton(
72+
modifier: Modifier = Modifier,
73+
colors: IconButtonColors = IconButtonDefaults.iconButtonColors(),
74+
) {
7475
val session = LocalSession.current ?: return
7576

7677
IconButton(
7778
modifier = modifier,
79+
colors = colors,
7880
onClick = {
7981
session.scene.requestFullSpaceMode()
8082
},
8183
) {
8284
Icon(
83-
ImageVector.vectorResource(R.drawable.expand_content_24px),
85+
modifier = Modifier
86+
.fillMaxSize()
87+
.padding(8.dp),
88+
imageVector = ImageVector.vectorResource(R.drawable.expand_content_24px),
8489
contentDescription = stringResource(R.string.xr_to_full_space_mode),
8590
)
8691
}

0 commit comments

Comments
 (0)