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
Expand Up @@ -89,7 +89,6 @@ fun MainNavigation() {
fadeIn(motionScheme.defaultEffectsSpec()),
scaleOut(
targetScale = 0.7f,
transformOrigin = TransformOrigin(pivotFractionX = 0.5f, pivotFractionY = 0.5f),
),
)
},
Expand All @@ -108,14 +107,17 @@ fun MainNavigation() {
entry<Camera> {
CameraPreviewScreen(
onImageCaptured = { uri ->
backStack.removeAll { it is Create }
backStack.add(Create(uri.toString()))
backStack.removeAll { it is Camera }
},
)
}
entry<Create> { createKey ->
CreationScreen(
createKey.fileName,
onCameraPressed = {
backStack.removeAll { it is Camera }
backStack.add(Camera)
},
onBackPressed = {
Expand All @@ -142,7 +144,7 @@ fun MainNavigation() {
showSplash = false
},
onTransitionMidpoint = {
backStack.add(Create())
backStack.add(Create(fileName = null))
},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ fun CameraPreviewScreen(
// so CameraX can retrieve the new Surface.
LaunchedEffect(surface) {
val oldIsTableTop = isTableTopPosture(foldingFeature)

snapshotFlow { foldingFeature }
.takeWhile {
val newIsTableTop = isTableTopPosture(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ fun CreationScreen(
}
LaunchedEffect(Unit) {
if (fileName != null) creationViewModel.onImageSelected(fileName.toUri())
else creationViewModel.onImageSelected(null)
}
val pickMedia = rememberLauncherForActivityResult(PickVisualMedia()) { uri ->
if (uri != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class CreationViewModel @Inject constructor(
val snackbarHostState: StateFlow<SnackbarHostState>
get() = _snackbarHostState

fun onImageSelected(uri: Uri) {
fun onImageSelected(uri: Uri?) {
_uiState.update {
it.copy(
imageUri = uri,
Expand All @@ -116,14 +116,21 @@ class CreationViewModel @Inject constructor(
_uiState.update {
it.copy(promptGenerationInProgress = true)
}
val prompt = textGenerationRepository.getNextGeneratedBotPrompt()
Log.d("CreationViewModel", "Prompt: $prompt")
if (prompt != null) {
try {
val prompt = textGenerationRepository.getNextGeneratedBotPrompt()
Log.d("CreationViewModel", "Prompt: $prompt")
if (prompt != null) {
_uiState.update {
it.copy(
generatedPrompt = prompt,
promptGenerationInProgress = false,
)
}
}
} catch (exception: Exception) {
Log.e("CreationViewModel", "Error generating prompt", exception)
_uiState.update {
it.copy(
generatedPrompt = prompt,
promptGenerationInProgress = false,
)
it.copy(promptGenerationInProgress = false)
}
}
}
Expand Down