forked from GitHub-Mirror/riotX-android
Fix / use emoji Compat font for view reaction screen
This commit is contained in:
parent
04576ba7fd
commit
3f1bf00fdd
@ -1,5 +1,6 @@
|
||||
package im.vector.riotredesign.features.home.room.detail.timeline.action
|
||||
|
||||
import android.graphics.Typeface
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
@ -8,7 +9,9 @@ import com.airbnb.epoxy.EpoxyModelWithHolder
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.epoxy.VectorEpoxyHolder
|
||||
|
||||
|
||||
/**
|
||||
* Item displaying an emoji reaction (single line with emoji, author, time)
|
||||
*/
|
||||
@EpoxyModelClass(layout = R.layout.item_simple_reaction_info)
|
||||
abstract class ReactionInfoSimpleItem : EpoxyModelWithHolder<ReactionInfoSimpleItem.Holder>() {
|
||||
|
||||
@ -19,8 +22,12 @@ abstract class ReactionInfoSimpleItem : EpoxyModelWithHolder<ReactionInfoSimpleI
|
||||
@EpoxyAttribute
|
||||
var timeStamp: CharSequence? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var emojiTypeFace: Typeface? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
holder.titleView.text = reactionKey
|
||||
holder.emojiReactionView.text = reactionKey
|
||||
holder.emojiReactionView.typeface = emojiTypeFace ?: Typeface.DEFAULT
|
||||
holder.displayNameView.text = authorDisplayName
|
||||
timeStamp?.let {
|
||||
holder.timeStampView.text = it
|
||||
@ -31,7 +38,7 @@ abstract class ReactionInfoSimpleItem : EpoxyModelWithHolder<ReactionInfoSimpleI
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
val titleView by bind<TextView>(R.id.itemSimpleReactionInfoKey)
|
||||
val emojiReactionView by bind<TextView>(R.id.itemSimpleReactionInfoKey)
|
||||
val displayNameView by bind<TextView>(R.id.itemSimpleReactionInfoMemberName)
|
||||
val timeStampView by bind<TextView>(R.id.itemSimpleReactionInfoTime)
|
||||
}
|
||||
|
@ -11,24 +11,27 @@ import butterknife.BindView
|
||||
import butterknife.ButterKnife
|
||||
import com.airbnb.epoxy.EpoxyRecyclerView
|
||||
import com.airbnb.mvrx.MvRx
|
||||
import com.airbnb.mvrx.args
|
||||
import com.airbnb.mvrx.fragmentViewModel
|
||||
import com.airbnb.mvrx.withState
|
||||
import im.vector.riotredesign.EmojiCompatFontProvider
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.features.home.room.detail.timeline.item.MessageInformationData
|
||||
import kotlinx.android.synthetic.main.bottom_sheet_display_reactions.*
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
|
||||
/**
|
||||
* Bottom sheet displaying list of reactions for a given event ordered by timestamp
|
||||
*/
|
||||
class ViewReactionBottomSheet : BaseMvRxBottomSheetDialog() {
|
||||
|
||||
private val viewModel: ViewReactionViewModel by fragmentViewModel(ViewReactionViewModel::class)
|
||||
|
||||
private val eventArgs: TimelineEventFragmentArgs by args()
|
||||
private val emojiCompatFontProvider by inject<EmojiCompatFontProvider>()
|
||||
|
||||
@BindView(R.id.bottom_sheet_display_reactions_list)
|
||||
lateinit var epoxyRecyclerView: EpoxyRecyclerView
|
||||
|
||||
private val epoxyController by lazy { ViewReactionsEpoxyController() }
|
||||
private val epoxyController by lazy { ViewReactionsEpoxyController(emojiCompatFontProvider.typeface) }
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
val view = inflater.inflate(R.layout.bottom_sheet_display_reactions, container, false)
|
||||
|
@ -1,15 +1,19 @@
|
||||
package im.vector.riotredesign.features.home.room.detail.timeline.action
|
||||
|
||||
import android.graphics.Typeface
|
||||
import com.airbnb.epoxy.TypedEpoxyController
|
||||
|
||||
|
||||
class ViewReactionsEpoxyController : TypedEpoxyController<DisplayReactionsViewState>() {
|
||||
/**
|
||||
* Epoxy controller for reaction event list
|
||||
*/
|
||||
class ViewReactionsEpoxyController(private val emojiCompatTypeface: Typeface?) : TypedEpoxyController<DisplayReactionsViewState>() {
|
||||
|
||||
override fun buildModels(state: DisplayReactionsViewState) {
|
||||
val map = state.mapReactionKeyToMemberList() ?: return
|
||||
map.forEach {
|
||||
reactionInfoSimpleItem {
|
||||
id(it.eventId)
|
||||
emojiTypeFace(emojiCompatTypeface)
|
||||
timeStamp(it.timestamp)
|
||||
reactionKey(it.reactionKey)
|
||||
authorDisplayName(it.authorName ?: it.authorId)
|
||||
|
Loading…
Reference in New Issue
Block a user