mirror of
https://github.com/Steffo99/twom.git
synced 2024-11-21 23:54:26 +00:00
Progress checkpoint
This commit is contained in:
parent
4b03307901
commit
6aeea6d170
10 changed files with 200 additions and 83 deletions
|
@ -22,7 +22,8 @@ android {
|
|||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
|
|
|
@ -11,7 +11,6 @@ import androidx.compose.material3.Text
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.steffo.twom.R
|
||||
|
@ -21,10 +20,12 @@ 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
|
||||
|
||||
// TODO: Check this with brain on
|
||||
|
@ -41,18 +42,36 @@ fun MemberListItem(
|
|||
|
||||
val user = session?.getUser(memberId)
|
||||
|
||||
// TODO: These are going to get cached many times...
|
||||
val crSure = colorRoleSure()
|
||||
val crLater = colorRoleLater()
|
||||
val crMaybe = colorRoleMaybe()
|
||||
val crNoway = colorRoleNoway()
|
||||
val colorRole = when (rsvpAnswer) {
|
||||
RSVPAnswer.SURE -> colorRoleSure()
|
||||
RSVPAnswer.LATER -> colorRoleLater()
|
||||
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(
|
||||
modifier = Modifier.clickable {
|
||||
modifier = modifier.clickable {
|
||||
onClickMember(memberId)
|
||||
},
|
||||
headlineContent = {
|
||||
Text(user?.displayName ?: stringResource(R.string.user_unresolved_name))
|
||||
Text(
|
||||
text = user?.displayName ?: stringResource(R.string.user_unresolved_name),
|
||||
)
|
||||
},
|
||||
leadingContent = {
|
||||
Box(
|
||||
|
@ -67,53 +86,17 @@ fun MemberListItem(
|
|||
}
|
||||
},
|
||||
trailingContent = {
|
||||
when (rsvpAnswer) {
|
||||
RSVPAnswer.SURE -> {
|
||||
Icon(
|
||||
imageVector = iconRoleSure,
|
||||
contentDescription = stringResource(R.string.room_rsvp_sure_label),
|
||||
tint = crSure.value,
|
||||
)
|
||||
}
|
||||
|
||||
RSVPAnswer.LATER -> {
|
||||
Icon(
|
||||
imageVector = iconRoleLater,
|
||||
contentDescription = stringResource(R.string.room_rsvp_later_label),
|
||||
tint = crLater.value,
|
||||
)
|
||||
}
|
||||
|
||||
RSVPAnswer.MAYBE -> {
|
||||
Icon(
|
||||
imageVector = iconRoleMaybe,
|
||||
contentDescription = stringResource(R.string.room_rsvp_maybe_label),
|
||||
tint = crMaybe.value,
|
||||
)
|
||||
}
|
||||
|
||||
RSVPAnswer.NOWAY -> {
|
||||
Icon(
|
||||
imageVector = iconRoleNoway,
|
||||
contentDescription = stringResource(R.string.room_rsvp_later_label),
|
||||
tint = crNoway.value,
|
||||
)
|
||||
}
|
||||
|
||||
null -> {}
|
||||
}
|
||||
Icon(
|
||||
imageVector = iconRole,
|
||||
contentDescription = iconDescription,
|
||||
tint = colorRole.value,
|
||||
)
|
||||
},
|
||||
supportingContent = {
|
||||
if (rsvpComment != "") {
|
||||
Text(
|
||||
text = rsvpComment,
|
||||
color = when (rsvpAnswer) {
|
||||
RSVPAnswer.SURE -> crSure.value
|
||||
RSVPAnswer.LATER -> crLater.value
|
||||
RSVPAnswer.MAYBE -> crMaybe.value
|
||||
RSVPAnswer.NOWAY -> crNoway.value
|
||||
null -> Color.Unspecified
|
||||
}
|
||||
color = colorRole.value,
|
||||
)
|
||||
}
|
||||
},
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package eu.steffo.twom.room
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun RoomActivityAnswerForm() {
|
||||
|
||||
}
|
|
@ -1,28 +1,27 @@
|
|||
package eu.steffo.twom.room
|
||||
|
||||
import androidx.compose.material3.ElevatedFilterChip
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FilterChip
|
||||
import androidx.compose.material3.FilterChipDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.steffo.twom.theme.StaticColorRole
|
||||
import eu.steffo.twom.theme.TwoMPadding
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun RoomActivityChip(
|
||||
modifier: Modifier = Modifier,
|
||||
selected: Boolean = false,
|
||||
onClick: () -> Unit = {},
|
||||
text: String,
|
||||
imageVector: ImageVector,
|
||||
colorRole: StaticColorRole,
|
||||
) {
|
||||
ElevatedFilterChip(
|
||||
FilterChip(
|
||||
modifier = TwoMPadding.chips,
|
||||
selected = selected,
|
||||
onClick = onClick,
|
||||
|
@ -35,15 +34,21 @@ fun RoomActivityChip(
|
|||
label = {
|
||||
Text(
|
||||
text = text,
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
)
|
||||
},
|
||||
colors = FilterChipDefaults.elevatedFilterChipColors(
|
||||
colors = FilterChipDefaults.filterChipColors(
|
||||
iconColor = colorRole.value,
|
||||
labelColor = colorRole.value,
|
||||
selectedContainerColor = colorRole.valueContainer,
|
||||
selectedLeadingIconColor = colorRole.onValueContainer,
|
||||
selectedLabelColor = colorRole.onValueContainer,
|
||||
),
|
||||
border = FilterChipDefaults.filterChipBorder(
|
||||
borderColor = MaterialTheme.colorScheme.surfaceVariant,
|
||||
selectedBorderColor = colorRole.onValueContainer,
|
||||
borderWidth = 1.dp,
|
||||
selectedBorderWidth = 1.dp,
|
||||
)
|
||||
)
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package eu.steffo.twom.room
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.OutlinedTextFieldDefaults
|
||||
import androidx.compose.material3.Text
|
||||
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.colorRoleMaybe
|
||||
import eu.steffo.twom.theme.colorRoleNoway
|
||||
import eu.steffo.twom.theme.colorRoleSure
|
||||
import eu.steffo.twom.theme.colorRoleUnknown
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun RoomActivityCommentField(
|
||||
modifier: Modifier = Modifier,
|
||||
value: String = "",
|
||||
onValueChange: (value: String) -> Unit = {},
|
||||
rsvpAnswer: RSVPAnswer? = null,
|
||||
) {
|
||||
val colorRole = when (rsvpAnswer) {
|
||||
RSVPAnswer.SURE -> colorRoleSure()
|
||||
RSVPAnswer.LATER -> colorRoleLater()
|
||||
RSVPAnswer.MAYBE -> colorRoleMaybe()
|
||||
RSVPAnswer.NOWAY -> colorRoleNoway()
|
||||
null -> colorRoleUnknown()
|
||||
}
|
||||
|
||||
OutlinedTextField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
value = value,
|
||||
onValueChange = onValueChange,
|
||||
singleLine = true,
|
||||
shape = MaterialTheme.shapes.small,
|
||||
placeholder = {
|
||||
Text(
|
||||
text = when (rsvpAnswer) {
|
||||
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) {
|
||||
OutlinedTextFieldDefaults.colors(
|
||||
focusedContainerColor = colorRole.valueContainer,
|
||||
unfocusedContainerColor = colorRole.valueContainer,
|
||||
focusedTextColor = colorRole.onValueContainer,
|
||||
unfocusedTextColor = colorRole.onValueContainer,
|
||||
focusedBorderColor = colorRole.onValueContainer,
|
||||
unfocusedBorderColor = colorRole.onValueContainer.copy(alpha = 0.3f),
|
||||
cursorColor = colorRole.onValueContainer,
|
||||
)
|
||||
} else {
|
||||
OutlinedTextFieldDefaults.colors(
|
||||
focusedBorderColor = LocalContentColor.current,
|
||||
unfocusedBorderColor = MaterialTheme.colorScheme.surfaceVariant,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
|
@ -1,19 +1,17 @@
|
|||
package eu.steffo.twom.room
|
||||
|
||||
import RoomActivityUpdateButton
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
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.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.steffo.twom.R
|
||||
|
@ -37,7 +35,7 @@ fun RoomActivityContent(
|
|||
Row(TwoMPadding.base) {
|
||||
Text(
|
||||
text = stringResource(R.string.room_topic_title),
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
)
|
||||
}
|
||||
Row(TwoMPadding.base) {
|
||||
|
@ -47,7 +45,7 @@ fun RoomActivityContent(
|
|||
Row(TwoMPadding.base) {
|
||||
Text(
|
||||
text = stringResource(R.string.room_rsvp_title),
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -56,24 +54,25 @@ fun RoomActivityContent(
|
|||
onChange = { rsvpAnswer = it }
|
||||
)
|
||||
|
||||
if (rsvpAnswer != null) {
|
||||
Row(Modifier.padding(start = 10.dp, end = 10.dp, bottom = 10.dp)) {
|
||||
TextField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
value = rsvpComment,
|
||||
onValueChange = { rsvpComment = it },
|
||||
placeholder = {
|
||||
Text(LocalContext.current.getString(R.string.room_rsvp_comment_placeholder))
|
||||
},
|
||||
)
|
||||
}
|
||||
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) {
|
||||
Text(
|
||||
text = stringResource(R.string.room_invitees_title),
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -82,11 +81,7 @@ fun RoomActivityContent(
|
|||
MemberListItem(
|
||||
memberId = LocalSession.current!!.myUserId,
|
||||
rsvpAnswer = rsvpAnswer,
|
||||
rsvpComment = if (rsvpAnswer != null) {
|
||||
rsvpComment
|
||||
} else {
|
||||
""
|
||||
},
|
||||
rsvpComment = rsvpComment,
|
||||
)
|
||||
|
||||
roomSummary.otherMemberIds.forEach {
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
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.room.RSVPAnswer
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun RoomActivityUpdateButton(
|
||||
onClick: () -> Unit = {},
|
||||
rsvpAnswer: RSVPAnswer? = null,
|
||||
) {
|
||||
Button(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onClick = onClick,
|
||||
shape = MaterialTheme.shapes.small,
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.room_update_label)
|
||||
)
|
||||
}
|
||||
}
|
14
app/src/main/java/eu/steffo/twom/theme/colorRoleUnknown.kt
Normal file
14
app/src/main/java/eu/steffo/twom/theme/colorRoleUnknown.kt
Normal file
|
@ -0,0 +1,14 @@
|
|||
package eu.steffo.twom.theme
|
||||
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
fun colorRoleUnknown(): StaticColorRole {
|
||||
return StaticColorRole(
|
||||
value = LocalContentColor.current,
|
||||
onValue = LocalContentColor.current,
|
||||
valueContainer = LocalContentColor.current,
|
||||
onValueContainer = LocalContentColor.current,
|
||||
)
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package eu.steffo.twom.theme
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Circle
|
||||
|
||||
val iconRoleUnknown = Icons.Outlined.Circle
|
|
@ -23,7 +23,7 @@
|
|||
<string name="main_account_label">My account</string>
|
||||
<string name="main_account_logout_text">Logout</string>
|
||||
<string name="main_roomlist_empty_text">There are no rooms.</string>
|
||||
<string name="loading">Loading...</string>
|
||||
<string name="loading">Loading…</string>
|
||||
<string name="main_efab_create_text">New</string>
|
||||
<string name="main_notloggedin_text_2">Log into your Matrix account by clicking the icon on the top right of the screen.</string>
|
||||
<string name="main_account_login_text">Login</string>
|
||||
|
@ -39,7 +39,7 @@
|
|||
<string name="room_invitees_title">Invitees</string>
|
||||
<string name="room_rsvp_title">Your reply</string>
|
||||
<string name="room_rsvp_sure_label">Sure!</string>
|
||||
<string name="room_rsvp_later_label">I\'ll be late...</string>
|
||||
<string name="room_rsvp_later_label">I\'ll be late…</string>
|
||||
<string name="room_rsvp_maybe_label">Maybe?</string>
|
||||
<string name="room_rsvp_noway_label">Nope.</string>
|
||||
<string name="room_topic_title">About this party</string>
|
||||
|
@ -48,5 +48,11 @@
|
|||
<string name="room_rsvp_later_response">Will arrive late</string>
|
||||
<string name="room_rsvp_maybe_response">Will maybe partecipate</string>
|
||||
<string name="room_rsvp_noway_response">Won\'t be there</string>
|
||||
<string name="room_rsvp_comment_placeholder">Leave a comment...</string>
|
||||
<string name="room_rsvp_sure_placeholder">Anything to add?</string>
|
||||
<string name="room_rsvp_later_placeholder">Why will you be late?</string>
|
||||
<string name="room_rsvp_maybe_placeholder">What will determine your partecipation?</string>
|
||||
<string name="room_rsvp_noway_placeholder">Why won\'t you partecipate?</string>
|
||||
<string name="room_rsvp_unknown_response">Hasn\'t answered yet</string>
|
||||
<string name="room_rsvp_unknown_placeholder">Leave a comment…</string>
|
||||
<string name="room_update_label">Update</string>
|
||||
</resources>
|
Loading…
Reference in a new issue