1
Fork 0
mirror of https://github.com/Steffo99/twom.git synced 2024-11-25 09:34:25 +00:00

Progress checkpoint

This commit is contained in:
Steffo 2024-01-08 04:33:03 +01:00
parent 4b03307901
commit 6aeea6d170
Signed by: steffo
GPG key ID: 2A24051445686895
10 changed files with 200 additions and 83 deletions

View file

@ -22,7 +22,8 @@ android {
buildTypes { buildTypes {
release { release {
isMinifyEnabled = false isMinifyEnabled = true
isShrinkResources = true
proguardFiles( proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro" "proguard-rules.pro"

View file

@ -11,7 +11,6 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import eu.steffo.twom.R 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.colorRoleMaybe
import eu.steffo.twom.theme.colorRoleNoway import eu.steffo.twom.theme.colorRoleNoway
import eu.steffo.twom.theme.colorRoleSure import eu.steffo.twom.theme.colorRoleSure
import eu.steffo.twom.theme.colorRoleUnknown
import eu.steffo.twom.theme.iconRoleLater import eu.steffo.twom.theme.iconRoleLater
import eu.steffo.twom.theme.iconRoleMaybe import eu.steffo.twom.theme.iconRoleMaybe
import eu.steffo.twom.theme.iconRoleNoway import eu.steffo.twom.theme.iconRoleNoway
import eu.steffo.twom.theme.iconRoleSure 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
@ -41,18 +42,36 @@ fun MemberListItem(
val user = session?.getUser(memberId) val user = session?.getUser(memberId)
// TODO: These are going to get cached many times... val colorRole = when (rsvpAnswer) {
val crSure = colorRoleSure() RSVPAnswer.SURE -> colorRoleSure()
val crLater = colorRoleLater() RSVPAnswer.LATER -> colorRoleLater()
val crMaybe = colorRoleMaybe() RSVPAnswer.MAYBE -> colorRoleMaybe()
val crNoway = colorRoleNoway() 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 {
onClickMember(memberId) onClickMember(memberId)
}, },
headlineContent = { headlineContent = {
Text(user?.displayName ?: stringResource(R.string.user_unresolved_name)) Text(
text = user?.displayName ?: stringResource(R.string.user_unresolved_name),
)
}, },
leadingContent = { leadingContent = {
Box( Box(
@ -67,53 +86,17 @@ fun MemberListItem(
} }
}, },
trailingContent = { trailingContent = {
when (rsvpAnswer) {
RSVPAnswer.SURE -> {
Icon( Icon(
imageVector = iconRoleSure, imageVector = iconRole,
contentDescription = stringResource(R.string.room_rsvp_sure_label), contentDescription = iconDescription,
tint = crSure.value, tint = colorRole.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 -> {}
}
}, },
supportingContent = { supportingContent = {
if (rsvpComment != "") { if (rsvpComment != "") {
Text( Text(
text = rsvpComment, text = rsvpComment,
color = when (rsvpAnswer) { color = colorRole.value,
RSVPAnswer.SURE -> crSure.value
RSVPAnswer.LATER -> crLater.value
RSVPAnswer.MAYBE -> crMaybe.value
RSVPAnswer.NOWAY -> crNoway.value
null -> Color.Unspecified
}
) )
} }
}, },

View file

@ -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() {
}

View file

@ -1,28 +1,27 @@
package eu.steffo.twom.room package eu.steffo.twom.room
import androidx.compose.material3.ElevatedFilterChip
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilterChip
import androidx.compose.material3.FilterChipDefaults import androidx.compose.material3.FilterChipDefaults
import androidx.compose.material3.Icon 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.Modifier
import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
import eu.steffo.twom.theme.StaticColorRole import eu.steffo.twom.theme.StaticColorRole
import eu.steffo.twom.theme.TwoMPadding import eu.steffo.twom.theme.TwoMPadding
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun RoomActivityChip( fun RoomActivityChip(
modifier: Modifier = Modifier,
selected: Boolean = false, selected: Boolean = false,
onClick: () -> Unit = {}, onClick: () -> Unit = {},
text: String, text: String,
imageVector: ImageVector, imageVector: ImageVector,
colorRole: StaticColorRole, colorRole: StaticColorRole,
) { ) {
ElevatedFilterChip( FilterChip(
modifier = TwoMPadding.chips, modifier = TwoMPadding.chips,
selected = selected, selected = selected,
onClick = onClick, onClick = onClick,
@ -35,15 +34,21 @@ fun RoomActivityChip(
label = { label = {
Text( Text(
text = text, text = text,
style = MaterialTheme.typography.labelLarge, style = MaterialTheme.typography.bodyLarge,
) )
}, },
colors = FilterChipDefaults.elevatedFilterChipColors( colors = FilterChipDefaults.filterChipColors(
iconColor = colorRole.value, iconColor = colorRole.value,
labelColor = colorRole.value, labelColor = colorRole.value,
selectedContainerColor = colorRole.valueContainer, selectedContainerColor = colorRole.valueContainer,
selectedLeadingIconColor = colorRole.onValueContainer, selectedLeadingIconColor = colorRole.onValueContainer,
selectedLabelColor = colorRole.onValueContainer, selectedLabelColor = colorRole.onValueContainer,
), ),
border = FilterChipDefaults.filterChipBorder(
borderColor = MaterialTheme.colorScheme.surfaceVariant,
selectedBorderColor = colorRole.onValueContainer,
borderWidth = 1.dp,
selectedBorderWidth = 1.dp,
)
) )
} }

View file

@ -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,
)
},
)
}

View file

@ -1,19 +1,17 @@
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.fillMaxWidth
import androidx.compose.foundation.layout.padding 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.material3.TextField
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable 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.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import eu.steffo.twom.R import eu.steffo.twom.R
@ -37,7 +35,7 @@ fun RoomActivityContent(
Row(TwoMPadding.base) { Row(TwoMPadding.base) {
Text( Text(
text = stringResource(R.string.room_topic_title), text = stringResource(R.string.room_topic_title),
style = MaterialTheme.typography.titleMedium style = MaterialTheme.typography.labelLarge,
) )
} }
Row(TwoMPadding.base) { Row(TwoMPadding.base) {
@ -47,7 +45,7 @@ fun RoomActivityContent(
Row(TwoMPadding.base) { Row(TwoMPadding.base) {
Text( Text(
text = stringResource(R.string.room_rsvp_title), text = stringResource(R.string.room_rsvp_title),
style = MaterialTheme.typography.titleMedium style = MaterialTheme.typography.labelLarge,
) )
} }
@ -56,24 +54,25 @@ fun RoomActivityContent(
onChange = { rsvpAnswer = it } onChange = { rsvpAnswer = it }
) )
if (rsvpAnswer != null) { Row(Modifier.padding(start = 10.dp, end = 10.dp)) {
Row(Modifier.padding(start = 10.dp, end = 10.dp, bottom = 10.dp)) { RoomActivityCommentField(
TextField(
modifier = Modifier.fillMaxWidth(),
singleLine = true,
value = rsvpComment, value = rsvpComment,
onValueChange = { rsvpComment = it }, onValueChange = { rsvpComment = it },
placeholder = { rsvpAnswer = rsvpAnswer,
Text(LocalContext.current.getString(R.string.room_rsvp_comment_placeholder))
},
) )
} }
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),
style = MaterialTheme.typography.titleMedium style = MaterialTheme.typography.labelLarge,
) )
} }
@ -82,11 +81,7 @@ fun RoomActivityContent(
MemberListItem( MemberListItem(
memberId = LocalSession.current!!.myUserId, memberId = LocalSession.current!!.myUserId,
rsvpAnswer = rsvpAnswer, rsvpAnswer = rsvpAnswer,
rsvpComment = if (rsvpAnswer != null) { rsvpComment = rsvpComment,
rsvpComment
} else {
""
},
) )
roomSummary.otherMemberIds.forEach { roomSummary.otherMemberIds.forEach {

View file

@ -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)
)
}
}

View 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,
)
}

View file

@ -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

View file

@ -23,7 +23,7 @@
<string name="main_account_label">My account</string> <string name="main_account_label">My account</string>
<string name="main_account_logout_text">Logout</string> <string name="main_account_logout_text">Logout</string>
<string name="main_roomlist_empty_text">There are no rooms.</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_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_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> <string name="main_account_login_text">Login</string>
@ -39,7 +39,7 @@
<string name="room_invitees_title">Invitees</string> <string name="room_invitees_title">Invitees</string>
<string name="room_rsvp_title">Your reply</string> <string name="room_rsvp_title">Your reply</string>
<string name="room_rsvp_sure_label">Sure!</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_maybe_label">Maybe?</string>
<string name="room_rsvp_noway_label">Nope.</string> <string name="room_rsvp_noway_label">Nope.</string>
<string name="room_topic_title">About this party</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_later_response">Will arrive late</string>
<string name="room_rsvp_maybe_response">Will maybe partecipate</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_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> </resources>