From 588154b050d281af2527469391f6332568324c11 Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Mon, 15 Feb 2021 11:17:06 -0800 Subject: [PATCH] wip --- View Controllers/EmojiPickerViewController.swift | 2 +- .../AutocompleteItemCollectionViewCell.swift | 6 ++++-- .../Collection View Cells/EmojiCollectionViewCell.swift | 7 +++++-- Views/UIKit/CompositionInputAccessoryView.swift | 8 ++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/View Controllers/EmojiPickerViewController.swift b/View Controllers/EmojiPickerViewController.swift index c4bc381..21a4a49 100644 --- a/View Controllers/EmojiPickerViewController.swift +++ b/View Controllers/EmojiPickerViewController.swift @@ -155,7 +155,7 @@ final class EmojiPickerViewController: UICollectionViewController { guard let item = dataSource.itemIdentifier(for: indexPath) else { return } - select(item.applyingDefaultSkinTone(identityContext: viewModel.identityContext)) + select(emoji: item.applyingDefaultSkinTone(identityContext: viewModel.identityContext)) viewModel.updateUse(emoji: item) } diff --git a/Views/UIKit/Collection View Cells/AutocompleteItemCollectionViewCell.swift b/Views/UIKit/Collection View Cells/AutocompleteItemCollectionViewCell.swift index 0224219..c25593b 100644 --- a/Views/UIKit/Collection View Cells/AutocompleteItemCollectionViewCell.swift +++ b/Views/UIKit/Collection View Cells/AutocompleteItemCollectionViewCell.swift @@ -12,9 +12,11 @@ final class AutocompleteItemCollectionViewCell: SeparatorConfiguredCollectionVie contentConfiguration = AutocompleteItemContentConfiguration(item: item, identityContext: identityContext) - var backgroundConfiguration = UIBackgroundConfiguration.listPlainCell() + var backgroundConfiguration = UIBackgroundConfiguration.listPlainCell().updated(for: state) - backgroundConfiguration.backgroundColor = state.isHighlighted || state.isSelected ? nil : .clear + if !state.isHighlighted && !state.isSelected { + backgroundConfiguration.backgroundColor = .clear + } self.backgroundConfiguration = backgroundConfiguration diff --git a/Views/UIKit/Collection View Cells/EmojiCollectionViewCell.swift b/Views/UIKit/Collection View Cells/EmojiCollectionViewCell.swift index 0407dab..2fe4b71 100644 --- a/Views/UIKit/Collection View Cells/EmojiCollectionViewCell.swift +++ b/Views/UIKit/Collection View Cells/EmojiCollectionViewCell.swift @@ -11,9 +11,12 @@ final class EmojiCollectionViewCell: UICollectionViewCell { contentConfiguration = EmojiContentConfiguration(emoji: emoji) - var backgroundConfiguration = UIBackgroundConfiguration.listPlainCell() + var backgroundConfiguration = UIBackgroundConfiguration.listPlainCell().updated(for: state) + + if !state.isHighlighted && !state.isSelected { + backgroundConfiguration.backgroundColor = .clear + } - backgroundConfiguration.backgroundColor = state.isHighlighted || state.isSelected ? nil : .clear backgroundConfiguration.cornerRadius = .defaultCornerRadius self.backgroundConfiguration = backgroundConfiguration diff --git a/Views/UIKit/CompositionInputAccessoryView.swift b/Views/UIKit/CompositionInputAccessoryView.swift index 0348720..04d8a9f 100644 --- a/Views/UIKit/CompositionInputAccessoryView.swift +++ b/Views/UIKit/CompositionInputAccessoryView.swift @@ -62,6 +62,8 @@ private extension CompositionInputAccessoryView { autocompleteCollectionView.backgroundColor = .clear autocompleteCollectionView.layer.cornerRadius = .defaultCornerRadius autocompleteCollectionView.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner] + autocompleteCollectionView.dataSource = autocompleteDataSource + autocompleteCollectionView.delegate = self let autocompleteBackgroundView = UIVisualEffectView(effect: UIBlurEffect(style: .systemChromeMaterial)) @@ -236,6 +238,12 @@ private extension CompositionInputAccessoryView { } } +extension CompositionInputAccessoryView: UICollectionViewDelegate { + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + collectionView.deselectItem(at: indexPath, animated: true) + } +} + private extension CompositionInputAccessoryView { static func autocompleteLayout() -> UICollectionViewLayout { var listConfig = UICollectionLayoutListConfiguration(appearance: .plain)