Skip to content

Commit 7e87287

Browse files
authored
Merge pull request #121 from devbridie/feature/xr/creation-screen
Create a Spatial layout for the Edit portion of CreationScreen
2 parents be1acea + cfdc59b commit 7e87287

File tree

18 files changed

+1900
-928
lines changed

18 files changed

+1900
-928
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.android.developers.androidify.xr
17+
18+
import androidx.compose.runtime.Composable
19+
import androidx.compose.ui.unit.dp
20+
import androidx.xr.compose.spatial.Subspace
21+
import androidx.xr.compose.subspace.SpatialBox
22+
import androidx.xr.compose.subspace.SpatialBoxScope
23+
import androidx.xr.compose.subspace.SpatialPanel
24+
import androidx.xr.compose.subspace.SubspaceComposable
25+
import androidx.xr.compose.subspace.layout.SubspaceModifier
26+
import androidx.xr.compose.subspace.layout.aspectRatio
27+
import androidx.xr.compose.subspace.layout.fillMaxWidth
28+
import androidx.xr.compose.subspace.layout.movable
29+
import androidx.xr.compose.subspace.layout.offset
30+
import androidx.xr.compose.subspace.layout.resizable
31+
import com.android.developers.androidify.theme.components.SquiggleBackgroundFull
32+
33+
/**
34+
* A composable for a Subspace with a Squiggle background.
35+
* This Subspace is generally the top-level Subspace. It contains a full-sized squiggle background
36+
* that is grabbable and movable, allowing all child components to move with the background.
37+
*/
38+
@Composable
39+
fun SquiggleBackgroundSubspace(
40+
content:
41+
@SubspaceComposable @Composable
42+
SpatialBoxScope.() -> Unit,
43+
) {
44+
Subspace {
45+
SpatialPanel(
46+
SubspaceModifier
47+
.movable()
48+
.resizable()
49+
.fillMaxWidth(1f)
50+
.aspectRatio(1.7f),
51+
) {
52+
SquiggleBackgroundFull()
53+
Subspace {
54+
SpatialBox(SubspaceModifier.offset(z = 10.dp), content = content)
55+
}
56+
}
57+
}
58+
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import androidx.compose.foundation.layout.fillMaxSize
1919
import androidx.compose.foundation.layout.padding
2020
import androidx.compose.material3.Icon
2121
import androidx.compose.material3.IconButton
22+
import androidx.compose.material3.IconButtonColors
2223
import androidx.compose.material3.IconButtonDefaults
23-
import androidx.compose.material3.MaterialTheme
2424
import androidx.compose.runtime.Composable
2525
import androidx.compose.ui.Modifier
2626
import androidx.compose.ui.graphics.vector.ImageVector
@@ -45,14 +45,15 @@ fun SpatialCapabilities.couldRequestHomeSpace(): Boolean {
4545

4646
/** Default styling for an IconButton with a home space button and behavior. */
4747
@Composable
48-
fun RequestHomeSpaceIconButton(modifier: Modifier = Modifier) {
48+
fun RequestHomeSpaceIconButton(
49+
modifier: Modifier = Modifier,
50+
colors: IconButtonColors = IconButtonDefaults.iconButtonColors(),
51+
) {
4952
val session = LocalSession.current ?: return
5053

5154
IconButton(
5255
modifier = modifier,
53-
colors = IconButtonDefaults.iconButtonColors(
54-
containerColor = MaterialTheme.colorScheme.secondaryContainer,
55-
),
56+
colors = colors,
5657
onClick = {
5758
session.scene.requestHomeSpaceMode()
5859
},

feature/creation/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,15 @@ dependencies {
7676
implementation(libs.androidx.media3.exoplayer)
7777
implementation(libs.androidx.media3.ui.compose)
7878
implementation(libs.androidx.media3.ui) // for string resources only
79+
implementation(libs.androidx.xr.compose)
7980
ksp(libs.hilt.compiler)
8081

8182
implementation(libs.androidx.ui.tooling)
8283
debugImplementation(libs.androidx.ui.tooling.preview)
8384

8485
implementation(projects.core.theme)
8586
implementation(projects.core.util)
87+
implementation(projects.core.xr)
8688
implementation(projects.data)
8789
implementation(projects.feature.results)
8890
testImplementation(libs.hilt.android.testing)
@@ -97,6 +99,7 @@ dependencies {
9799
androidTestImplementation(libs.androidx.espresso.core)
98100
androidTestImplementation(libs.hilt.android.testing)
99101
androidTestImplementation(projects.core.testing)
102+
implementation(projects.core.network)
100103
kspAndroidTest(libs.hilt.compiler)
101104

102105
debugImplementation(libs.androidx.ui.test.manifest)

feature/creation/src/androidTest/java/com/android/developers/androidify/creation/CreationScreenTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CreationScreenTest {
4747
EditScreen(
4848
snackbarHostState = SnackbarHostState(),
4949
dropBehaviourFactory = FakeDropImageFactory(),
50-
isExpanded = false,
50+
layoutType = EditScreenLayoutType.Compact,
5151
onCameraPressed = {},
5252
onBackPressed = {},
5353
onAboutPressed = {},
@@ -76,7 +76,7 @@ class CreationScreenTest {
7676
EditScreen(
7777
snackbarHostState = SnackbarHostState(),
7878
dropBehaviourFactory = FakeDropImageFactory(),
79-
isExpanded = false,
79+
layoutType = EditScreenLayoutType.Compact,
8080
onCameraPressed = {},
8181
onBackPressed = {},
8282
onAboutPressed = {},
@@ -106,7 +106,7 @@ class CreationScreenTest {
106106
EditScreen(
107107
snackbarHostState = SnackbarHostState(),
108108
dropBehaviourFactory = FakeDropImageFactory(),
109-
isExpanded = false,
109+
layoutType = EditScreenLayoutType.Compact,
110110
onCameraPressed = {},
111111
onBackPressed = {},
112112
onAboutPressed = {},
@@ -141,7 +141,7 @@ class CreationScreenTest {
141141
EditScreen(
142142
snackbarHostState = SnackbarHostState(),
143143
dropBehaviourFactory = FakeDropImageFactory(),
144-
isExpanded = false,
144+
layoutType = EditScreenLayoutType.Compact,
145145
onCameraPressed = {},
146146
onBackPressed = {},
147147
onAboutPressed = {},
@@ -175,7 +175,7 @@ class CreationScreenTest {
175175
EditScreen(
176176
snackbarHostState = SnackbarHostState(),
177177
dropBehaviourFactory = FakeDropImageFactory(),
178-
isExpanded = false,
178+
layoutType = EditScreenLayoutType.Compact,
179179
onCameraPressed = {},
180180
onBackPressed = {},
181181
onAboutPressed = {},
@@ -210,7 +210,7 @@ class CreationScreenTest {
210210
EditScreen(
211211
snackbarHostState = SnackbarHostState(),
212212
dropBehaviourFactory = FakeDropImageFactory(),
213-
isExpanded = false,
213+
layoutType = EditScreenLayoutType.Compact,
214214
onCameraPressed = {},
215215
onBackPressed = {},
216216
onAboutPressed = {},
@@ -244,7 +244,7 @@ class CreationScreenTest {
244244
EditScreen(
245245
snackbarHostState = SnackbarHostState(),
246246
dropBehaviourFactory = FakeDropImageFactory(),
247-
isExpanded = false,
247+
layoutType = EditScreenLayoutType.Compact,
248248
onCameraPressed = {},
249249
onBackPressed = {},
250250
onAboutPressed = {},
@@ -274,7 +274,7 @@ class CreationScreenTest {
274274
EditScreen(
275275
snackbarHostState = SnackbarHostState(),
276276
dropBehaviourFactory = FakeDropImageFactory(),
277-
isExpanded = true, // Expanded mode
277+
layoutType = EditScreenLayoutType.Medium,
278278
onCameraPressed = {},
279279
onBackPressed = {},
280280
onAboutPressed = {},

0 commit comments

Comments
 (0)