changed stealthbutton to blue + disbale feed continue when task or subject is archived
This commit is contained in:
parent
d22d40439d
commit
875732fd2d
4 changed files with 33 additions and 19 deletions
|
@ -2,6 +2,7 @@ package be.ugent.sel.studeez.common.composable
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.compose.foundation.BorderStroke
|
import androidx.compose.foundation.BorderStroke
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
@ -49,6 +50,7 @@ fun BasicButton(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
colors: ButtonColors = ButtonDefaults.buttonColors(),
|
colors: ButtonColors = ButtonDefaults.buttonColors(),
|
||||||
border: BorderStroke? = null,
|
border: BorderStroke? = null,
|
||||||
|
enabled: Boolean = true,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Button(
|
Button(
|
||||||
|
@ -57,6 +59,7 @@ fun BasicButton(
|
||||||
shape = defaultButtonShape(),
|
shape = defaultButtonShape(),
|
||||||
colors = colors,
|
colors = colors,
|
||||||
border = border,
|
border = border,
|
||||||
|
enabled = enabled,
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(text),
|
text = stringResource(text),
|
||||||
|
@ -75,17 +78,22 @@ fun BasicButtonPreview() {
|
||||||
fun StealthButton(
|
fun StealthButton(
|
||||||
@StringRes text: Int,
|
@StringRes text: Int,
|
||||||
modifier: Modifier = Modifier.card(),
|
modifier: Modifier = Modifier.card(),
|
||||||
|
enabled: Boolean = true,
|
||||||
onClick: () -> Unit,
|
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(
|
BasicButton(
|
||||||
text = text,
|
text = text,
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
|
enabled = enabled,
|
||||||
colors = ButtonDefaults.buttonColors(
|
colors = ButtonDefaults.buttonColors(
|
||||||
backgroundColor = MaterialTheme.colors.surface,
|
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)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,7 @@ import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.material.Card
|
import androidx.compose.material.Card
|
||||||
import androidx.compose.material.Icon
|
|
||||||
import androidx.compose.material.Text
|
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.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -19,9 +16,9 @@ import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import be.ugent.sel.studeez.R
|
import be.ugent.sel.studeez.R
|
||||||
import be.ugent.sel.studeez.common.composable.StealthButton
|
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.FeedEntry
|
||||||
import be.ugent.sel.studeez.data.local.models.timer_functional.HoursMinutesSeconds
|
import be.ugent.sel.studeez.data.local.models.timer_functional.HoursMinutesSeconds
|
||||||
|
import be.ugent.sel.studeez.R.string as AppText
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun FeedEntry(
|
fun FeedEntry(
|
||||||
|
@ -73,21 +70,19 @@ fun FeedEntry(
|
||||||
Text(text = HoursMinutesSeconds(feedEntry.totalStudyTime).toString())
|
Text(text = HoursMinutesSeconds(feedEntry.totalStudyTime).toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!feedEntry.isArchived) {
|
val buttonText: Int = if (feedEntry.isArchived) AppText.deleted else AppText.continue_task
|
||||||
StealthButton(
|
StealthButton(
|
||||||
text = R.string.continue_task,
|
text = buttonText,
|
||||||
|
enabled = !feedEntry.isArchived,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(start = 10.dp, end = 5.dp)
|
.padding(start = 10.dp, end = 5.dp)
|
||||||
.weight(6f)
|
.weight(6f)
|
||||||
) {
|
) {
|
||||||
|
if (!feedEntry.isArchived) {
|
||||||
continueWithTask()
|
continueWithTask()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Row {
|
|
||||||
Icon(imageVector = Icons.Default.Info, contentDescription = null)
|
|
||||||
Text(text = "Deleted", modifier = Modifier.padding(horizontal = 5.dp))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,25 @@
|
||||||
package be.ugent.sel.studeez.common.ext
|
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.foundation.layout.*
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.composed
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
fun Modifier.textButton(): Modifier {
|
fun Modifier.textButton(): Modifier {
|
||||||
return this.fillMaxWidth().padding(16.dp, 8.dp, 16.dp, 0.dp)
|
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 {
|
fun Modifier.basicButton(): Modifier {
|
||||||
return this.fillMaxWidth().padding(16.dp, 8.dp)
|
return this.fillMaxWidth().padding(16.dp, 8.dp)
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ class FirebaseFeedDAO @Inject constructor(
|
||||||
subjectId = subject.id,
|
subjectId = subject.id,
|
||||||
totalStudyTime = sessionReport.studyTime,
|
totalStudyTime = sessionReport.studyTime,
|
||||||
endTime = sessionReport.endTime,
|
endTime = sessionReport.endTime,
|
||||||
isArchived = task.completed
|
isArchived = task.archived || subject.archived
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in a new issue