From 8527d3f162205b70f0b6d19f6cb283e8de9354c4 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 9 Dec 2019 22:30:29 +0100 Subject: [PATCH] Improve emoji picker search result --- .../reactions/EmojiSearchResultController.kt | 7 ++-- .../reactions/EmojiSearchResultFragment.kt | 20 +++++------ .../reactions/EmojiSearchResultItem.kt | 3 +- .../src/main/res/layout/item_emoji_result.xml | 33 ++++++++++--------- 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultController.kt b/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultController.kt index 3e8f1c9769..208d9d7a56 100644 --- a/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultController.kt +++ b/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultController.kt @@ -24,9 +24,10 @@ import im.vector.riotx.core.resources.StringProvider import im.vector.riotx.core.ui.list.genericFooterItem import javax.inject.Inject -class EmojiSearchResultController @Inject constructor(val stringProvider: StringProvider, - private val fontProvider: EmojiCompatFontProvider) - : TypedEpoxyController() { +class EmojiSearchResultController @Inject constructor( + private val stringProvider: StringProvider, + private val fontProvider: EmojiCompatFontProvider +) : TypedEpoxyController() { var emojiTypeface: Typeface? = fontProvider.typeface diff --git a/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultFragment.kt b/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultFragment.kt index b34a5f2357..a62b2d39cb 100644 --- a/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultFragment.kt @@ -29,25 +29,18 @@ import javax.inject.Inject class EmojiSearchResultFragment @Inject constructor( private val epoxyController: EmojiSearchResultController -) : VectorBaseFragment() { +) : VectorBaseFragment(), ReactionClickListener { override fun getLayoutResId() = R.layout.fragment_generic_recycler - val viewModel: EmojiSearchResultViewModel by activityViewModel() + private val viewModel: EmojiSearchResultViewModel by activityViewModel() - var sharedViewModel: EmojiChooserViewModel? = null + private lateinit var sharedViewModel: EmojiChooserViewModel override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) sharedViewModel = activityViewModelProvider.get(EmojiChooserViewModel::class.java) - - epoxyController.listener = object : ReactionClickListener { - override fun onReactionSelected(reaction: String) { - sharedViewModel?.selectedReaction = reaction - sharedViewModel?.navigateEvent?.value = LiveEvent(EmojiChooserViewModel.NAVIGATE_FINISH) - } - } - + epoxyController.listener = this recyclerView.configureWith(epoxyController, showDivider = true) } @@ -57,6 +50,11 @@ class EmojiSearchResultFragment @Inject constructor( super.onDestroyView() } + override fun onReactionSelected(reaction: String) { + sharedViewModel.selectedReaction = reaction + sharedViewModel.navigateEvent.value = LiveEvent(EmojiChooserViewModel.NAVIGATE_FINISH) + } + override fun invalidate() = withState(viewModel) { state -> epoxyController.setData(state) } diff --git a/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultItem.kt b/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultItem.kt index 1b117035d9..746fdddbf3 100644 --- a/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultItem.kt +++ b/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultItem.kt @@ -22,6 +22,7 @@ import com.airbnb.epoxy.EpoxyModelClass import com.airbnb.epoxy.EpoxyModelWithHolder import im.vector.riotx.R import im.vector.riotx.core.epoxy.VectorEpoxyHolder +import im.vector.riotx.core.extensions.setTextOrHide @EpoxyModelClass(layout = R.layout.item_emoji_result) abstract class EmojiSearchResultItem : EpoxyModelWithHolder() { @@ -44,7 +45,7 @@ abstract class EmojiSearchResultItem : EpoxyModelWithHolder + android:paddingStart="@dimen/layout_horizontal_margin" + android:paddingEnd="@dimen/layout_horizontal_margin"> + android:layout_weight="1" + android:orientation="vertical"> - + android:textColor="?riotx_text_secondary" + android:textSize="14sp" + android:visibility="gone" + tools:text="Smile, foo, bar" + tools:visibility="visible" />