feat: Add Sentiment and UI Changes #14

Merged
ben merged 1 commit from feature/Create-Form-Skeleton into master 2025-01-21 12:50:48 +00:00
3 changed files with 53 additions and 25 deletions

View file

@ -1,37 +1,67 @@
package uk.sky.bob.application package uk.sky.bob.application
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button import androidx.compose.material.Button
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.FilterChip
import androidx.compose.material.MaterialTheme import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.* import androidx.compose.material.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import org.jetbrains.compose.resources.painterResource import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.ui.tooling.preview.Preview import org.jetbrains.compose.ui.tooling.preview.Preview
import bob.composeapp.generated.resources.Res @OptIn(ExperimentalMaterialApi::class)
import bob.composeapp.generated.resources.compose_multiplatform
@Composable @Composable
@Preview @Preview
fun App() { fun App() {
MaterialTheme { MaterialTheme {
var showContent by remember { mutableStateOf(false) }
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) { Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
Button(onClick = { showContent = !showContent }) { Row {
Text("Click me!") val state = remember { mutableStateOf(Sentiment.HAPPY) }
for (emotion in Sentiment.entries) {
FilterChip(
onClick = { state.value = emotion },
selected = state.value == emotion,
modifier = Modifier.padding(8.dp),
leadingIcon = { Text(emotion.leadingIcon) },
) {
Text(emotion.friendlyName)
}
}
} }
AnimatedVisibility(showContent) {
val greeting = remember { Greeting().greet() } Row {
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) { var text by rememberSaveable(stateSaver = TextFieldValue.Saver) {
Image(painterResource(Res.drawable.compose_multiplatform), null) mutableStateOf(
Text("Compose: $greeting") TextFieldValue("")
)
}
TextField(
value = text,
onValueChange = { text = it },
label = { Text("Your comment") },
maxLines = 3,
)
}
Row {
Button(onClick = { /* Handle submit */ }) {
Text("Submit")
} }
} }
} }
} }
} }

View file

@ -1,9 +0,0 @@
package uk.sky.bob.application
class Greeting {
private val platform = getPlatform()
fun greet(): String {
return "Hello, ${platform.name}!"
}
}

View file

@ -0,0 +1,7 @@
package uk.sky.bob.application
enum class Sentiment(val friendlyName: String, val leadingIcon: String) {
HAPPY("Happy", "\uD83D\uDE03"),
NEUTRAL("Neutral", "\uD83D\uDE10"),
SAD("Sad", "\uD83D\uDE1E");
}