redid importer view buttons

added a label to emojidetailview
use the view's isediting as source of truth
fix state issues
This commit is contained in:
Nihaal Sharma committed 2026-08-24 19:54:43 +05:30
1 parent f0829b739e
commit c129b4e15b
5 files changed
+102 -4

No files matched your search

@@ -285,6 +285,7 @@ class EmojiHoarder: BaseHoarder {
enum NotifCategory {
case emojis
case downloadedEmojis
case packs
var name: Notification.Name {
switch self {
@@ -292,6 +293,8 @@ class EmojiHoarder: BaseHoarder {
Notification.Name("EmojiHoarder.notif.emojis")
case .downloadedEmojis:
Notification.Name("EmojiHoarder.notif.downloadedEmojis")
case .packs:
Notification.Name("EmojiHoarder.notif.packs")
}
}
}
@@ -16,7 +16,7 @@ final class EmojiCollectionView: UICollectionViewController, UICollectionViewDel
var style: EmojiCollectionView.Style
var onRemove: ((String) -> Void)?
var onTap: ((String) -> Void)?
var onEditChange: ((Bool) -> Void)?
var onEditChange: (() -> Void)?
var dataSource: UICollectionViewDiffableDataSource<Int, String>!
@@ -175,7 +175,7 @@ final class EmojiCollectionView: UICollectionViewController, UICollectionViewDel
override func setEditing(_ editing: Bool, animated: Bool) {
super.setEditing(editing, animated: animated)
onEditChange?(editing)
onEditChange?()
for cell in collectionView.visibleCells {
if let cell = cell as? EmojiCollectionViewCell {
@@ -18,6 +18,8 @@ class EmojiPackDetailViewController: UIViewController {
let emptyCollectionView: UIViewController
var effectView: UIVisualEffectView!
var countLabel: UILabel!
var adderSheetButton: UIBarButtonItem!
var downloadButton: UIAction!
var renameButton: UIAction!
@@ -81,6 +83,32 @@ class EmojiPackDetailViewController: UIViewController {
self.refreshUI()
}
self.countLabel = UILabel()
countLabel.text = "hello default"
countLabel.font = UIFont.systemFont(ofSize: 14)
countLabel.textAlignment = .center
self.effectView = UIVisualEffectView(effect: nil)
self.view.addSubview(effectView)
if #available(iOS 19, *) {
let glassEffect = UIGlassEffect()
glassEffect.isInteractive = true
effectView.effect = glassEffect
}
effectView.layer.masksToBounds = true
effectView.clipsToBounds = true
effectView.contentView.addSubview(countLabel)
effectView.translatesAutoresizingMaskIntoConstraints = false
countLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
effectView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
effectView.heightAnchor.constraint(equalTo: countLabel.heightAnchor, constant: 12),
effectView.widthAnchor.constraint(equalTo: countLabel.widthAnchor, constant: 24),
effectView.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor, constant: -8),
countLabel.centerXAnchor.constraint(equalTo: effectView.centerXAnchor),
countLabel.centerYAnchor.constraint(equalTo: effectView.centerYAnchor)
])
self.adderSheetButton = UIBarButtonItem(image: UIImage(systemName: "plus"), style: .plain, target: self, action: #selector(showSheet))
let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(hideSheet))
@@ -108,6 +136,7 @@ class EmojiPackDetailViewController: UIViewController {
func refreshUI() {
self.navigationItem.title = pack.name
self.countLabel.text = pack.description
// self.navigationItem.documentProperties
checkForEmptyPack()
updateDownloadButton()
@@ -221,6 +250,12 @@ class EmojiPackDetailViewController: UIViewController {
refreshUI()
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
effectView.layer.cornerRadius = effectView.bounds.height/2
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
hoarder.updateEmojiPack(pack)
@@ -12,11 +12,36 @@ class EmojiPackImporterViewController: UINavigationController {
var emojiHoarder: EmojiHoarder
var pack: EmojiPack
var packView: EmojiPackDetailViewController
var addButton: UIButton
var cancelButton: UIButton
init(emojiHoarder: EmojiHoarder, pack: EmojiPack) {
self.emojiHoarder = emojiHoarder
self.pack = pack
self.packView = EmojiPackDetailViewController(with: emojiHoarder, andPack: pack)
var config: UIButton.Configuration
if #available(iOS 19, *) {
config = .prominentClearGlass()
} else {
config = .filled()
}
config.title = "Add"
config.cornerStyle = .capsule
config.baseBackgroundColor = .accent
config.buttonSize = .large
self.addButton = UIButton(configuration: config)
if #available(iOS 19, *) {
config = .glass()
} else {
config = .filled()
config.baseBackgroundColor = .primary.inverted
}
config.title = "Cancel"
config.cornerStyle = .capsule
config.buttonSize = .large
self.cancelButton = UIButton(configuration: config)
super.init(rootViewController: packView)
}
@@ -26,6 +51,35 @@ class EmojiPackImporterViewController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
packView.navigationItem.title = "Shared Pack"
addButton.addTarget(self, action: #selector(add), for: .touchUpInside)
cancelButton.addTarget(self, action: #selector(cancel), for: .touchUpInside)
packView.view.addSubview(addButton)
packView.view.addSubview(cancelButton)
addButton.translatesAutoresizingMaskIntoConstraints = false
cancelButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
cancelButton.leadingAnchor.constraint(equalTo: packView.view.leadingAnchor, constant: 32),
cancelButton.bottomAnchor.constraint(equalTo: packView.view.bottomAnchor, constant: -32),
addButton.trailingAnchor.constraint(equalTo: packView.view.trailingAnchor, constant: -32),
addButton.bottomAnchor.constraint(equalTo: packView.view.bottomAnchor, constant: -32),
])
}
@objc func add() {
emojiHoarder.addEmojiPack(pack)
emojiHoarder.sendChangeNotif(for: .packs)
dismiss(animated: true)
}
@objc func cancel() {
dismiss(animated: true)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
}
}
@@ -17,6 +17,12 @@ class EmojiPackListView: UITableViewController {
init(emojiHoarder: EmojiHoarder) {
self.emojiHoarder = emojiHoarder
super.init(style: .insetGrouped)
NotificationCenter.default.addObserver(
self,
selector: #selector(refresh),
name: EmojiHoarder.NotifCategory.packs.name,
object: nil
)
}
required init?(coder: NSCoder) {
@@ -116,7 +122,7 @@ class EmojiPackListView: UITableViewController {
}
}
func refresh() {
@objc func refresh() {
self.tableView.reloadData()
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.