mirror of
https://github.com/Steffo99/twom.git
synced 2024-11-25 01:24:24 +00:00
Clean up code
This commit is contained in:
parent
6aeea6d170
commit
7565d511c3
18 changed files with 191 additions and 256 deletions
|
@ -16,16 +16,6 @@ import androidx.compose.ui.unit.dp
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.matrix.LocalSession
|
import eu.steffo.twom.matrix.LocalSession
|
||||||
import eu.steffo.twom.matrix.avatar.AvatarFromURL
|
import eu.steffo.twom.matrix.avatar.AvatarFromURL
|
||||||
import eu.steffo.twom.theme.colorRoleLater
|
|
||||||
import eu.steffo.twom.theme.colorRoleMaybe
|
|
||||||
import eu.steffo.twom.theme.colorRoleNoway
|
|
||||||
import eu.steffo.twom.theme.colorRoleSure
|
|
||||||
import eu.steffo.twom.theme.colorRoleUnknown
|
|
||||||
import eu.steffo.twom.theme.iconRoleLater
|
|
||||||
import eu.steffo.twom.theme.iconRoleMaybe
|
|
||||||
import eu.steffo.twom.theme.iconRoleNoway
|
|
||||||
import eu.steffo.twom.theme.iconRoleSure
|
|
||||||
import eu.steffo.twom.theme.iconRoleUnknown
|
|
||||||
import org.matrix.android.sdk.api.session.getUser
|
import org.matrix.android.sdk.api.session.getUser
|
||||||
|
|
||||||
// TODO: Check this with brain on
|
// TODO: Check this with brain on
|
||||||
|
@ -42,27 +32,9 @@ fun MemberListItem(
|
||||||
|
|
||||||
val user = session?.getUser(memberId)
|
val user = session?.getUser(memberId)
|
||||||
|
|
||||||
val colorRole = when (rsvpAnswer) {
|
val icon = rsvpAnswer.toIcon()
|
||||||
RSVPAnswer.SURE -> colorRoleSure()
|
val responseResourceId = rsvpAnswer.toResponseResourceId()
|
||||||
RSVPAnswer.LATER -> colorRoleLater()
|
val colorRole = rsvpAnswer.toStaticColorRole()
|
||||||
RSVPAnswer.MAYBE -> colorRoleMaybe()
|
|
||||||
RSVPAnswer.NOWAY -> colorRoleNoway()
|
|
||||||
null -> colorRoleUnknown()
|
|
||||||
}
|
|
||||||
val iconRole = when (rsvpAnswer) {
|
|
||||||
RSVPAnswer.SURE -> iconRoleSure
|
|
||||||
RSVPAnswer.LATER -> iconRoleLater
|
|
||||||
RSVPAnswer.MAYBE -> iconRoleMaybe
|
|
||||||
RSVPAnswer.NOWAY -> iconRoleNoway
|
|
||||||
null -> iconRoleUnknown
|
|
||||||
}
|
|
||||||
val iconDescription = when (rsvpAnswer) {
|
|
||||||
RSVPAnswer.SURE -> stringResource(R.string.room_rsvp_sure_response)
|
|
||||||
RSVPAnswer.LATER -> stringResource(R.string.room_rsvp_later_response)
|
|
||||||
RSVPAnswer.MAYBE -> stringResource(R.string.room_rsvp_maybe_response)
|
|
||||||
RSVPAnswer.NOWAY -> stringResource(R.string.room_rsvp_noway_response)
|
|
||||||
null -> stringResource(R.string.room_rsvp_unknown_response)
|
|
||||||
}
|
|
||||||
|
|
||||||
ListItem(
|
ListItem(
|
||||||
modifier = modifier.clickable {
|
modifier = modifier.clickable {
|
||||||
|
@ -87,18 +59,16 @@ fun MemberListItem(
|
||||||
},
|
},
|
||||||
trailingContent = {
|
trailingContent = {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = iconRole,
|
imageVector = icon,
|
||||||
contentDescription = iconDescription,
|
contentDescription = stringResource(responseResourceId),
|
||||||
tint = colorRole.value,
|
tint = colorRole.value,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
if (rsvpComment != "") {
|
Text(
|
||||||
Text(
|
text = rsvpComment,
|
||||||
text = rsvpComment,
|
color = colorRole.value,
|
||||||
color = colorRole.value,
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -1,8 +1,73 @@
|
||||||
package eu.steffo.twom.room
|
package eu.steffo.twom.room
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
import eu.steffo.twom.R
|
||||||
|
import eu.steffo.twom.theme.StaticColorRole
|
||||||
|
import eu.steffo.twom.theme.colorRoleLater
|
||||||
|
import eu.steffo.twom.theme.colorRoleMaybe
|
||||||
|
import eu.steffo.twom.theme.colorRoleNoway
|
||||||
|
import eu.steffo.twom.theme.colorRoleSure
|
||||||
|
import eu.steffo.twom.theme.colorRoleUnknown
|
||||||
|
import eu.steffo.twom.theme.iconLater
|
||||||
|
import eu.steffo.twom.theme.iconMaybe
|
||||||
|
import eu.steffo.twom.theme.iconNoway
|
||||||
|
import eu.steffo.twom.theme.iconSure
|
||||||
|
import eu.steffo.twom.theme.iconUnknown
|
||||||
|
|
||||||
enum class RSVPAnswer {
|
enum class RSVPAnswer {
|
||||||
SURE,
|
SURE,
|
||||||
LATER,
|
LATER,
|
||||||
MAYBE,
|
MAYBE,
|
||||||
NOWAY,
|
NOWAY,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun RSVPAnswer?.toStaticColorRole(): StaticColorRole {
|
||||||
|
return when (this) {
|
||||||
|
RSVPAnswer.SURE -> colorRoleSure()
|
||||||
|
RSVPAnswer.LATER -> colorRoleLater()
|
||||||
|
RSVPAnswer.MAYBE -> colorRoleMaybe()
|
||||||
|
RSVPAnswer.NOWAY -> colorRoleNoway()
|
||||||
|
null -> colorRoleUnknown()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun RSVPAnswer?.toIcon(): ImageVector {
|
||||||
|
return when (this) {
|
||||||
|
RSVPAnswer.SURE -> iconSure
|
||||||
|
RSVPAnswer.LATER -> iconLater
|
||||||
|
RSVPAnswer.MAYBE -> iconMaybe
|
||||||
|
RSVPAnswer.NOWAY -> iconNoway
|
||||||
|
null -> iconUnknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun RSVPAnswer.toLabelResourceId(): Int {
|
||||||
|
return when (this) {
|
||||||
|
RSVPAnswer.SURE -> R.string.room_rsvp_sure_label
|
||||||
|
RSVPAnswer.LATER -> R.string.room_rsvp_later_label
|
||||||
|
RSVPAnswer.MAYBE -> R.string.room_rsvp_maybe_label
|
||||||
|
RSVPAnswer.NOWAY -> R.string.room_rsvp_noway_label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun RSVPAnswer?.toResponseResourceId(): Int {
|
||||||
|
return when (this) {
|
||||||
|
RSVPAnswer.SURE -> R.string.room_rsvp_sure_response
|
||||||
|
RSVPAnswer.LATER -> R.string.room_rsvp_later_response
|
||||||
|
RSVPAnswer.MAYBE -> R.string.room_rsvp_maybe_response
|
||||||
|
RSVPAnswer.NOWAY -> R.string.room_rsvp_noway_response
|
||||||
|
null -> R.string.room_rsvp_unknown_response
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun RSVPAnswer?.toPlaceholderResourceId(): Int {
|
||||||
|
return when (this) {
|
||||||
|
RSVPAnswer.SURE -> R.string.room_rsvp_sure_placeholder
|
||||||
|
RSVPAnswer.LATER -> R.string.room_rsvp_later_placeholder
|
||||||
|
RSVPAnswer.MAYBE -> R.string.room_rsvp_maybe_placeholder
|
||||||
|
RSVPAnswer.NOWAY -> R.string.room_rsvp_noway_placeholder
|
||||||
|
null -> R.string.room_rsvp_unknown_placeholder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,33 +7,35 @@ import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.steffo.twom.theme.StaticColorRole
|
|
||||||
import eu.steffo.twom.theme.TwoMPadding
|
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun RoomActivityChip(
|
fun RSVPAnswerFilterChip(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
representing: RSVPAnswer,
|
||||||
selected: Boolean = false,
|
selected: Boolean = false,
|
||||||
onClick: () -> Unit = {},
|
onClick: () -> Unit = {},
|
||||||
text: String,
|
|
||||||
imageVector: ImageVector,
|
|
||||||
colorRole: StaticColorRole,
|
|
||||||
) {
|
) {
|
||||||
|
val icon = representing.toIcon()
|
||||||
|
val colorRole = representing.toStaticColorRole()
|
||||||
|
val labelResourceId = representing.toLabelResourceId()
|
||||||
|
|
||||||
FilterChip(
|
FilterChip(
|
||||||
modifier = TwoMPadding.chips,
|
modifier = modifier,
|
||||||
selected = selected,
|
selected = selected,
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
leadingIcon = {
|
leadingIcon = {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = imageVector,
|
imageVector = icon,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
label = {
|
label = {
|
||||||
Text(
|
Text(
|
||||||
text = text,
|
text = stringResource(labelResourceId),
|
||||||
style = MaterialTheme.typography.bodyLarge,
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
)
|
)
|
||||||
},
|
},
|
|
@ -13,66 +13,53 @@ import eu.steffo.twom.theme.TwoMPadding
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
||||||
fun RoomActivityChipSelector(
|
fun RSVPAnswerSelectRow(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
value: RSVPAnswer? = null,
|
value: RSVPAnswer? = null,
|
||||||
onChange: (answer: RSVPAnswer?) -> Unit = {},
|
onChange: (answer: RSVPAnswer?) -> Unit = {},
|
||||||
) {
|
) {
|
||||||
|
fun toggleSwitch(representing: RSVPAnswer): () -> Unit {
|
||||||
|
return {
|
||||||
|
onChange(
|
||||||
|
when (value) {
|
||||||
|
representing -> null
|
||||||
|
else -> representing
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.horizontalScroll(rememberScrollState())
|
.horizontalScroll(rememberScrollState())
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(start = 8.dp, end = 8.dp)
|
.padding(start = 10.dp, end = 10.dp)
|
||||||
) {
|
) {
|
||||||
RoomActivityChipSure(
|
RSVPAnswerFilterChip(
|
||||||
modifier = TwoMPadding.chips,
|
modifier = TwoMPadding.chips,
|
||||||
|
representing = RSVPAnswer.SURE,
|
||||||
selected = (value == RSVPAnswer.SURE),
|
selected = (value == RSVPAnswer.SURE),
|
||||||
onClick = {
|
onClick = toggleSwitch(RSVPAnswer.SURE)
|
||||||
onChange(
|
|
||||||
when (value) {
|
|
||||||
RSVPAnswer.SURE -> null
|
|
||||||
else -> RSVPAnswer.SURE
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
RoomActivityChipLater(
|
RSVPAnswerFilterChip(
|
||||||
modifier = TwoMPadding.chips,
|
modifier = TwoMPadding.chips,
|
||||||
|
representing = RSVPAnswer.LATER,
|
||||||
selected = (value == RSVPAnswer.LATER),
|
selected = (value == RSVPAnswer.LATER),
|
||||||
onClick = {
|
onClick = toggleSwitch(RSVPAnswer.LATER)
|
||||||
onChange(
|
|
||||||
when (value) {
|
|
||||||
RSVPAnswer.LATER -> null
|
|
||||||
else -> RSVPAnswer.LATER
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
RoomActivityChipMaybe(
|
RSVPAnswerFilterChip(
|
||||||
modifier = TwoMPadding.chips,
|
modifier = TwoMPadding.chips,
|
||||||
|
representing = RSVPAnswer.MAYBE,
|
||||||
selected = (value == RSVPAnswer.MAYBE),
|
selected = (value == RSVPAnswer.MAYBE),
|
||||||
onClick = {
|
onClick = toggleSwitch(RSVPAnswer.MAYBE)
|
||||||
onChange(
|
|
||||||
when (value) {
|
|
||||||
RSVPAnswer.MAYBE -> null
|
|
||||||
else -> RSVPAnswer.MAYBE
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
RoomActivityChipNoway(
|
RSVPAnswerFilterChip(
|
||||||
modifier = TwoMPadding.chips,
|
modifier = TwoMPadding.chips,
|
||||||
|
representing = RSVPAnswer.NOWAY,
|
||||||
selected = (value == RSVPAnswer.NOWAY),
|
selected = (value == RSVPAnswer.NOWAY),
|
||||||
onClick = {
|
onClick = toggleSwitch(RSVPAnswer.NOWAY)
|
||||||
onChange(
|
|
||||||
when (value) {
|
|
||||||
RSVPAnswer.NOWAY -> null
|
|
||||||
else -> RSVPAnswer.NOWAY
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package eu.steffo.twom.room
|
package eu.steffo.twom.room
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.material3.LocalContentColor
|
import androidx.compose.material3.LocalContentColor
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
|
@ -10,47 +9,29 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.R
|
|
||||||
import eu.steffo.twom.theme.colorRoleLater
|
|
||||||
import eu.steffo.twom.theme.colorRoleMaybe
|
|
||||||
import eu.steffo.twom.theme.colorRoleNoway
|
|
||||||
import eu.steffo.twom.theme.colorRoleSure
|
|
||||||
import eu.steffo.twom.theme.colorRoleUnknown
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
||||||
fun RoomActivityCommentField(
|
fun RSVPCommentField(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
value: String = "",
|
value: String = "",
|
||||||
onValueChange: (value: String) -> Unit = {},
|
onChange: (value: String) -> Unit = {},
|
||||||
rsvpAnswer: RSVPAnswer? = null,
|
currentRsvpAnswer: RSVPAnswer? = null,
|
||||||
) {
|
) {
|
||||||
val colorRole = when (rsvpAnswer) {
|
val colorRole = currentRsvpAnswer.toStaticColorRole()
|
||||||
RSVPAnswer.SURE -> colorRoleSure()
|
|
||||||
RSVPAnswer.LATER -> colorRoleLater()
|
|
||||||
RSVPAnswer.MAYBE -> colorRoleMaybe()
|
|
||||||
RSVPAnswer.NOWAY -> colorRoleNoway()
|
|
||||||
null -> colorRoleUnknown()
|
|
||||||
}
|
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = modifier,
|
||||||
value = value,
|
value = value,
|
||||||
onValueChange = onValueChange,
|
onValueChange = onChange,
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
shape = MaterialTheme.shapes.small,
|
shape = MaterialTheme.shapes.small,
|
||||||
placeholder = {
|
placeholder = {
|
||||||
Text(
|
Text(
|
||||||
text = when (rsvpAnswer) {
|
text = stringResource(currentRsvpAnswer.toPlaceholderResourceId())
|
||||||
RSVPAnswer.SURE -> stringResource(R.string.room_rsvp_sure_placeholder)
|
|
||||||
RSVPAnswer.LATER -> stringResource(R.string.room_rsvp_later_placeholder)
|
|
||||||
RSVPAnswer.MAYBE -> stringResource(R.string.room_rsvp_maybe_placeholder)
|
|
||||||
RSVPAnswer.NOWAY -> stringResource(R.string.room_rsvp_noway_placeholder)
|
|
||||||
null -> stringResource(R.string.room_rsvp_unknown_placeholder)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
colors = if (rsvpAnswer != null) {
|
colors = if (currentRsvpAnswer != null) {
|
||||||
OutlinedTextFieldDefaults.colors(
|
OutlinedTextFieldDefaults.colors(
|
||||||
focusedContainerColor = colorRole.valueContainer,
|
focusedContainerColor = colorRole.valueContainer,
|
||||||
unfocusedContainerColor = colorRole.valueContainer,
|
unfocusedContainerColor = colorRole.valueContainer,
|
|
@ -1,5 +1,7 @@
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
package eu.steffo.twom.room
|
||||||
|
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
@ -7,21 +9,29 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.room.RSVPAnswer
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
||||||
fun RoomActivityUpdateButton(
|
fun RSVPUpdateButton(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
enabled: Boolean = true,
|
||||||
onClick: () -> Unit = {},
|
onClick: () -> Unit = {},
|
||||||
rsvpAnswer: RSVPAnswer? = null,
|
currentRsvpAnswer: RSVPAnswer? = null,
|
||||||
) {
|
) {
|
||||||
|
val colorRole = currentRsvpAnswer.toStaticColorRole()
|
||||||
|
|
||||||
Button(
|
Button(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = modifier,
|
||||||
|
enabled = enabled,
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
shape = MaterialTheme.shapes.small,
|
shape = MaterialTheme.shapes.small,
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
containerColor = colorRole.value,
|
||||||
|
contentColor = colorRole.onValue,
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.room_update_label)
|
text = stringResource(R.string.room_update_label)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,46 @@
|
||||||
package eu.steffo.twom.room
|
package eu.steffo.twom.room
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
||||||
fun RoomActivityAnswerForm() {
|
fun RoomActivityAnswerForm(
|
||||||
|
currentRsvpAnswer: RSVPAnswer? = null,
|
||||||
|
currentRsvpComment: String = "",
|
||||||
|
onUpdate: (rsvpAnswer: RSVPAnswer?, rsvpComment: String) -> Unit = { _, _ -> },
|
||||||
|
) {
|
||||||
|
var rsvpAnswer by rememberSaveable { mutableStateOf(currentRsvpAnswer) }
|
||||||
|
var rsvpComment by rememberSaveable { mutableStateOf(currentRsvpComment) }
|
||||||
|
|
||||||
}
|
val hasChanged = (rsvpAnswer != currentRsvpAnswer || rsvpComment != currentRsvpComment)
|
||||||
|
|
||||||
|
RSVPAnswerSelectRow(
|
||||||
|
value = rsvpAnswer,
|
||||||
|
onChange = { rsvpAnswer = it },
|
||||||
|
)
|
||||||
|
RSVPCommentField(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(start = 10.dp, end = 10.dp)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
value = rsvpComment,
|
||||||
|
onChange = { rsvpComment = it },
|
||||||
|
currentRsvpAnswer = rsvpAnswer,
|
||||||
|
)
|
||||||
|
RSVPUpdateButton(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(start = 10.dp, end = 10.dp, top = 4.dp, bottom = 4.dp)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
onClick = { onUpdate(rsvpAnswer, rsvpComment) },
|
||||||
|
enabled = hasChanged,
|
||||||
|
currentRsvpAnswer = rsvpAnswer,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
package eu.steffo.twom.room
|
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.res.stringResource
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
import eu.steffo.twom.R
|
|
||||||
import eu.steffo.twom.theme.colorRoleLater
|
|
||||||
import eu.steffo.twom.theme.iconRoleLater
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Preview
|
|
||||||
fun RoomActivityChipLater(
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
selected: Boolean = false,
|
|
||||||
onClick: () -> Unit = {},
|
|
||||||
) {
|
|
||||||
RoomActivityChip(
|
|
||||||
selected = selected,
|
|
||||||
onClick = onClick,
|
|
||||||
imageVector = iconRoleLater,
|
|
||||||
text = stringResource(R.string.room_rsvp_later_label),
|
|
||||||
colorRole = colorRoleLater(),
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package eu.steffo.twom.room
|
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.res.stringResource
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
import eu.steffo.twom.R
|
|
||||||
import eu.steffo.twom.theme.colorRoleMaybe
|
|
||||||
import eu.steffo.twom.theme.iconRoleMaybe
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Preview
|
|
||||||
fun RoomActivityChipMaybe(
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
selected: Boolean = false,
|
|
||||||
onClick: () -> Unit = {},
|
|
||||||
) {
|
|
||||||
// TODO: Pick a better color
|
|
||||||
RoomActivityChip(
|
|
||||||
selected = selected,
|
|
||||||
onClick = onClick,
|
|
||||||
imageVector = iconRoleMaybe,
|
|
||||||
text = stringResource(R.string.room_rsvp_maybe_label),
|
|
||||||
colorRole = colorRoleMaybe(),
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package eu.steffo.twom.room
|
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.res.stringResource
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
import eu.steffo.twom.R
|
|
||||||
import eu.steffo.twom.theme.colorRoleNoway
|
|
||||||
import eu.steffo.twom.theme.iconRoleNoway
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Preview
|
|
||||||
fun RoomActivityChipNoway(
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
selected: Boolean = false,
|
|
||||||
onClick: () -> Unit = {},
|
|
||||||
) {
|
|
||||||
RoomActivityChip(
|
|
||||||
selected = selected,
|
|
||||||
onClick = onClick,
|
|
||||||
imageVector = iconRoleNoway,
|
|
||||||
text = stringResource(R.string.room_rsvp_noway_label),
|
|
||||||
colorRole = colorRoleNoway(),
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package eu.steffo.twom.room
|
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.res.stringResource
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
import eu.steffo.twom.R
|
|
||||||
import eu.steffo.twom.theme.colorRoleSure
|
|
||||||
import eu.steffo.twom.theme.iconRoleSure
|
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Preview
|
|
||||||
fun RoomActivityChipSure(
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
selected: Boolean = false,
|
|
||||||
onClick: () -> Unit = {},
|
|
||||||
) {
|
|
||||||
RoomActivityChip(
|
|
||||||
selected = selected,
|
|
||||||
onClick = onClick,
|
|
||||||
imageVector = iconRoleSure,
|
|
||||||
text = stringResource(R.string.room_rsvp_sure_label),
|
|
||||||
colorRole = colorRoleSure(),
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -1,9 +1,7 @@
|
||||||
package eu.steffo.twom.room
|
package eu.steffo.twom.room
|
||||||
|
|
||||||
import RoomActivityUpdateButton
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
@ -13,7 +11,6 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.matrix.LocalSession
|
import eu.steffo.twom.matrix.LocalSession
|
||||||
import eu.steffo.twom.theme.TwoMPadding
|
import eu.steffo.twom.theme.TwoMPadding
|
||||||
|
@ -49,26 +46,15 @@ fun RoomActivityContent(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomActivityChipSelector(
|
RoomActivityAnswerForm(
|
||||||
value = rsvpAnswer,
|
currentRsvpAnswer = rsvpAnswer,
|
||||||
onChange = { rsvpAnswer = it }
|
currentRsvpComment = rsvpComment,
|
||||||
|
onUpdate = { answer, comment ->
|
||||||
|
rsvpAnswer = answer
|
||||||
|
rsvpComment = comment
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
Row(Modifier.padding(start = 10.dp, end = 10.dp)) {
|
|
||||||
RoomActivityCommentField(
|
|
||||||
value = rsvpComment,
|
|
||||||
onValueChange = { rsvpComment = it },
|
|
||||||
rsvpAnswer = rsvpAnswer,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Row(Modifier.padding(all = 10.dp)) {
|
|
||||||
RoomActivityUpdateButton(
|
|
||||||
onClick = {},
|
|
||||||
rsvpAnswer = rsvpAnswer,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Row(TwoMPadding.base) {
|
Row(TwoMPadding.base) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.room_invitees_title),
|
text = stringResource(R.string.room_invitees_title),
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package eu.steffo.twom.theme
|
package eu.steffo.twom.theme
|
||||||
|
|
||||||
import androidx.compose.material3.LocalContentColor
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun colorRoleUnknown(): StaticColorRole {
|
fun colorRoleUnknown(): StaticColorRole {
|
||||||
return StaticColorRole(
|
return StaticColorRole(
|
||||||
value = LocalContentColor.current,
|
value = MaterialTheme.colorScheme.inverseSurface,
|
||||||
onValue = LocalContentColor.current,
|
onValue = MaterialTheme.colorScheme.inverseOnSurface,
|
||||||
valueContainer = LocalContentColor.current,
|
valueContainer = MaterialTheme.colorScheme.surfaceVariant,
|
||||||
onValueContainer = LocalContentColor.current,
|
onValueContainer = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,4 @@ package eu.steffo.twom.theme
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.Schedule
|
import androidx.compose.material.icons.outlined.Schedule
|
||||||
|
|
||||||
val iconRoleLater = Icons.Outlined.Schedule
|
val iconLater = Icons.Outlined.Schedule
|
|
@ -3,4 +3,4 @@ package eu.steffo.twom.theme
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.PauseCircle
|
import androidx.compose.material.icons.outlined.PauseCircle
|
||||||
|
|
||||||
val iconRoleMaybe = Icons.Outlined.PauseCircle
|
val iconMaybe = Icons.Outlined.PauseCircle
|
|
@ -3,4 +3,4 @@ package eu.steffo.twom.theme
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.RemoveCircleOutline
|
import androidx.compose.material.icons.outlined.RemoveCircleOutline
|
||||||
|
|
||||||
val iconRoleNoway = Icons.Outlined.RemoveCircleOutline
|
val iconNoway = Icons.Outlined.RemoveCircleOutline
|
|
@ -3,4 +3,4 @@ package eu.steffo.twom.theme
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.CheckCircle
|
import androidx.compose.material.icons.outlined.CheckCircle
|
||||||
|
|
||||||
val iconRoleSure = Icons.Outlined.CheckCircle
|
val iconSure = Icons.Outlined.CheckCircle
|
|
@ -3,4 +3,4 @@ package eu.steffo.twom.theme
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.Circle
|
import androidx.compose.material.icons.outlined.Circle
|
||||||
|
|
||||||
val iconRoleUnknown = Icons.Outlined.Circle
|
val iconUnknown = Icons.Outlined.Circle
|
Loading…
Reference in a new issue