Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.developers.androidify.xr

import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.dp
import androidx.xr.compose.spatial.Subspace
import androidx.xr.compose.subspace.SpatialBox
import androidx.xr.compose.subspace.SpatialBoxScope
import androidx.xr.compose.subspace.SpatialPanel
import androidx.xr.compose.subspace.SubspaceComposable
import androidx.xr.compose.subspace.layout.SubspaceModifier
import androidx.xr.compose.subspace.layout.aspectRatio
import androidx.xr.compose.subspace.layout.fillMaxWidth
import androidx.xr.compose.subspace.layout.movable
import androidx.xr.compose.subspace.layout.offset
import androidx.xr.compose.subspace.layout.resizable
import com.android.developers.androidify.theme.components.SquiggleBackgroundFull

/**
* A composable for a Subspace with a Squiggle background.
* This Subspace is generally the top-level Subspace. It contains a full-sized squiggle background
* that is grabbable and movable, allowing all child components to move with the background.
*/
@Composable
fun SquiggleBackgroundSubspace(
content:
@SubspaceComposable @Composable
SpatialBoxScope.() -> Unit,
) {
Subspace {
SpatialPanel(
SubspaceModifier
.movable()
.resizable()
.fillMaxWidth(1f)
.aspectRatio(1.7f),
) {
SquiggleBackgroundFull()
Subspace {
SpatialBox(SubspaceModifier.offset(z = 10.dp), content = content)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.IconButtonColors
import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
Expand All @@ -45,14 +45,15 @@ fun SpatialCapabilities.couldRequestHomeSpace(): Boolean {

/** Default styling for an IconButton with a home space button and behavior. */
@Composable
fun RequestHomeSpaceIconButton(modifier: Modifier = Modifier) {
fun RequestHomeSpaceIconButton(
modifier: Modifier = Modifier,
colors: IconButtonColors = IconButtonDefaults.iconButtonColors(),
) {
val session = LocalSession.current ?: return

IconButton(
modifier = modifier,
colors = IconButtonDefaults.iconButtonColors(
containerColor = MaterialTheme.colorScheme.secondaryContainer,
),
colors = colors,
onClick = {
session.scene.requestHomeSpaceMode()
},
Expand Down
3 changes: 3 additions & 0 deletions feature/creation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ dependencies {
implementation(libs.androidx.media3.exoplayer)
implementation(libs.androidx.media3.ui.compose)
implementation(libs.androidx.media3.ui) // for string resources only
implementation(libs.androidx.xr.compose)
ksp(libs.hilt.compiler)

implementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.tooling.preview)

implementation(projects.core.theme)
implementation(projects.core.util)
implementation(projects.core.xr)
implementation(projects.data)
implementation(projects.feature.results)
testImplementation(libs.hilt.android.testing)
Expand All @@ -97,6 +99,7 @@ dependencies {
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.hilt.android.testing)
androidTestImplementation(projects.core.testing)
implementation(projects.core.network)
kspAndroidTest(libs.hilt.compiler)

debugImplementation(libs.androidx.ui.test.manifest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CreationScreenTest {
EditScreen(
snackbarHostState = SnackbarHostState(),
dropBehaviourFactory = FakeDropImageFactory(),
isExpanded = false,
layoutType = EditScreenLayoutType.Compact,
onCameraPressed = {},
onBackPressed = {},
onAboutPressed = {},
Expand Down Expand Up @@ -76,7 +76,7 @@ class CreationScreenTest {
EditScreen(
snackbarHostState = SnackbarHostState(),
dropBehaviourFactory = FakeDropImageFactory(),
isExpanded = false,
layoutType = EditScreenLayoutType.Compact,
onCameraPressed = {},
onBackPressed = {},
onAboutPressed = {},
Expand Down Expand Up @@ -106,7 +106,7 @@ class CreationScreenTest {
EditScreen(
snackbarHostState = SnackbarHostState(),
dropBehaviourFactory = FakeDropImageFactory(),
isExpanded = false,
layoutType = EditScreenLayoutType.Compact,
onCameraPressed = {},
onBackPressed = {},
onAboutPressed = {},
Expand Down Expand Up @@ -141,7 +141,7 @@ class CreationScreenTest {
EditScreen(
snackbarHostState = SnackbarHostState(),
dropBehaviourFactory = FakeDropImageFactory(),
isExpanded = false,
layoutType = EditScreenLayoutType.Compact,
onCameraPressed = {},
onBackPressed = {},
onAboutPressed = {},
Expand Down Expand Up @@ -175,7 +175,7 @@ class CreationScreenTest {
EditScreen(
snackbarHostState = SnackbarHostState(),
dropBehaviourFactory = FakeDropImageFactory(),
isExpanded = false,
layoutType = EditScreenLayoutType.Compact,
onCameraPressed = {},
onBackPressed = {},
onAboutPressed = {},
Expand Down Expand Up @@ -210,7 +210,7 @@ class CreationScreenTest {
EditScreen(
snackbarHostState = SnackbarHostState(),
dropBehaviourFactory = FakeDropImageFactory(),
isExpanded = false,
layoutType = EditScreenLayoutType.Compact,
onCameraPressed = {},
onBackPressed = {},
onAboutPressed = {},
Expand Down Expand Up @@ -244,7 +244,7 @@ class CreationScreenTest {
EditScreen(
snackbarHostState = SnackbarHostState(),
dropBehaviourFactory = FakeDropImageFactory(),
isExpanded = false,
layoutType = EditScreenLayoutType.Compact,
onCameraPressed = {},
onBackPressed = {},
onAboutPressed = {},
Expand Down Expand Up @@ -274,7 +274,7 @@ class CreationScreenTest {
EditScreen(
snackbarHostState = SnackbarHostState(),
dropBehaviourFactory = FakeDropImageFactory(),
isExpanded = true, // Expanded mode
layoutType = EditScreenLayoutType.Medium,
onCameraPressed = {},
onBackPressed = {},
onAboutPressed = {},
Expand Down
Loading