Support AvatarBackgroundColor in Persona (#77)

Co-authored-by: Aishwarya <aishwarya@DESKTOP-SBI7.redmond.corp.microsoft.com>
This commit is contained in:
Aishwarya Pratap Singh 2021-06-02 16:36:15 +05:30 коммит произвёл GitHub
Родитель f32b18d753
Коммит e4747a0d34
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -20,6 +20,7 @@ import android.view.accessibility.AccessibilityNodeInfo
import android.widget.CheckBox import android.widget.CheckBox
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.annotation.ColorInt
import com.microsoft.fluentui.persona.R import com.microsoft.fluentui.persona.R
import com.microsoft.fluentui.persona.databinding.ViewPersonaChipBinding import com.microsoft.fluentui.persona.databinding.ViewPersonaChipBinding
import com.microsoft.fluentui.theming.FluentUIContextThemeWrapper import com.microsoft.fluentui.theming.FluentUIContextThemeWrapper
@ -71,6 +72,14 @@ class PersonaChipView : TemplateView {
field = value field = value
updateViews() updateViews()
} }
@ColorInt
var avatarBackgroundColor: Int? = null
set(value) {
if (field == value)
return
field = value
updateViews()
}
/** /**
* Flag for setting the chip's error state * Flag for setting the chip's error state
*/ */
@ -204,6 +213,7 @@ class PersonaChipView : TemplateView {
avatarImageDrawable = this@PersonaChipView.avatarImageDrawable avatarImageDrawable = this@PersonaChipView.avatarImageDrawable
avatarImageBitmap = this@PersonaChipView.avatarImageBitmap avatarImageBitmap = this@PersonaChipView.avatarImageBitmap
avatarImageUri = this@PersonaChipView.avatarImageUri avatarImageUri = this@PersonaChipView.avatarImageUri
avatarBackgroundColor = this@PersonaChipView.avatarBackgroundColor
} }
if (hasError) if (hasError)
@ -273,4 +283,5 @@ fun PersonaChipView.setPersona(persona: IPersona) {
avatarImageDrawable = persona.avatarImageDrawable avatarImageDrawable = persona.avatarImageDrawable
avatarImageResourceId = persona.avatarImageResourceId avatarImageResourceId = persona.avatarImageResourceId
avatarImageUri = persona.avatarImageUri avatarImageUri = persona.avatarImageUri
avatarBackgroundColor = persona.avatarBackgroundColor
} }

Просмотреть файл

@ -12,6 +12,7 @@ import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import android.util.AttributeSet import android.util.AttributeSet
import android.view.accessibility.AccessibilityEvent import android.view.accessibility.AccessibilityEvent
import androidx.annotation.ColorInt
import com.microsoft.fluentui.persona.R import com.microsoft.fluentui.persona.R
import com.microsoft.fluentui.listitem.ListItemView import com.microsoft.fluentui.listitem.ListItemView
import com.microsoft.fluentui.util.isVisibleOnScreen import com.microsoft.fluentui.util.isVisibleOnScreen
@ -103,6 +104,14 @@ class PersonaView : ListItemView {
field = value field = value
updateViews() updateViews()
} }
@ColorInt
var avatarBackgroundColor: Int? = null
set(value) {
if (field == value)
return
field = value
updateViews()
}
private val avatarView = AvatarView(context) private val avatarView = AvatarView(context)
@ -141,6 +150,7 @@ class PersonaView : ListItemView {
avatarView.avatarImageDrawable = avatarImageDrawable avatarView.avatarImageDrawable = avatarImageDrawable
avatarView.avatarImageBitmap = avatarImageBitmap avatarView.avatarImageBitmap = avatarImageBitmap
avatarView.avatarImageUri = avatarImageUri avatarView.avatarImageUri = avatarImageUri
avatarView.avatarBackgroundColor = avatarBackgroundColor
customView = avatarView customView = avatarView
@ -172,4 +182,5 @@ fun PersonaView.setPersona(persona: IPersona) {
avatarImageDrawable = persona.avatarImageDrawable avatarImageDrawable = persona.avatarImageDrawable
avatarImageResourceId = persona.avatarImageResourceId avatarImageResourceId = persona.avatarImageResourceId
avatarImageUri = persona.avatarImageUri avatarImageUri = persona.avatarImageUri
avatarBackgroundColor = persona.avatarBackgroundColor
} }