-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add detail information view of tasks
- Loading branch information
1 parent
0bfc7f5
commit 98a78dd
Showing
12 changed files
with
181 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package cn.super12138.todo.logic.model | ||
|
||
data class ToDo(val uuid: String, val content: String, val subject: String) { | ||
data class ToDo(val uuid: String, val state:Int, val content: String, val subject: String) { | ||
var isAnimated = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
app/src/main/kotlin/cn/super12138/todo/views/all/InfoBottomSheet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package cn.super12138.todo.views.all | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import cn.super12138.todo.R | ||
import cn.super12138.todo.ToDoApplication | ||
import cn.super12138.todo.databinding.BottomSheetInfoBinding | ||
import cn.super12138.todo.logic.Repository | ||
import com.google.android.material.bottomsheet.BottomSheetBehavior | ||
import com.google.android.material.bottomsheet.BottomSheetDialog | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
|
||
class InfoBottomSheet : BottomSheetDialogFragment() { | ||
|
||
private lateinit var binding: BottomSheetInfoBinding | ||
private lateinit var todoContent: String | ||
private lateinit var todoSubject: String | ||
private var todoState: Int = 0 | ||
private lateinit var todoUUID: String | ||
|
||
companion object { | ||
const val TAG = "InfoBtmSheet" | ||
fun newInstance( | ||
todoContent: String, | ||
todoSubject: String, | ||
todoState: Int, | ||
todoUUID: String | ||
) = InfoBottomSheet().apply { | ||
arguments = Bundle().apply { | ||
putString("todoContent", todoContent) | ||
putString("todoSubject", todoSubject) | ||
putInt("todoState", todoState) | ||
putString("todoUUID", todoUUID) | ||
} | ||
} | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
arguments?.let { | ||
todoContent = it.getString("todoContent", "") | ||
todoSubject = it.getString("todoSubject", "") | ||
todoState = it.getInt("todoState", 0) | ||
todoUUID = it.getString("todoUUID", "") | ||
} | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
binding = BottomSheetInfoBinding.inflate(inflater, container, false) | ||
|
||
return binding.root | ||
} | ||
|
||
@androidx.annotation.OptIn(com.google.android.material.badge.ExperimentalBadgeUtils::class) | ||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
val bottomSheetDialog = dialog as BottomSheetDialog | ||
bottomSheetDialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED | ||
bottomSheetDialog.dismissWithAnimation = true | ||
|
||
binding.todoContentInfo.text = todoContent | ||
binding.todoSubjectInfo.text = String.format(getString(R.string.info_subject), todoSubject) | ||
if (todoState == 0) { | ||
binding.todoState.text = getString(R.string.info_state_complete) | ||
} else { | ||
binding.todoState.text = getString(R.string.info_state_incomplete) | ||
} | ||
if (Repository.getPreferenceBoolean(ToDoApplication.context, "dev_mode", false)) { | ||
binding.todoUuid.apply { | ||
visibility = View.VISIBLE | ||
text = String.format(getString(R.string.info_uuid), todoUUID) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<com.google.android.material.bottomsheet.BottomSheetDragHandleView | ||
android:id="@+id/drag_handle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
<androidx.core.widget.NestedScrollView | ||
android:id="@+id/scroll_content_info" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_marginLeft="40dp" | ||
android:layout_marginRight="40dp" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/todo_content_info" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="测试" | ||
android:textAlignment="center" | ||
android:textColor="?android:attr/textColorPrimary" | ||
android:textSize="25sp" /> | ||
|
||
|
||
<TextView | ||
android:id="@+id/todo_uuid" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:textColor="?android:attr/textColorPrimary" | ||
android:textSize="15sp" | ||
android:visibility="gone" /> | ||
|
||
<TextView | ||
android:id="@+id/todo_subject_info" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="5dp" | ||
android:textColor="?android:attr/textColorPrimary" | ||
android:textSize="15sp" /> | ||
|
||
<TextView | ||
android:id="@+id/todo_state" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="5dp" | ||
android:layout_marginBottom="45dp" | ||
android:textColor="?android:attr/textColorPrimary" | ||
android:textSize="15sp" /> | ||
</LinearLayout> | ||
</androidx.core.widget.NestedScrollView> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters