更新Dialog界面与SCV控件
This commit is contained in:
10 files changed
+332
-142
No files matched your search
@@ -4,14 +4,15 @@ import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.base.BaseBottomSheetDialogFragment
|
||||
import io.legato.kazusa.base.BaseDialogFragment
|
||||
import io.legato.kazusa.constant.EventBus
|
||||
import io.legato.kazusa.databinding.DialogReadPaddingBinding
|
||||
import io.legato.kazusa.help.config.ReadBookConfig
|
||||
import io.legato.kazusa.utils.postEvent
|
||||
import io.legato.kazusa.utils.setLayout
|
||||
import io.legato.kazusa.utils.viewbindingdelegate.viewBinding
|
||||
|
||||
class PaddingConfigDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_padding) {
|
||||
class PaddingConfigDialog : BaseDialogFragment(R.layout.dialog_read_padding) {
|
||||
|
||||
private val binding by viewBinding(DialogReadPaddingBinding::bind)
|
||||
|
||||
@@ -25,6 +26,11 @@ class PaddingConfigDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_p
|
||||
ReadBookConfig.save()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
setLayout(0.9f, 0.9f)
|
||||
}
|
||||
|
||||
private fun initData() = binding.run {
|
||||
//正文
|
||||
dsbPaddingTop.progress = ReadBookConfig.paddingTop
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package io.legato.kazusa.ui.book.read.config
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.base.BaseBottomSheetDialogFragment
|
||||
import io.legato.kazusa.constant.EventBus
|
||||
import io.legato.kazusa.databinding.DialogReadBookSpacingBinding
|
||||
import io.legato.kazusa.help.config.ReadBookConfig
|
||||
import io.legato.kazusa.ui.book.read.ReadBookActivity
|
||||
import io.legato.kazusa.utils.postEvent
|
||||
import io.legato.kazusa.utils.viewbindingdelegate.viewBinding
|
||||
|
||||
class ReadSpacingDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_spacing) {
|
||||
|
||||
private val binding by viewBinding(DialogReadBookSpacingBinding::bind)
|
||||
private val callBack get() = activity as? ReadBookActivity
|
||||
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
(activity as ReadBookActivity).bottomDialog++
|
||||
initView()
|
||||
upView()
|
||||
initViewEvent()
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
super.onDismiss(dialog)
|
||||
ReadBookConfig.save()
|
||||
(activity as ReadBookActivity).bottomDialog--
|
||||
}
|
||||
|
||||
private fun initView() = binding.run {
|
||||
dsbTextLetterSpacing.valueFormat = {
|
||||
((it - 50) / 100f).toString()
|
||||
}
|
||||
dsbLineSize.valueFormat = { ((it - 10) / 10f).toString() }
|
||||
dsbParagraphSpacing.valueFormat = { (it / 10f).toString() }
|
||||
}
|
||||
|
||||
private fun initViewEvent() = binding.run {
|
||||
dsbTextLetterSpacing.onChanged = {
|
||||
ReadBookConfig.letterSpacing = (it - 50) / 100f
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(8, 5))
|
||||
}
|
||||
dsbLineSize.onChanged = {
|
||||
ReadBookConfig.lineSpacingExtra = it
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(8, 5))
|
||||
}
|
||||
dsbParagraphSpacing.onChanged = {
|
||||
ReadBookConfig.paragraphSpacing = it
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(8, 5))
|
||||
}
|
||||
}
|
||||
|
||||
private fun upView() = binding.run {
|
||||
ReadBookConfig.let {
|
||||
dsbTextLetterSpacing.progress = (it.letterSpacing * 100).toInt() + 50
|
||||
dsbLineSize.progress = it.lineSpacingExtra
|
||||
dsbParagraphSpacing.progress = it.paragraphSpacing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import io.legato.kazusa.databinding.ItemReadStyleBinding
|
||||
import io.legato.kazusa.help.config.AppConfig
|
||||
import io.legato.kazusa.help.config.ReadBookConfig
|
||||
import io.legato.kazusa.help.config.ThemeConfig
|
||||
import io.legato.kazusa.lib.dialogs.alert
|
||||
import io.legato.kazusa.lib.dialogs.selector
|
||||
import io.legato.kazusa.model.ReadBook
|
||||
import io.legato.kazusa.ui.book.read.ReadBookActivity
|
||||
@@ -56,11 +57,7 @@ class ReadStyleDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_
|
||||
dsbTextSize.valueFormat = {
|
||||
(it + 5).toString()
|
||||
}
|
||||
dsbTextLetterSpacing.valueFormat = {
|
||||
((it - 50) / 100f).toString()
|
||||
}
|
||||
dsbLineSize.valueFormat = { ((it - 10) / 10f).toString() }
|
||||
dsbParagraphSpacing.valueFormat = { (it / 10f).toString() }
|
||||
|
||||
styleAdapter = StyleAdapter()
|
||||
rvStyle.adapter = styleAdapter
|
||||
styleAdapter.addFooterView {
|
||||
@@ -76,6 +73,8 @@ class ReadStyleDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
@@ -85,10 +84,18 @@ class ReadStyleDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_
|
||||
}
|
||||
|
||||
private fun initViewEvent() = binding.run {
|
||||
chineseConverter.onChanged {
|
||||
ChineseUtils.unLoad(*TransType.entries.toTypedArray())
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(5))
|
||||
btnChineseConverter.setOnClickListener {
|
||||
alert(titleResource = R.string.chinese_converter) {
|
||||
items(resources.getStringArray(R.array.chinese_mode).toList()) { _, i ->
|
||||
AppConfig.chineseConverterType = i
|
||||
|
||||
// 不需要更新文字,也不需要切换图标
|
||||
ChineseUtils.unLoad(*TransType.entries.toTypedArray())
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(5))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
textFontWeightConverter.onChanged {
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(8, 9, 6))
|
||||
}
|
||||
@@ -149,17 +156,9 @@ class ReadStyleDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_
|
||||
ReadBookConfig.textSize = it + 5
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(8, 5))
|
||||
}
|
||||
dsbTextLetterSpacing.onChanged = {
|
||||
ReadBookConfig.letterSpacing = (it - 50) / 100f
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(8, 5))
|
||||
}
|
||||
dsbLineSize.onChanged = {
|
||||
ReadBookConfig.lineSpacingExtra = it
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(8, 5))
|
||||
}
|
||||
dsbParagraphSpacing.onChanged = {
|
||||
ReadBookConfig.paragraphSpacing = it
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(8, 5))
|
||||
|
||||
btnSpacing.setOnClickListener {
|
||||
callBack?.showSpacingDialog()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,9 +192,6 @@ class ReadStyleDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_
|
||||
}
|
||||
ReadBookConfig.let {
|
||||
dsbTextSize.progress = it.textSize - 5
|
||||
dsbTextLetterSpacing.progress = (it.letterSpacing * 100).toInt() + 50
|
||||
dsbLineSize.progress = it.lineSpacingExtra
|
||||
dsbParagraphSpacing.progress = it.paragraphSpacing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user