背景选择器
This commit is contained in:
parent
667161f05f
commit
ad06ee3411
|
|
@ -6,11 +6,13 @@ import com.remax.visualnovel.entity.model.base.BasePhoto
|
|||
* Created by HJW on 2025/8/18
|
||||
*/
|
||||
data class ChatBackground(
|
||||
val backgroundId: Int?,
|
||||
val imgUrl: String,
|
||||
var isDefault: Boolean,
|
||||
var backgroundId: Int? = 0,
|
||||
var imgUrl: String? = "",
|
||||
var isDefault: Boolean = false,
|
||||
var select: Boolean = false,
|
||||
var isSelected: Boolean? = null,
|
||||
var deletable: Boolean = false,
|
||||
var isUploadLocalItem: Boolean = false
|
||||
) : BasePhoto() {
|
||||
override fun paramId(): Long {
|
||||
return imgUrl.hashCode().toLong()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package com.remax.visualnovel.entity.response
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class ChatHistory(
|
||||
var id: Int? = 0,
|
||||
var time: Long,
|
||||
var describle: String
|
||||
) : Parcelable {
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import android.widget.LinearLayout
|
|||
import androidx.core.graphics.toColorInt
|
||||
import com.remax.visualnovel.R
|
||||
import com.remax.visualnovel.databinding.LayoutChatMenuViewBinding
|
||||
import com.remax.visualnovel.entity.response.ChatBackground
|
||||
import com.remax.visualnovel.entity.response.ChatBubble
|
||||
import com.remax.visualnovel.entity.response.ChatMode
|
||||
import com.remax.visualnovel.entity.response.ChatSound
|
||||
|
|
@ -32,6 +33,7 @@ class ChatSettingView @JvmOverloads constructor(
|
|||
initChatModeSelectorView()
|
||||
initSoundSelectorView()
|
||||
initBubbleSelectView()
|
||||
initBackgroundSelectView()
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -179,5 +181,44 @@ class ChatSettingView @JvmOverloads constructor(
|
|||
mBinding.bubbleSelectView.setItems(items)
|
||||
}
|
||||
|
||||
fun initBackgroundSelectView() {
|
||||
val items = listOf(
|
||||
ChatBackground(
|
||||
backgroundId = 1,
|
||||
imgUrl = "https://cdhrss.chengdu.gov.cn/cdrsj/xhtml/images/2022_logo.png",
|
||||
),
|
||||
ChatBackground(
|
||||
backgroundId = 1,
|
||||
imgUrl = "https://cdhrss.chengdu.gov.cn/cdrsj/xhtml/images/2022_logo.png",
|
||||
),
|
||||
ChatBackground(
|
||||
backgroundId = 1,
|
||||
imgUrl = "https://cdhrss.chengdu.gov.cn/cdrsj/xhtml/images/2022_logo.png",
|
||||
),
|
||||
ChatBackground(
|
||||
backgroundId = 1,
|
||||
imgUrl = "https://cdhrss.chengdu.gov.cn/cdrsj/xhtml/images/2022_logo.png",
|
||||
),
|
||||
ChatBackground(
|
||||
backgroundId = 1,
|
||||
imgUrl = "https://cdhrss.chengdu.gov.cn/cdrsj/xhtml/images/2022_logo.png",
|
||||
),
|
||||
ChatBackground(
|
||||
backgroundId = 1,
|
||||
imgUrl = "https://cdhrss.chengdu.gov.cn/cdrsj/xhtml/images/2022_logo.png",
|
||||
),
|
||||
ChatBackground(
|
||||
backgroundId = 1,
|
||||
imgUrl = "https://cdhrss.chengdu.gov.cn/cdrsj/xhtml/images/2022_logo.png",
|
||||
deletable = true
|
||||
),
|
||||
ChatBackground(
|
||||
isUploadLocalItem = true
|
||||
)
|
||||
)
|
||||
|
||||
mBinding.backgroundSelectorView.setItems(items)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
package com.remax.visualnovel.ui.chat.ui.expandableSelector
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.drake.brv.annotaion.DividerOrientation
|
||||
import com.drake.brv.utils.bindingAdapter
|
||||
import com.drake.brv.utils.divider
|
||||
import com.drake.brv.utils.grid
|
||||
import com.drake.brv.utils.models
|
||||
import com.drake.brv.utils.setup
|
||||
import com.remax.visualnovel.R
|
||||
import com.remax.visualnovel.databinding.LayoutItemSettingBackgroundBinding
|
||||
import com.remax.visualnovel.databinding.LayoutSettingBgSubViewBinding
|
||||
import com.remax.visualnovel.entity.response.ChatBackground
|
||||
import com.remax.visualnovel.extension.glide.load
|
||||
|
||||
class ExpandBackgroundSubView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : LinearLayout(context, attrs, defStyleAttr) {
|
||||
private lateinit var items: List<ChatBackground>
|
||||
private var mBinding: LayoutSettingBgSubViewBinding
|
||||
|
||||
|
||||
init {
|
||||
mBinding = LayoutSettingBgSubViewBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
with(mBinding) {
|
||||
initRv(itemsRv)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initRv(itemsRv: RecyclerView) {
|
||||
itemsRv.grid(3)
|
||||
.divider {
|
||||
setDivider(10, true)
|
||||
orientation = DividerOrientation.VERTICAL
|
||||
}.setup {
|
||||
addType<ChatBackground>(R.layout.layout_item_setting_background)
|
||||
|
||||
onClick(R.id.root) {
|
||||
val chatBackground = getModel<ChatBackground>()
|
||||
if (!chatBackground.select) {
|
||||
itemsRv.bindingAdapter.models?.filterIsInstance<ChatBackground>()?.forEach { item ->
|
||||
item.select = item == chatBackground
|
||||
}
|
||||
itemsRv.bindingAdapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
onBind {
|
||||
val item = getModel<ChatBackground>()
|
||||
with(getBinding<LayoutItemSettingBackgroundBinding>()) {
|
||||
if (!item.imgUrl.isNullOrEmpty()) {
|
||||
ivBackgroundSrc.load(item.imgUrl)
|
||||
}
|
||||
ivDel.visibility = if (item.deletable) VISIBLE else GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setItems(newItems: List<ChatBackground>) {
|
||||
items = newItems
|
||||
mBinding.itemsRv.models = items
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
package com.remax.visualnovel.ui.chat.ui.expandableSelector
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.drake.brv.annotaion.DividerOrientation
|
||||
import com.drake.brv.utils.divider
|
||||
import com.drake.brv.utils.grid
|
||||
import com.drake.brv.utils.setup
|
||||
import com.remax.visualnovel.databinding.LayoutSettingBgSubViewBinding
|
||||
|
||||
class ExpandBgSubView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : LinearLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private var mBinding: LayoutSettingBgSubViewBinding
|
||||
|
||||
|
||||
init {
|
||||
mBinding = LayoutSettingBgSubViewBinding.inflate(LayoutInflater.from(context))
|
||||
with(mBinding) {
|
||||
initRv(itemsRv)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun initRv(itemsRv: RecyclerView) {
|
||||
itemsRv.grid(2)
|
||||
.divider {
|
||||
setDivider(16, true)
|
||||
orientation = DividerOrientation.VERTICAL
|
||||
}.setup {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -253,6 +253,12 @@
|
|||
android:orientation="vertical"
|
||||
android:layout_marginTop="10dp" >
|
||||
|
||||
<com.remax.visualnovel.ui.chat.ui.expandableSelector.ExpandBackgroundSubView
|
||||
android:id="@+id/background_selector_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
</com.remax.visualnovel.widget.uitoken.view.UITokenLinearLayout>
|
||||
|
||||
<!-- history related -->
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/iv_background_src"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:src="@mipmap/img_1"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/selectBg"
|
||||
app:layout_constraintEnd_toEndOf="@+id/selectBg"
|
||||
app:layout_constraintStart_toStartOf="@+id/selectBg"
|
||||
app:layout_constraintTop_toTopOf="@+id/selectBg" />
|
||||
|
||||
<com.remax.visualnovel.widget.uitoken.view.UITokenFrameLayout
|
||||
android:id="@+id/selectBg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:backgroundColorToken="@string/color_surface_element_normal"
|
||||
app:layout_constraintDimensionRatio="h,87:116"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:radiusToken="@string/radius_l"
|
||||
app:strokeColorToken="@string/color_primary_normal"
|
||||
app:strokeWidthToken="@string/border_m"
|
||||
/>
|
||||
|
||||
<com.remax.visualnovel.widget.uitoken.view.UITokenImageView
|
||||
android:id="@+id/iv_del"
|
||||
android:layout_width="@dimen/dp_15"
|
||||
android:layout_height="@dimen/dp_15"
|
||||
android:src="@mipmap/setting_delete"
|
||||
app:radiusToken="@string/radius_l"
|
||||
android:tint="@color/white"
|
||||
android:layout_marginBottom="@dimen/dp_9"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -4,13 +4,14 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="16dp">
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/backgroundIcon"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:src="@mipmap/img_1"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/selectBg"
|
||||
app:layout_constraintEnd_toEndOf="@+id/selectBg"
|
||||
app:layout_constraintStart_toStartOf="@+id/selectBg"
|
||||
|
|
@ -21,44 +22,11 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:backgroundColorToken="@string/color_surface_element_normal"
|
||||
app:layout_constraintDimensionRatio="h,164:219"
|
||||
app:layout_constraintDimensionRatio="h,87:116"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:radiusToken="@string/radius_l"
|
||||
app:strokeColorToken="@string/color_primary_normal"
|
||||
app:strokeWidthToken="@string/border_m"
|
||||
/>
|
||||
|
||||
<com.remax.visualnovel.widget.ui.buttons.IconButtonView
|
||||
android:id="@+id/fullImage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="12dp"
|
||||
android:text="@string/icon_full_image"
|
||||
app:iconButtonName="ContrastButton_Tertiary_Dark"
|
||||
app:iconButtonRadius="round"
|
||||
app:iconButtonSizeType="small"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<com.remax.visualnovel.widget.ui.RadioCheckButton
|
||||
android:id="@+id/singleCheckBox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:radioCheck="true" />
|
||||
|
||||
<!--<com.remax.visualnovel.widget.TagIconView
|
||||
android:id="@+id/backgroundTag"
|
||||
android:layout_width="wrap_content"
|
||||
app:tagIconSize="SIZE_S"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
app:layout_constraintStart_toStartOf="@+id/selectBg"
|
||||
app:layout_constraintTop_toTopOf="@+id/selectBg"
|
||||
app:tagIconContent="@string/default_txt"
|
||||
app:tagIconType="ELEMENT_DARK" />-->
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -4,8 +4,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="16dp">
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<com.remax.visualnovel.widget.uitoken.view.UITokenFrameLayout
|
||||
android:id="@+id/selectBg"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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="wrap_content"
|
||||
android:maxHeight="250dp"
|
||||
|
|
@ -13,5 +12,4 @@
|
|||
android:orientation="vertical"
|
||||
android:layout_marginTop="@dimen/dp_2"
|
||||
android:visibility="visible"/>
|
||||
|
||||
</LinearLayout>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 114 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 114 KiB |
Loading…
Reference in New Issue