Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review comments for AI UI #1948

Merged
merged 1 commit into from
Jan 10, 2024
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
22 changes: 11 additions & 11 deletions ai/ui/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package com.google.android.horologist.ai.ui.components {
method @androidx.compose.runtime.Composable public static void TextPromptDisplay(com.google.android.horologist.ai.ui.model.TextPromptUiModel prompt, optional androidx.compose.ui.Modifier modifier, optional kotlin.jvm.functions.Function0<kotlin.Unit> onClick);
}

public final class PromptResponseDisplayKt {
method @androidx.compose.runtime.Composable public static void PromptResponseDisplay(com.google.android.horologist.ai.ui.model.PromptResponseUiModel promptResponse, optional androidx.compose.ui.Modifier modifier, optional kotlin.jvm.functions.Function0<kotlin.Unit> onClick);
public final class PromptOrResponseDisplayKt {
method @androidx.compose.runtime.Composable public static void PromptOrResponseDisplay(com.google.android.horologist.ai.ui.model.PromptOrResponseUiModel promptResponse, optional androidx.compose.ui.Modifier modifier, optional kotlin.jvm.functions.Function0<kotlin.Unit> onClick);
}

public final class ResponseDisplayKt {
Expand All @@ -19,7 +19,7 @@ package com.google.android.horologist.ai.ui.components {

package com.google.android.horologist.ai.ui.model {

public final class FailedResponseUiModel implements com.google.android.horologist.ai.ui.model.PromptResponseUiModel {
public final class FailedResponseUiModel implements com.google.android.horologist.ai.ui.model.PromptOrResponseUiModel {
ctor public FailedResponseUiModel(String message);
method public String component1();
method public com.google.android.horologist.ai.ui.model.FailedResponseUiModel copy(String message);
Expand Down Expand Up @@ -48,13 +48,13 @@ package com.google.android.horologist.ai.ui.model {
property public final String name;
}

public sealed interface PromptResponseUiModel {
public sealed interface PromptOrResponseUiModel {
}

public sealed interface PromptUiModel extends com.google.android.horologist.ai.ui.model.PromptResponseUiModel {
public sealed interface PromptUiModel extends com.google.android.horologist.ai.ui.model.PromptOrResponseUiModel {
}

public sealed interface ResponseUiModel extends com.google.android.horologist.ai.ui.model.PromptResponseUiModel {
public sealed interface ResponseUiModel extends com.google.android.horologist.ai.ui.model.PromptOrResponseUiModel {
}

public final class TextPromptUiModel implements com.google.android.horologist.ai.ui.model.PromptUiModel {
Expand Down Expand Up @@ -85,16 +85,16 @@ package com.google.android.horologist.ai.ui.screens {
}

public final class PromptUiState {
ctor public PromptUiState(optional com.google.android.horologist.ai.ui.model.ModelInstanceUiModel? modelInfo, optional java.util.List<? extends com.google.android.horologist.ai.ui.model.PromptResponseUiModel> messages, optional com.google.android.horologist.ai.ui.model.TextPromptUiModel? inProgress);
ctor public PromptUiState(optional com.google.android.horologist.ai.ui.model.ModelInstanceUiModel? modelInfo, optional java.util.List<? extends com.google.android.horologist.ai.ui.model.PromptOrResponseUiModel> messages, optional com.google.android.horologist.ai.ui.model.TextPromptUiModel? inProgress);
method public com.google.android.horologist.ai.ui.model.ModelInstanceUiModel? component1();
method public java.util.List<com.google.android.horologist.ai.ui.model.PromptResponseUiModel> component2();
method public java.util.List<com.google.android.horologist.ai.ui.model.PromptOrResponseUiModel> component2();
method public com.google.android.horologist.ai.ui.model.TextPromptUiModel? component3();
method public com.google.android.horologist.ai.ui.screens.PromptUiState copy(com.google.android.horologist.ai.ui.model.ModelInstanceUiModel? modelInfo, java.util.List<? extends com.google.android.horologist.ai.ui.model.PromptResponseUiModel> messages, com.google.android.horologist.ai.ui.model.TextPromptUiModel? inProgress);
method public com.google.android.horologist.ai.ui.screens.PromptUiState copy(com.google.android.horologist.ai.ui.model.ModelInstanceUiModel? modelInfo, java.util.List<? extends com.google.android.horologist.ai.ui.model.PromptOrResponseUiModel> messages, com.google.android.horologist.ai.ui.model.TextPromptUiModel? inProgress);
method public com.google.android.horologist.ai.ui.model.TextPromptUiModel? getInProgress();
method public java.util.List<com.google.android.horologist.ai.ui.model.PromptResponseUiModel> getMessages();
method public java.util.List<com.google.android.horologist.ai.ui.model.PromptOrResponseUiModel> getMessages();
method public com.google.android.horologist.ai.ui.model.ModelInstanceUiModel? getModelInfo();
property public final com.google.android.horologist.ai.ui.model.TextPromptUiModel? inProgress;
property public final java.util.List<com.google.android.horologist.ai.ui.model.PromptResponseUiModel> messages;
property public final java.util.List<com.google.android.horologist.ai.ui.model.PromptOrResponseUiModel> messages;
property public final com.google.android.horologist.ai.ui.model.ModelInstanceUiModel? modelInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.wear.compose.material.Card
import androidx.wear.compose.material.CardDefaults
import androidx.wear.compose.material.MaterialTheme
Expand All @@ -43,8 +42,8 @@ public fun TextPromptDisplay(
modifier = modifier.fillMaxWidth(),
onClick = onClick,
backgroundPainter = CardDefaults.cardBackgroundPainter(
Color(0xff8ab4f8),
Color(0xff8ab4f8),
MaterialTheme.colors.primaryVariant,
MaterialTheme.colors.primaryVariant,
),
) {
Text(text = prompt.prompt, color = MaterialTheme.colors.surface)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.google.android.horologist.ai.ui.model.FailedResponseUiModel
import com.google.android.horologist.ai.ui.model.InProgressResponseUiModel
import com.google.android.horologist.ai.ui.model.PromptResponseUiModel
import com.google.android.horologist.ai.ui.model.PromptOrResponseUiModel
import com.google.android.horologist.ai.ui.model.TextPromptUiModel
import com.google.android.horologist.ai.ui.model.TextResponseUiModel

/**
* A component to display an Answer.
*/
@Composable
public fun PromptResponseDisplay(
promptResponse: PromptResponseUiModel,
public fun PromptOrResponseDisplay(
promptResponse: PromptOrResponseUiModel,
modifier: Modifier = Modifier,
onClick: () -> Unit = {},
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.datasource.LoremIpsum
import androidx.wear.compose.material.Card
import androidx.wear.compose.material.CardDefaults
Expand Down Expand Up @@ -56,11 +55,11 @@ public fun TextResponseCard(
modifier = modifier.fillMaxWidth(),
onClick = onClick,
backgroundPainter = CardDefaults.cardBackgroundPainter(
Color(0xffbdc1c6),
Color(0xffbdc1c6),
MaterialTheme.colors.surface,
MaterialTheme.colors.surface,
),
) {
Text(text = textResponseUiModel.text, color = MaterialTheme.colors.surface)
Text(text = textResponseUiModel.text, color = MaterialTheme.colors.onSurface, style = MaterialTheme.typography.body2)
}
}

Expand All @@ -78,7 +77,7 @@ public fun ResponseInProgressCard(
@Composable
internal fun TextResponseCardPreview() {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) {
PromptResponseDisplay(
PromptOrResponseDisplay(
TextResponseUiModel(LoremIpsum(20).values.joinToString("\n")),
)
}
Expand All @@ -88,7 +87,7 @@ internal fun TextResponseCardPreview() {
@Composable
internal fun FailedResponseChipPreview() {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
PromptResponseDisplay(
PromptOrResponseDisplay(
FailedResponseUiModel("Error"),
)
}
Expand All @@ -98,7 +97,7 @@ internal fun FailedResponseChipPreview() {
@Composable
internal fun ResponseInProgressCardPreview() {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
PromptResponseDisplay(
PromptOrResponseDisplay(
InProgressResponseUiModel,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.android.horologist.ai.ui.model

public data class FailedResponseUiModel(public val message: String) : PromptResponseUiModel {
public data class FailedResponseUiModel(public val message: String) : PromptOrResponseUiModel {
public companion object {
public val NoCompanion: FailedResponseUiModel =
FailedResponseUiModel("No companion app found")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

package com.google.android.horologist.ai.ui.model

public sealed interface PromptResponseUiModel
public sealed interface PromptOrResponseUiModel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.google.android.horologist.ai.ui.model

import java.time.Instant

public sealed interface PromptUiModel : PromptResponseUiModel
public sealed interface PromptUiModel : PromptOrResponseUiModel

public data class TextPromptUiModel(
val prompt: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.android.horologist.ai.ui.model

public sealed interface ResponseUiModel : PromptResponseUiModel
public sealed interface ResponseUiModel : PromptOrResponseUiModel

public object InProgressResponseUiModel : ResponseUiModel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.wear.compose.material.ListHeader
import androidx.wear.compose.material.Text
import com.google.android.horologist.ai.ui.components.PromptResponseDisplay
import com.google.android.horologist.ai.ui.components.PromptOrResponseDisplay
import com.google.android.horologist.ai.ui.components.ResponseInProgressCard
import com.google.android.horologist.ai.ui.components.TextPromptDisplay
import com.google.android.horologist.ai.ui.model.InProgressResponseUiModel
Expand Down Expand Up @@ -64,11 +64,11 @@ public fun PromptScreen(
uiState.messages.forEach {
item {
val padding = when (it) {
is PromptUiModel -> PaddingValues(end = 25.dp)
is ResponseUiModel -> PaddingValues(start = 25.dp)
is PromptUiModel -> PaddingValues(end = 20.dp)
is ResponseUiModel -> PaddingValues(start = 20.dp)
else -> PaddingValues()
}
PromptResponseDisplay(
PromptOrResponseDisplay(
promptResponse = it,
onClick = {},
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
package com.google.android.horologist.ai.ui.screens

import com.google.android.horologist.ai.ui.model.ModelInstanceUiModel
import com.google.android.horologist.ai.ui.model.PromptResponseUiModel
import com.google.android.horologist.ai.ui.model.PromptOrResponseUiModel
import com.google.android.horologist.ai.ui.model.TextPromptUiModel

public data class PromptUiState(
val modelInfo: ModelInstanceUiModel? = null,
val messages: List<PromptResponseUiModel> = listOf(),
val messages: List<PromptOrResponseUiModel> = listOf(),
val inProgress: TextPromptUiModel? = null,
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.