导入 v0.1.0 / v0.2.0 源码:五模块首版、交互重构、重复任务、任务分布
- 源码镜像 src/main(81 个文件):首页双模式、任务、项目、统计、设置 - 补齐 README / LICENSE / CHANGELOG / CONTRIBUTING / .gitignore - 不含构建配置、签名材料、编译产物与备份数据
This commit is contained in:
42
src/main/java/com/focusbox/app/ui/SheetDialog.kt
Normal file
42
src/main/java/com/focusbox/app/ui/SheetDialog.kt
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.focusbox.app.ui
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import com.focusbox.app.R
|
||||
|
||||
/**
|
||||
* 从底部升起的弹层。
|
||||
*
|
||||
* 不用 Material 的 BottomSheetDialog:本工程刻意不引 Material 依赖(离线构建体积与
|
||||
* 主题冲突都省了),而这里只需要"贴底 + 圆角 + 键盘顶起"三件事,自己写反而可控。
|
||||
*/
|
||||
open class SheetDialog(context: Context) : Dialog(context, R.style.SheetDialog) {
|
||||
|
||||
init {
|
||||
window?.apply {
|
||||
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
setGravity(Gravity.BOTTOM)
|
||||
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
|
||||
attributes = attributes.apply {
|
||||
width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
dimAmount = 0.45f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun setContentView(view: View) {
|
||||
super.setContentView(view)
|
||||
(view.parent as? View)?.setBackgroundColor(Color.TRANSPARENT)
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
super.show()
|
||||
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user