uikit pack manager

This commit is contained in:
Nihaal Sharma committed 2026-07-06 00:50:52 +01:00
1 parent 1b8ec6a414
commit ffc20b2dad
5 files changed
+96 -12

No files matched your search

+6
View File
@@ -151,6 +151,8 @@
A9D15B8B2EB1142C00404792 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; }; A9D15B8B2EB1142C00404792 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; };
A9D53AEA2FFB0272001C1BB9 /* EmojiPackManagerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D53AE92FFB0272001C1BB9 /* EmojiPackManagerController.swift */; }; A9D53AEA2FFB0272001C1BB9 /* EmojiPackManagerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D53AE92FFB0272001C1BB9 /* EmojiPackManagerController.swift */; };
A9D53AEB2FFB0272001C1BB9 /* EmojiPackManagerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D53AE92FFB0272001C1BB9 /* EmojiPackManagerController.swift */; }; A9D53AEB2FFB0272001C1BB9 /* EmojiPackManagerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D53AE92FFB0272001C1BB9 /* EmojiPackManagerController.swift */; };
A9D53AED2FFB0E83001C1BB9 /* EmojiPackListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D53AEC2FFB0E83001C1BB9 /* EmojiPackListView.swift */; };
A9D53AEE2FFB0E83001C1BB9 /* EmojiPackListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D53AEC2FFB0E83001C1BB9 /* EmojiPackListView.swift */; };
A9D6A8212F7014AE00F198FB /* TestStructures.swift in Sources */ = {isa = PBXBuildFile; fileRef = A995D95A2F6EBBDD0043E5F5 /* TestStructures.swift */; }; A9D6A8212F7014AE00F198FB /* TestStructures.swift in Sources */ = {isa = PBXBuildFile; fileRef = A995D95A2F6EBBDD0043E5F5 /* TestStructures.swift */; };
A9E8C78F2FF71D8C009A38B5 /* DownloadedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E8C78E2FF71D8C009A38B5 /* DownloadedViewController.swift */; }; A9E8C78F2FF71D8C009A38B5 /* DownloadedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E8C78E2FF71D8C009A38B5 /* DownloadedViewController.swift */; };
A9E8C7902FF71D8C009A38B5 /* DownloadedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E8C78E2FF71D8C009A38B5 /* DownloadedViewController.swift */; }; A9E8C7902FF71D8C009A38B5 /* DownloadedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E8C78E2FF71D8C009A38B5 /* DownloadedViewController.swift */; };
@@ -285,6 +287,7 @@
A9CD6C372EDDE37500B7F421 /* EmojiPackManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackManager.swift; sourceTree = "<group>"; }; A9CD6C372EDDE37500B7F421 /* EmojiPackManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackManager.swift; sourceTree = "<group>"; };
A9D15B892EB1142C00404792 /* EmojiPack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPack.swift; sourceTree = "<group>"; }; A9D15B892EB1142C00404792 /* EmojiPack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPack.swift; sourceTree = "<group>"; };
A9D53AE92FFB0272001C1BB9 /* EmojiPackManagerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackManagerController.swift; sourceTree = "<group>"; }; A9D53AE92FFB0272001C1BB9 /* EmojiPackManagerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackManagerController.swift; sourceTree = "<group>"; };
A9D53AEC2FFB0E83001C1BB9 /* EmojiPackListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackListView.swift; sourceTree = "<group>"; };
A9E2ECD72EB74CE00038B2D6 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; A9E2ECD72EB74CE00038B2D6 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
A9E8C78E2FF71D8C009A38B5 /* DownloadedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadedViewController.swift; sourceTree = "<group>"; }; A9E8C78E2FF71D8C009A38B5 /* DownloadedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadedViewController.swift; sourceTree = "<group>"; };
A9E8C7992FF7256B009A38B5 /* EmojiHoarder.Packs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiHoarder.Packs.swift; sourceTree = "<group>"; }; A9E8C7992FF7256B009A38B5 /* EmojiHoarder.Packs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiHoarder.Packs.swift; sourceTree = "<group>"; };
@@ -406,6 +409,7 @@
children = ( children = (
A94693D62FEF0A4200E56AC5 /* TabbedContentView.swift */, A94693D62FEF0A4200E56AC5 /* TabbedContentView.swift */,
A9D53AE92FFB0272001C1BB9 /* EmojiPackManagerController.swift */, A9D53AE92FFB0272001C1BB9 /* EmojiPackManagerController.swift */,
A9D53AEC2FFB0E83001C1BB9 /* EmojiPackListView.swift */,
A94F3E632F9E384D00FA6995 /* TableView */, A94F3E632F9E384D00FA6995 /* TableView */,
A94F3E642F9E385300FA6995 /* CollectionView */, A94F3E642F9E385300FA6995 /* CollectionView */,
A9C52F712F89A85F00078588 /* ShareSheet.swift */, A9C52F712F89A85F00078588 /* ShareSheet.swift */,
@@ -770,6 +774,7 @@
A957C1772ECD008E00EA3EE9 /* Bundle.swift in Sources */, A957C1772ECD008E00EA3EE9 /* Bundle.swift in Sources */,
A957C17F2ECFAA1100EA3EE9 /* GifView.swift in Sources */, A957C17F2ECFAA1100EA3EE9 /* GifView.swift in Sources */,
A957C1742ECCE2CE00EA3EE9 /* SettingsView.swift in Sources */, A957C1742ECCE2CE00EA3EE9 /* SettingsView.swift in Sources */,
A9D53AEE2FFB0E83001C1BB9 /* EmojiPackListView.swift in Sources */,
A9A7A44B2F6837A800BB84C6 /* GiphyUser.swift in Sources */, A9A7A44B2F6837A800BB84C6 /* GiphyUser.swift in Sources */,
A9E8C7A62FF7C34A009A38B5 /* EmojiPackDetailViewRepresentable.swift in Sources */, A9E8C7A62FF7C34A009A38B5 /* EmojiPackDetailViewRepresentable.swift in Sources */,
A9EB72392EB93FDB00658CEB /* EmojiTableViewRepresentable.swift in Sources */, A9EB72392EB93FDB00658CEB /* EmojiTableViewRepresentable.swift in Sources */,
@@ -889,6 +894,7 @@
A98BD15C2FF5242700ADC264 /* EmojiPackPreview.swift in Sources */, A98BD15C2FF5242700ADC264 /* EmojiPackPreview.swift in Sources */,
A9BBC51A2EB8FA4500FFE82F /* ViewModifiers.swift in Sources */, A9BBC51A2EB8FA4500FFE82F /* ViewModifiers.swift in Sources */,
A995D95B2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */, A995D95B2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */,
A9D53AED2FFB0E83001C1BB9 /* EmojiPackListView.swift in Sources */,
A9E8C7A02FF726DA009A38B5 /* EmojiHoarder.LetterStats.swift in Sources */, A9E8C7A02FF726DA009A38B5 /* EmojiHoarder.LetterStats.swift in Sources */,
A955B3ED2EC22C4A00E1732D /* DownloadedView.swift in Sources */, A955B3ED2EC22C4A00E1732D /* DownloadedView.swift in Sources */,
A9EC46AD2F6D9E4600E066E6 /* Hoarder.swift in Sources */, A9EC46AD2F6D9E4600E066E6 /* Hoarder.swift in Sources */,
@@ -10,7 +10,7 @@ import UIKit
import SwiftUI import SwiftUI
import UniformTypeIdentifiers import UniformTypeIdentifiers
class EmojiPackDetailViewController: UINavigationController { class EmojiPackDetailViewController: UIViewController {
var hoarder: EmojiHoarder var hoarder: EmojiHoarder
var pack: EmojiPack var pack: EmojiPack
let collectionView: EmojiCollectionView let collectionView: EmojiCollectionView
@@ -62,7 +62,8 @@ class EmojiPackDetailViewController: UINavigationController {
// collectionView.view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor) // collectionView.view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor)
// ]) // ])
super.init(rootViewController: collectionView) // super.init(rootViewController: collectionView)
super.init(nibName: nil, bundle: nil)
collectionView.navigationItem.title = pack.name collectionView.navigationItem.title = pack.name
collectionView.onEditChange = { editing in collectionView.onEditChange = { editing in
@@ -79,7 +80,6 @@ class EmojiPackDetailViewController: UINavigationController {
} }
} }
self.isToolbarHidden = false
collectionView.toolbarItems = [shareButton, downloadButton] collectionView.toolbarItems = [shareButton, downloadButton]
// collectionView.toolbarItems = [editButton, adderSheetButton] // collectionView.toolbarItems = [editButton, adderSheetButton]
@@ -0,0 +1,51 @@
//
// EmojiPackListView.swift
// StickerSlack
//
// Created by neon443 on 05/07/2026.
//
import Foundation
import UIKit
class EmojiPackListView: UITableViewController {
var emojiHoarder: EmojiHoarder
init(emojiHoarder: EmojiHoarder) {
self.emojiHoarder = emojiHoarder
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return emojiHoarder.emojiPacks.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
var content = cell.defaultContentConfiguration()
guard indexPath.row+1 <= emojiHoarder.emojiPacks.count else { return cell }
let pack = emojiHoarder.emojiPacks[indexPath.row]
content.text = pack.name
content.secondaryText = "\(pack.items.count) item\(pack.items.count.plural)"
cell.contentConfiguration = content
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard indexPath.row+1 <= emojiHoarder.emojiPacks.count else { return }
let pack = emojiHoarder.emojiPacks[indexPath.row]
print(indexPath)
let detailView = EmojiPackDetailViewController(with: emojiHoarder, andPack: pack)
super.navigationController?.pushViewController(detailView.collectionView, animated: true)
}
}
@@ -8,19 +8,18 @@
import Foundation import Foundation
import UIKit import UIKit
class EmojiPackManagerController: UINavigationController { class EmojiPackManagerController: UINavigationController, UINavigationControllerDelegate {
var emojiHoarder: EmojiHoarder var emojiHoarder: EmojiHoarder
var tableView: UITableViewController
init(emojiHoarder: EmojiHoarder) { init(emojiHoarder: EmojiHoarder) {
self.emojiHoarder = emojiHoarder self.emojiHoarder = emojiHoarder
self.tableView = EmojiPackListView(emojiHoarder: emojiHoarder)
super.init(nibName: nil, bundle: nil) super.init(rootViewController: tableView)
self.isToolbarHidden = false
} }
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
} }
+31 -3
View File
@@ -9,8 +9,10 @@ import Foundation
import UIKit import UIKit
import SwiftUI import SwiftUI
final class TabbedContentView: UITabBarController { final class TabbedContentView: UITabBarController, UITabBarControllerDelegate {
func setupTabs(with emojiHoarder: EmojiHoarder, and gifHoarder: GifHoarder) { func setupTabs(with emojiHoarder: EmojiHoarder, and gifHoarder: GifHoarder) {
self.delegate = self
let browseView = EmojiTableView(hoarder: emojiHoarder, items: emojiHoarder.emojis.map { $0.name }) let browseView = EmojiTableView(hoarder: emojiHoarder, items: emojiHoarder.emojis.map { $0.name })
let browse = UINavigationController(rootViewController: browseView) let browse = UINavigationController(rootViewController: browseView)
browseView.navigationItem.title = "Browse" browseView.navigationItem.title = "Browse"
@@ -18,8 +20,8 @@ final class TabbedContentView: UITabBarController {
// let packsView = EmojiPackManager(hoarder: emojiHoarder) // let packsView = EmojiPackManager(hoarder: emojiHoarder)
// let packs = UIHostingController(rootView: packsView) // let packs = UIHostingController(rootView: packsView)
// let packs = EmojiPackManagerController(emojiHoarder: emojiHoarder) let packs = EmojiPackManagerController(emojiHoarder: emojiHoarder)
let packs = EmojiPackDetailViewController(with: emojiHoarder, andPack: .test) // let packs = EmojiPackDetailViewController(with: emojiHoarder, andPack: .test)
packs.tabBarItem = UITabBarItem(title: "Packs", image: UIImage(systemName: "square.stack.3d.up.fill"), tag: 1) packs.tabBarItem = UITabBarItem(title: "Packs", image: UIImage(systemName: "square.stack.3d.up.fill"), tag: 1)
let downloaded = DownloadedViewController(emojiHoarder: emojiHoarder) let downloaded = DownloadedViewController(emojiHoarder: emojiHoarder)
@@ -37,4 +39,30 @@ final class TabbedContentView: UITabBarController {
self.setViewControllers([browse, packs, downloaded, search, settings], animated: false) self.setViewControllers([browse, packs, downloaded, search, settings], animated: false)
} }
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
guard let selectedVc = selectedViewController else { return true }
if viewController.tabBarItem.tag == selectedVc.tabBarItem.tag {
guard let navController = viewController as? UINavigationController else { return true }
navController.popToRootViewController(animated: true)
return true
}
return true
}
func tabBarController(_ tabBarController: UITabBarController, willSelect viewController: UIViewController) {
guard let navController = viewController as? UINavigationController else { return }
navController.popToRootViewController(animated: true)
}
// override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
// item
// }/
// func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
// let navController = viewController as! UINavigationController
// navController.popViewController(animated: true)
// }
} }
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.