feat: 剩余项目提示
This commit is contained in:
parent
3cc10cd216
commit
7ef264509f
3 changed files with 13 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.super12138.todo.ui.pages.main
|
package cn.super12138.todo.ui.pages.main
|
||||||
|
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.core.animateFloatAsState
|
import androidx.compose.animation.core.animateFloatAsState
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
|
@ -13,8 +14,10 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import cn.super12138.todo.R
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ProgressFragment(
|
fun ProgressFragment(
|
||||||
|
|
@ -22,6 +25,7 @@ fun ProgressFragment(
|
||||||
completedTasks: Int,
|
completedTasks: Int,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
|
val remainTasks = totalTasks - completedTasks
|
||||||
val progress = if (totalTasks != 0) {
|
val progress = if (totalTasks != 0) {
|
||||||
completedTasks / totalTasks.toFloat()
|
completedTasks / totalTasks.toFloat()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -43,7 +47,7 @@ fun ProgressFragment(
|
||||||
gapSize = 10.dp,
|
gapSize = 10.dp,
|
||||||
modifier = Modifier.size(170.dp)
|
modifier = Modifier.size(170.dp)
|
||||||
)
|
)
|
||||||
Column {
|
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Text(
|
Text(
|
||||||
text = completedTasks.toString(),
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,4 +21,5 @@
|
||||||
<string name="subject_history">历史</string>
|
<string name="subject_history">历史</string>
|
||||||
<string name="subject_others">其它</string>
|
<string name="subject_others">其它</string>
|
||||||
<string name="title_edit_task">修改待办</string>
|
<string name="title_edit_task">修改待办</string>
|
||||||
|
<string name="tip_remain_tasks">剩余 %s 项任务</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -20,4 +20,5 @@
|
||||||
<string name="subject_history">History</string>
|
<string name="subject_history">History</string>
|
||||||
<string name="subject_others">Others</string>
|
<string name="subject_others">Others</string>
|
||||||
<string name="title_edit_task">Edit Task</string>
|
<string name="title_edit_task">Edit Task</string>
|
||||||
|
<string name="tip_remain_tasks">%s tasks remaining</string>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in a new issue