mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 20:54:51 +00:00
added a pill showing what pack it is
fix scrollbar floating properly
This commit is contained in:
5 files changed
+84
-14
No files matched your search
@@ -7,6 +7,9 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
A9034532301F42DB00EFFFDF /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9034531301F42DB00EFFFDF /* UIColor.swift */; };
|
||||
A9034533301F42DB00EFFFDF /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9034531301F42DB00EFFFDF /* UIColor.swift */; };
|
||||
A9034534301F42DB00EFFFDF /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9034531301F42DB00EFFFDF /* UIColor.swift */; };
|
||||
A9104C752EB3AE4700D160EA /* Icon.pxd in Resources */ = {isa = PBXBuildFile; fileRef = A9104C722EB3AE4700D160EA /* Icon.pxd */; };
|
||||
A9104C762EB3AE4700D160EA /* StickerSlack.icon in Resources */ = {isa = PBXBuildFile; fileRef = A9104C732EB3AE4700D160EA /* StickerSlack.icon */; };
|
||||
A9104C772EB3AE4700D160EA /* Icon.pxd in Resources */ = {isa = PBXBuildFile; fileRef = A9104C722EB3AE4700D160EA /* Icon.pxd */; };
|
||||
@@ -198,6 +201,7 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
A9034531301F42DB00EFFFDF /* UIColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = "<group>"; };
|
||||
A9104C722EB3AE4700D160EA /* Icon.pxd */ = {isa = PBXFileReference; lastKnownFileType = file; path = Icon.pxd; sourceTree = "<group>"; };
|
||||
A9104C732EB3AE4700D160EA /* StickerSlack.icon */ = {isa = PBXFileReference; lastKnownFileType = folder.iconcomposer.icon; path = StickerSlack.icon; sourceTree = "<group>"; };
|
||||
A9104C7D2EB4022500D160EA /* MSSticker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MSSticker.swift; sourceTree = "<group>"; };
|
||||
@@ -328,6 +332,7 @@
|
||||
A995D95A2F6EBBDD0043E5F5 /* TestStructures.swift */,
|
||||
A9C52F742F89A93D00078588 /* URL.swift */,
|
||||
A9BBC5172EB8FA4500FFE82F /* ViewModifiers.swift */,
|
||||
A9034531301F42DB00EFFFDF /* UIColor.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
sourceTree = "<group>";
|
||||
@@ -770,6 +775,7 @@
|
||||
A9773C2F2EA54AF000F3B753 /* StickerPreview.swift in Sources */,
|
||||
A917BACF2F9B787B008DB31E /* EmojiCollectionViewRepresentable.swift in Sources */,
|
||||
A98FA6612FF3BD5400D50212 /* EmojiCollectionView.swift in Sources */,
|
||||
A9034533301F42DB00EFFFDF /* UIColor.swift in Sources */,
|
||||
A9E8C78F2FF71D8C009A38B5 /* DownloadedViewController.swift in Sources */,
|
||||
A9BE30EC2F5AFE1E00A57668 /* StickerType.swift in Sources */,
|
||||
A995D95C2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */,
|
||||
@@ -796,6 +802,7 @@
|
||||
A9BDEAE02F82BCB4002798DF /* NoStickersView.swift in Sources */,
|
||||
A9BE30FA2F5B03F400A57668 /* Sticker.swift in Sources */,
|
||||
A98C51C0301D2925006CB5A9 /* GifManager.swift in Sources */,
|
||||
A9034532301F42DB00EFFFDF /* UIColor.swift in Sources */,
|
||||
A9E8C79B2FF7256B009A38B5 /* EmojiHoarder.Packs.swift in Sources */,
|
||||
A986A6CD2EB659E000B6E0FA /* MessagesAppViewController.swift in Sources */,
|
||||
A96D59963013D6450086948E /* MessagesPackListView.swift in Sources */,
|
||||
@@ -852,6 +859,7 @@
|
||||
A97322A22FA7B9C8004B657D /* JumboMoji.swift in Sources */,
|
||||
A9C172DC2EB8C9AC008A7885 /* Trie.swift in Sources */,
|
||||
A98FA65B2FF3B29700D50212 /* EmojiTableView.swift in Sources */,
|
||||
A9034534301F42DB00EFFFDF /* UIColor.swift in Sources */,
|
||||
A9FB3EE32FA7AB3A00030E2A /* UIKitGifView.swift in Sources */,
|
||||
A9C52F7A2F89BB0800078588 /* EmojiTableViewCell.swift in Sources */,
|
||||
A957C1752ECCE2CE00EA3EE9 /* SettingsView.swift in Sources */,
|
||||
|
||||
@@ -17,8 +17,9 @@ struct EmojiPack: Identifiable, Codable, Equatable, Hashable, CustomStringConver
|
||||
var description: String {
|
||||
return "\(items.count) emoji\(items.count.plural)"
|
||||
}
|
||||
var downloadedDescription: (Int) -> String {
|
||||
{ dlCount in
|
||||
var downloadedDescription: (EmojiHoarder) -> String {
|
||||
{ hoarder in
|
||||
let dlCount = hoarder.downloadedStickers.intersection(items).count
|
||||
if dlCount != items.count {
|
||||
return "\(dlCount) / \(items.count) emoji\(items.count.plural)"
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// UIColor.swift
|
||||
// StickerSlack
|
||||
//
|
||||
// Created by neon443 on 02/08/2026.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
extension UIColor {
|
||||
var inverted: UIColor {
|
||||
var (r, g, b, a): (CGFloat, CGFloat, CGFloat, CGFloat) = (0, 0, 0, 0)
|
||||
if self.getRed(&r, green: &g, blue: &b, alpha: &a) {
|
||||
return UIColor(red: 1.0-r, green: 1.0-g, blue: 1.0-b, alpha: a)
|
||||
} else {
|
||||
return .clear
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ class MessagesPackListView: UITableViewController {
|
||||
config.textProperties.font = UIFont.systemFont(ofSize: 14)
|
||||
|
||||
let dlCount = emojiHoarder.downloadedStickers.intersection(pack.items).count
|
||||
config.secondaryText = pack.downloadedDescription(dlCount)
|
||||
config.secondaryText = pack.downloadedDescription(emojiHoarder)
|
||||
|
||||
config.secondaryTextProperties.font = UIFont.systemFont(ofSize: 12)
|
||||
config.secondaryTextProperties.color = dlCount == 0 ? .systemRed : .systemGray
|
||||
|
||||
@@ -14,11 +14,19 @@ class StickerBrowserViewController: MSStickerBrowserViewController {
|
||||
var emojiHoarder: EmojiHoarder!
|
||||
var pack: EmojiPack?
|
||||
var msStickers: [MSSticker] = []
|
||||
var labelStack: UIStackView
|
||||
var labelTitle: UILabel
|
||||
var labelSubTitle: UILabel
|
||||
var emptyView: UIViewController
|
||||
|
||||
init(emojiHoarder: EmojiHoarder, pack: EmojiPack?) {
|
||||
self.emojiHoarder = emojiHoarder
|
||||
self.pack = pack
|
||||
|
||||
self.labelTitle = UILabel()
|
||||
self.labelSubTitle = UILabel()
|
||||
self.labelStack = UIStackView(arrangedSubviews: [labelTitle, labelSubTitle])
|
||||
|
||||
self.emptyView = UIHostingController(
|
||||
rootView: EmptyCollectionView(
|
||||
title: "None Downloaded",
|
||||
@@ -35,8 +43,42 @@ class StickerBrowserViewController: MSStickerBrowserViewController {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.view.addSubview(labelStack)
|
||||
labelStack.translatesAutoresizingMaskIntoConstraints = false
|
||||
NSLayoutConstraint.activate([
|
||||
labelStack.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
|
||||
labelStack.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor)
|
||||
])
|
||||
|
||||
labelTitle.font = UIFont.systemFont(ofSize: 16)
|
||||
labelTitle.textAlignment = .center
|
||||
|
||||
labelSubTitle.font = UIFont.systemFont(ofSize: 14)
|
||||
labelSubTitle.textAlignment = .center
|
||||
|
||||
labelStack.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1).inverted.withAlphaComponent(0.75)
|
||||
labelStack.layoutMargins = UIEdgeInsets(top: 5, left: 10, bottom: 5, right: 10)
|
||||
labelStack.isLayoutMarginsRelativeArrangement = true
|
||||
labelStack.layer.masksToBounds = true
|
||||
labelStack.axis = .vertical
|
||||
}
|
||||
|
||||
override func viewDidLayoutSubviews() {
|
||||
super.viewDidLayoutSubviews()
|
||||
setScrollbars()
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
labelStack.layer.cornerRadius = labelStack.frame.height/4
|
||||
}
|
||||
|
||||
@objc func reload() {
|
||||
msStickers = []
|
||||
self.labelTitle.text = pack?.name ?? "All Downloaded"
|
||||
self.labelSubTitle.text = pack?.downloadedDescription(emojiHoarder) ??
|
||||
"\(emojiHoarder.downloadedStickers.count) emoji\(emojiHoarder.downloadedStickers.count.plural)"
|
||||
let names: [String]
|
||||
if let pack {
|
||||
names = emojiHoarder.downloadedStickers.intersection(pack.items).sorted()
|
||||
@@ -55,6 +97,15 @@ class StickerBrowserViewController: MSStickerBrowserViewController {
|
||||
collectionView.setContentOffset(.zero, animated: true)
|
||||
}
|
||||
|
||||
func setScrollbars() {
|
||||
guard let subview = stickerBrowserView.subviews.first,
|
||||
let collectionView = subview as? UICollectionView else { return }
|
||||
collectionView.automaticallyAdjustsScrollIndicatorInsets = false
|
||||
collectionView.directionalLayoutMargins.trailing = 0
|
||||
self.view.directionalLayoutMargins.trailing = 0
|
||||
collectionView.verticalScrollIndicatorInsets.bottom = view.safeAreaInsets.bottom
|
||||
}
|
||||
|
||||
func setEmptyViewTo(visible: Bool) {
|
||||
if visible {
|
||||
emptyView.willMove(toParent: self)
|
||||
@@ -75,16 +126,6 @@ class StickerBrowserViewController: MSStickerBrowserViewController {
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
guard let subview = stickerBrowserView.subviews.first,
|
||||
let collectionView = subview as? UICollectionView else { return }
|
||||
collectionView.automaticallyAdjustsScrollIndicatorInsets = false
|
||||
collectionView.directionalLayoutMargins.trailing = 0
|
||||
self.view.directionalLayoutMargins.trailing = 0
|
||||
collectionView.verticalScrollIndicatorInsets.bottom = view.safeAreaInsets.bottom
|
||||
}
|
||||
|
||||
override func numberOfStickers(in stickerBrowserView: MSStickerBrowserView) -> Int {
|
||||
return msStickers.count
|
||||
}
|
||||
|
||||