feat: 剩余项目提示

This commit is contained in:
Super12138 2025-01-12 13:36:36 +08:00
parent 3cc10cd216
commit 7ef264509f
3 changed files with 13 additions and 1 deletions

View file

@ -1,5 +1,6 @@
package cn.super12138.todo.ui.pages.main
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
@ -13,8 +14,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import cn.super12138.todo.R
@Composable
fun ProgressFragment(
@ -22,6 +25,7 @@ fun ProgressFragment(
completedTasks: Int,
modifier: Modifier = Modifier
) {
val remainTasks = totalTasks - completedTasks
val progress = if (totalTasks != 0) {
completedTasks / totalTasks.toFloat()
} else {
@ -43,7 +47,7 @@ fun ProgressFragment(
gapSize = 10.dp,
modifier = Modifier.size(170.dp)
)
Column {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Row(verticalAlignment = Alignment.CenterVertically) {
Text(
text = completedTasks.toString(),
@ -64,6 +68,12 @@ fun ProgressFragment(
)
)
}
AnimatedVisibility(remainTasks != 0) {
Text(
text = stringResource(R.string.tip_remain_tasks, remainTasks),
style = MaterialTheme.typography.labelMedium
)
}
}
}
}

View file

@ -21,4 +21,5 @@
<string name="subject_history">历史</string>
<string name="subject_others">其它</string>
<string name="title_edit_task">修改待办</string>
<string name="tip_remain_tasks">剩余 %s 项任务</string>
</resources>

View file

@ -20,4 +20,5 @@
<string name="subject_history">History</string>
<string name="subject_others">Others</string>
<string name="title_edit_task">Edit Task</string>
<string name="tip_remain_tasks">%s tasks remaining</string>
</resources>