mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
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:
5 files changed
+102
-4
No files matched your search
@@ -285,6 +285,7 @@ class EmojiHoarder: BaseHoarder {
|
|||||||
enum NotifCategory {
|
enum NotifCategory {
|
||||||
case emojis
|
case emojis
|
||||||
case downloadedEmojis
|
case downloadedEmojis
|
||||||
|
case packs
|
||||||
|
|
||||||
var name: Notification.Name {
|
var name: Notification.Name {
|
||||||
switch self {
|
switch self {
|
||||||
@@ -292,6 +293,8 @@ class EmojiHoarder: BaseHoarder {
|
|||||||
Notification.Name("EmojiHoarder.notif.emojis")
|
Notification.Name("EmojiHoarder.notif.emojis")
|
||||||
case .downloadedEmojis:
|
case .downloadedEmojis:
|
||||||
Notification.Name("EmojiHoarder.notif.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 style: EmojiCollectionView.Style
|
||||||
var onRemove: ((String) -> Void)?
|
var onRemove: ((String) -> Void)?
|
||||||
var onTap: ((String) -> Void)?
|
var onTap: ((String) -> Void)?
|
||||||
var onEditChange: ((Bool) -> Void)?
|
var onEditChange: (() -> Void)?
|
||||||
|
|
||||||
var dataSource: UICollectionViewDiffableDataSource<Int, String>!
|
var dataSource: UICollectionViewDiffableDataSource<Int, String>!
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ final class EmojiCollectionView: UICollectionViewController, UICollectionViewDel
|
|||||||
override func setEditing(_ editing: Bool, animated: Bool) {
|
override func setEditing(_ editing: Bool, animated: Bool) {
|
||||||
super.setEditing(editing, animated: animated)
|
super.setEditing(editing, animated: animated)
|
||||||
|
|
||||||
onEditChange?(editing)
|
onEditChange?()
|
||||||
|
|
||||||
for cell in collectionView.visibleCells {
|
for cell in collectionView.visibleCells {
|
||||||
if let cell = cell as? EmojiCollectionViewCell {
|
if let cell = cell as? EmojiCollectionViewCell {
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ class EmojiPackDetailViewController: UIViewController {
|
|||||||
|
|
||||||
let emptyCollectionView: UIViewController
|
let emptyCollectionView: UIViewController
|
||||||
|
|
||||||
|
var effectView: UIVisualEffectView!
|
||||||
|
var countLabel: UILabel!
|
||||||
var adderSheetButton: UIBarButtonItem!
|
var adderSheetButton: UIBarButtonItem!
|
||||||
var downloadButton: UIAction!
|
var downloadButton: UIAction!
|
||||||
var renameButton: UIAction!
|
var renameButton: UIAction!
|
||||||
@@ -81,6 +83,32 @@ class EmojiPackDetailViewController: UIViewController {
|
|||||||
self.refreshUI()
|
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))
|
self.adderSheetButton = UIBarButtonItem(image: UIImage(systemName: "plus"), style: .plain, target: self, action: #selector(showSheet))
|
||||||
|
|
||||||
let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(hideSheet))
|
let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(hideSheet))
|
||||||
@@ -108,6 +136,7 @@ class EmojiPackDetailViewController: UIViewController {
|
|||||||
|
|
||||||
func refreshUI() {
|
func refreshUI() {
|
||||||
self.navigationItem.title = pack.name
|
self.navigationItem.title = pack.name
|
||||||
|
self.countLabel.text = pack.description
|
||||||
// self.navigationItem.documentProperties
|
// self.navigationItem.documentProperties
|
||||||
checkForEmptyPack()
|
checkForEmptyPack()
|
||||||
updateDownloadButton()
|
updateDownloadButton()
|
||||||
@@ -221,6 +250,12 @@ class EmojiPackDetailViewController: UIViewController {
|
|||||||
refreshUI()
|
refreshUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func viewDidLayoutSubviews() {
|
||||||
|
super.viewDidLayoutSubviews()
|
||||||
|
effectView.layer.cornerRadius = effectView.bounds.height/2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override func viewWillDisappear(_ animated: Bool) {
|
override func viewWillDisappear(_ animated: Bool) {
|
||||||
super.viewWillDisappear(animated)
|
super.viewWillDisappear(animated)
|
||||||
hoarder.updateEmojiPack(pack)
|
hoarder.updateEmojiPack(pack)
|
||||||
|
|||||||
@@ -12,11 +12,36 @@ class EmojiPackImporterViewController: UINavigationController {
|
|||||||
var emojiHoarder: EmojiHoarder
|
var emojiHoarder: EmojiHoarder
|
||||||
var pack: EmojiPack
|
var pack: EmojiPack
|
||||||
var packView: EmojiPackDetailViewController
|
var packView: EmojiPackDetailViewController
|
||||||
|
var addButton: UIButton
|
||||||
|
var cancelButton: UIButton
|
||||||
|
|
||||||
init(emojiHoarder: EmojiHoarder, pack: EmojiPack) {
|
init(emojiHoarder: EmojiHoarder, pack: EmojiPack) {
|
||||||
self.emojiHoarder = emojiHoarder
|
self.emojiHoarder = emojiHoarder
|
||||||
self.pack = pack
|
self.pack = pack
|
||||||
self.packView = EmojiPackDetailViewController(with: emojiHoarder, andPack: 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)
|
super.init(rootViewController: packView)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,6 +51,35 @@ class EmojiPackImporterViewController: UINavigationController {
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.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) {
|
init(emojiHoarder: EmojiHoarder) {
|
||||||
self.emojiHoarder = emojiHoarder
|
self.emojiHoarder = emojiHoarder
|
||||||
super.init(style: .insetGrouped)
|
super.init(style: .insetGrouped)
|
||||||
|
NotificationCenter.default.addObserver(
|
||||||
|
self,
|
||||||
|
selector: #selector(refresh),
|
||||||
|
name: EmojiHoarder.NotifCategory.packs.name,
|
||||||
|
object: nil
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
@@ -116,7 +122,7 @@ class EmojiPackListView: UITableViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func refresh() {
|
@objc func refresh() {
|
||||||
self.tableView.reloadData()
|
self.tableView.reloadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||