@@ -63,19 +63,18 @@ import androidx.compose.ui.draw.dropShadow
6363import androidx.compose.ui.graphics.Color
6464import androidx.compose.ui.graphics.shadow.Shadow
6565import androidx.compose.ui.graphics.vector.ImageVector
66- import androidx.compose.ui.layout.LookaheadScope
6766import androidx.compose.ui.platform.LocalContext
6867import androidx.compose.ui.res.stringResource
6968import androidx.compose.ui.res.vectorResource
7069import androidx.compose.ui.tooling.preview.Preview
7170import androidx.compose.ui.unit.dp
7271import androidx.lifecycle.compose.collectAsStateWithLifecycle
7372import androidx.navigation3.ui.LocalNavAnimatedContentScope
73+ import com.android.developers.androidify.customize.xr.CustomizeExportLayoutSpatial
7474import com.android.developers.androidify.results.PermissionRationaleDialog
7575import com.android.developers.androidify.results.R
7676import com.android.developers.androidify.results.shareImage
7777import com.android.developers.androidify.theme.AndroidifyTheme
78- import com.android.developers.androidify.theme.LocalAnimateBoundsScope
7978import com.android.developers.androidify.theme.components.AboutButton
8079import com.android.developers.androidify.theme.components.AndroidifyTopAppBar
8180import com.android.developers.androidify.theme.components.PrimaryButton
@@ -86,6 +85,10 @@ import com.android.developers.androidify.util.PhonePreview
8685import com.android.developers.androidify.util.allowsFullContent
8786import com.android.developers.androidify.watchface.WatchFaceAsset
8887import com.android.developers.androidify.wear.common.ConnectedWatch
88+ import com.android.developers.androidify.xr.RequestFullSpaceIconButton
89+ import com.android.developers.androidify.xr.RequestHomeSpaceIconButton
90+ import com.android.developers.androidify.xr.couldRequestFullSpace
91+ import com.android.developers.androidify.xr.couldRequestHomeSpace
8992import com.google.accompanist.permissions.ExperimentalPermissionsApi
9093import com.google.accompanist.permissions.isGranted
9194import com.google.accompanist.permissions.rememberPermissionState
@@ -110,7 +113,7 @@ fun CustomizeAndExportScreen(
110113 }
111114 }
112115
113- val layoutType = calculateLayoutType()
116+ val layoutType = calculateLayoutType(enableXr = state.value.xrEnabled )
114117 CustomizeExportContents (
115118 state.value,
116119 onBackPress,
@@ -193,10 +196,18 @@ private fun CustomizeExportContents(
193196 AndroidifyTopAppBar (
194197 backEnabled = true ,
195198 titleText = stringResource(R .string.customize_and_export),
196- isMediumWindowSize = layoutType == CustomizeExportLayoutType .Medium ,
199+ isMediumWindowSize = layoutType != CustomizeExportLayoutType .Compact ,
197200 onBackPressed = onBackPress,
198201 actions = {
199202 AboutButton { onInfoPress() }
203+ if (state.xrEnabled) {
204+ if (couldRequestFullSpace()) {
205+ RequestFullSpaceIconButton ()
206+ }
207+ if (couldRequestHomeSpace()) {
208+ RequestHomeSpaceIconButton ()
209+ }
210+ }
200211 },
201212 )
202213 }
@@ -255,40 +266,46 @@ private fun CustomizeExportContents(
255266 )
256267 }
257268 }
258- LookaheadScope {
259- CompositionLocalProvider (LocalAnimateBoundsScope provides this ) {
260- when (layoutType) {
261- CustomizeExportLayoutType .Medium -> CustomizeExportScreenScaffold (
262- snackbarHostState,
263- topBar = topBar,
264- containerColor = MaterialTheme .colorScheme.surface,
265- ) { paddingValues ->
266- CustomizeExportLayoutMedium (
267- paddingValues = paddingValues,
268- imageResult = imageResult,
269- state = state,
270- toolDetail = toolDetail,
271- toolSelector = toolSelector,
272- actionButtons = actionButtons,
273- )
274- }
269+ when (layoutType) {
270+ CustomizeExportLayoutType .Medium -> CustomizeExportScreenScaffold (
271+ snackbarHostState,
272+ topBar = topBar,
273+ containerColor = MaterialTheme .colorScheme.surface,
274+ ) { paddingValues ->
275+ CustomizeExportLayoutMedium (
276+ paddingValues = paddingValues,
277+ imageResult = imageResult,
278+ state = state,
279+ toolDetail = toolDetail,
280+ toolSelector = toolSelector,
281+ actionButtons = actionButtons,
282+ )
283+ }
275284
276- else -> CustomizeExportScreenScaffold (
277- snackbarHostState,
278- topBar = topBar,
279- containerColor = MaterialTheme .colorScheme.surface,
280- ) { paddingValues ->
281- CustomizeExportLayoutCompact (
282- paddingValues = paddingValues,
283- imageResult = imageResult,
284- state = state,
285- toolSelector = toolSelector,
286- toolDetail = toolDetail,
287- actionButtons = actionButtons,
288- )
289- }
290- }
285+ CustomizeExportLayoutType .Compact -> CustomizeExportScreenScaffold (
286+ snackbarHostState,
287+ topBar = topBar,
288+ containerColor = MaterialTheme .colorScheme.surface,
289+ ) { paddingValues ->
290+ CustomizeExportLayoutCompact (
291+ paddingValues = paddingValues,
292+ imageResult = imageResult,
293+ state = state,
294+ toolSelector = toolSelector,
295+ toolDetail = toolDetail,
296+ actionButtons = actionButtons,
297+ )
291298 }
299+
300+ CustomizeExportLayoutType .Spatial -> CustomizeExportLayoutSpatial (
301+ imageResult = imageResult,
302+ state = state,
303+ toolSelector = toolSelector,
304+ toolDetail = toolDetail,
305+ actionButtons = actionButtons,
306+ snackbarHostState = snackbarHostState,
307+ topBar = topBar,
308+ )
292309 }
293310}
294311
@@ -533,7 +550,7 @@ fun CustomizeExportScreenScaffold(
533550 },
534551 topBar = topBar,
535552 containerColor = containerColor,
536- modifier = modifier.fillMaxSize() ,
553+ modifier = modifier,
537554 content = content,
538555 )
539556}
0 commit comments