changed stealthbutton to blue + disbale feed continue when task or subject is archived

This commit is contained in:
lbarraga 2023-05-09 23:12:52 +02:00
parent d22d40439d
commit 875732fd2d
4 changed files with 33 additions and 19 deletions

View file

@ -2,6 +2,7 @@ package be.ugent.sel.studeez.common.composable
import androidx.annotation.StringRes
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
@ -49,6 +50,7 @@ fun BasicButton(
modifier: Modifier = Modifier,
colors: ButtonColors = ButtonDefaults.buttonColors(),
border: BorderStroke? = null,
enabled: Boolean = true,
onClick: () -> Unit,
) {
Button(
@ -57,6 +59,7 @@ fun BasicButton(
shape = defaultButtonShape(),
colors = colors,
border = border,
enabled = enabled,
) {
Text(
text = stringResource(text),
@ -75,17 +78,22 @@ fun BasicButtonPreview() {
fun StealthButton(
@StringRes text: Int,
modifier: Modifier = Modifier.card(),
enabled: Boolean = true,
onClick: () -> Unit,
) {
//val clickablemodifier = if (disabled) Modifier.clickable(indication = null) else modifier
val borderColor = if (enabled) MaterialTheme.colors.primary
else MaterialTheme.colors.onSurface.copy(alpha = 0.3f)
BasicButton(
text = text,
onClick = onClick,
modifier = modifier,
enabled = enabled,
colors = ButtonDefaults.buttonColors(
backgroundColor = MaterialTheme.colors.surface,
contentColor = MaterialTheme.colors.onSurface.copy(alpha = 0.4f)
contentColor = borderColor
),
border = BorderStroke(2.dp, MaterialTheme.colors.onSurface.copy(alpha = 0.4f))
border = BorderStroke(2.dp, borderColor)
)
}

View file

@ -4,10 +4,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Card
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Info
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -19,9 +16,9 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import be.ugent.sel.studeez.R
import be.ugent.sel.studeez.common.composable.StealthButton
import be.ugent.sel.studeez.common.ext.fieldModifier
import be.ugent.sel.studeez.data.local.models.FeedEntry
import be.ugent.sel.studeez.data.local.models.timer_functional.HoursMinutesSeconds
import be.ugent.sel.studeez.R.string as AppText
@Composable
fun FeedEntry(
@ -73,21 +70,19 @@ fun FeedEntry(
Text(text = HoursMinutesSeconds(feedEntry.totalStudyTime).toString())
}
}
if (!feedEntry.isArchived) {
StealthButton(
text = R.string.continue_task,
modifier = Modifier
.padding(start = 10.dp, end = 5.dp)
.weight(6f)
) {
val buttonText: Int = if (feedEntry.isArchived) AppText.deleted else AppText.continue_task
StealthButton(
text = buttonText,
enabled = !feedEntry.isArchived,
modifier = Modifier
.padding(start = 10.dp, end = 5.dp)
.weight(6f)
) {
if (!feedEntry.isArchived) {
continueWithTask()
}
} else {
Row {
Icon(imageVector = Icons.Default.Info, contentDescription = null)
Text(text = "Deleted", modifier = Modifier.padding(horizontal = 5.dp))
}
}
}
}
}

View file

@ -1,14 +1,25 @@
package be.ugent.sel.studeez.common.ext
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.unit.dp
fun Modifier.textButton(): Modifier {
return this.fillMaxWidth().padding(16.dp, 8.dp, 16.dp, 0.dp)
}
fun Modifier.noRippleClickable(onClick: () -> Unit): Modifier = composed {
clickable(indication = null,
interactionSource = remember { MutableInteractionSource() }) {
onClick()
}
}
fun Modifier.basicButton(): Modifier {
return this.fillMaxWidth().padding(16.dp, 8.dp)
}

View file

@ -75,7 +75,7 @@ class FirebaseFeedDAO @Inject constructor(
subjectId = subject.id,
totalStudyTime = sessionReport.studyTime,
endTime = sessionReport.endTime,
isArchived = task.completed
isArchived = task.archived || subject.archived
)
}
}