Add new subject and animation of to-do list

This commit is contained in:
Super12138 2024-01-24 14:56:09 +08:00
parent 435b2fce27
commit 80cfce19e1
5 changed files with 22 additions and 3 deletions

View file

@ -105,6 +105,7 @@ class ToDoFragment : Fragment() {
R.id.subject_history -> getString(R.string.subject_history)
R.id.subject_physics -> getString(R.string.subject_physics)
R.id.subject_law -> getString(R.string.subject_law)
R.id.subject_other -> getString(R.string.subject_other)
else -> getString(R.string.subject_unknown)
}
@ -172,10 +173,20 @@ class ToDoFragment : Fragment() {
todoViewModel.emptyTipVis.observe(viewLifecycleOwner, Observer { visibility ->
if (visibility == View.VISIBLE) {
binding.todoList.alpha = 1f
binding.todoList.animate().alpha(0f).duration = 200
binding.todoList.visibility = View.GONE
binding.emptyTip.alpha = 0f
binding.emptyTip.visibility = View.VISIBLE
binding.emptyTip.animate().alpha(1f).duration = 200
} else {
binding.todoList.alpha = 0f
binding.todoList.visibility = View.VISIBLE
binding.todoList.animate().alpha(1f).duration = 200
binding.emptyTip.alpha = 1f
binding.emptyTip.animate().alpha(0f).duration = 200
binding.emptyTip.visibility = View.GONE
}
if (todoList.size == 0 && !binding.addItem.isShown) {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -106,6 +106,13 @@
android:layout_height="wrap_content"
android:text="@string/subject_law" />
<com.google.android.material.chip.Chip
android:id="@+id/subject_other"
style="@style/Widget.Material3.Chip.Filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subject_other" />
</com.google.android.material.chip.ChipGroup>
</LinearLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>

View file

@ -3,7 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:orientation="vertical">
<!--<LinearLayout

View file

@ -20,6 +20,7 @@
<string name="subject_history">历史</string>
<string name="subject_geography">地理</string>
<string name="subject_law">道法</string>
<string name="subject_other">其它</string>
<!--UI-->
<string name="cancel">取消</string>
<string name="ok">确定</string>

View file

@ -20,6 +20,7 @@
<string name="subject_history">History</string>
<string name="subject_geography">Geography</string>
<string name="subject_law">Law</string>
<string name="subject_other">Other</string>
<!--UI-->
<string name="cancel">Cancel</string>
<string name="ok">OK</string>