mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
added emojicollectionviewcell with labels, swill working on it
This commit is contained in:
6 files changed
+131
-10
No files matched your search
@@ -51,6 +51,10 @@
|
|||||||
A9773C2F2EA54AF000F3B753 /* StickerPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9773C2E2EA54AF000F3B753 /* StickerPreview.swift */; };
|
A9773C2F2EA54AF000F3B753 /* StickerPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9773C2E2EA54AF000F3B753 /* StickerPreview.swift */; };
|
||||||
A97BFFBC2F9E6092000441E5 /* EmptyEmojiPackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97BFFBB2F9E6092000441E5 /* EmptyEmojiPackView.swift */; };
|
A97BFFBC2F9E6092000441E5 /* EmptyEmojiPackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97BFFBB2F9E6092000441E5 /* EmptyEmojiPackView.swift */; };
|
||||||
A97BFFBD2F9E6092000441E5 /* EmptyEmojiPackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97BFFBB2F9E6092000441E5 /* EmptyEmojiPackView.swift */; };
|
A97BFFBD2F9E6092000441E5 /* EmptyEmojiPackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97BFFBB2F9E6092000441E5 /* EmptyEmojiPackView.swift */; };
|
||||||
|
A97BFFBF2F9E745C000441E5 /* EmojiCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97BFFBE2F9E745C000441E5 /* EmojiCollectionViewCell.swift */; };
|
||||||
|
A97BFFC02F9E745C000441E5 /* EmojiCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97BFFBE2F9E745C000441E5 /* EmojiCollectionViewCell.swift */; };
|
||||||
|
A97BFFC22F9E7F18000441E5 /* EmojiCollectionFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97BFFC12F9E7F10000441E5 /* EmojiCollectionFlowLayout.swift */; };
|
||||||
|
A97BFFC32F9E7F18000441E5 /* EmojiCollectionFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97BFFC12F9E7F10000441E5 /* EmojiCollectionFlowLayout.swift */; };
|
||||||
A986A6AE2EB658DF00B6E0FA /* Messages.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A969D6932EA3E86500399C05 /* Messages.framework */; };
|
A986A6AE2EB658DF00B6E0FA /* Messages.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A969D6932EA3E86500399C05 /* Messages.framework */; };
|
||||||
A986A6BA2EB658E100B6E0FA /* StickerSlackiMessageApp.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = A986A6AD2EB658DF00B6E0FA /* StickerSlackiMessageApp.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
A986A6BA2EB658E100B6E0FA /* StickerSlackiMessageApp.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = A986A6AD2EB658DF00B6E0FA /* StickerSlackiMessageApp.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||||
A986A6C12EB6595F00B6E0FA /* EmojiHoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F72EA04F2300215164 /* EmojiHoarder.swift */; };
|
A986A6C12EB6595F00B6E0FA /* EmojiHoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F72EA04F2300215164 /* EmojiHoarder.swift */; };
|
||||||
@@ -209,6 +213,8 @@
|
|||||||
A969D6932EA3E86500399C05 /* Messages.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Messages.framework; path = Library/Frameworks/Messages.framework; sourceTree = DEVELOPER_DIR; };
|
A969D6932EA3E86500399C05 /* Messages.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Messages.framework; path = Library/Frameworks/Messages.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
A9773C2E2EA54AF000F3B753 /* StickerPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerPreview.swift; sourceTree = "<group>"; };
|
A9773C2E2EA54AF000F3B753 /* StickerPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerPreview.swift; sourceTree = "<group>"; };
|
||||||
A97BFFBB2F9E6092000441E5 /* EmptyEmojiPackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyEmojiPackView.swift; sourceTree = "<group>"; };
|
A97BFFBB2F9E6092000441E5 /* EmptyEmojiPackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyEmojiPackView.swift; sourceTree = "<group>"; };
|
||||||
|
A97BFFBE2F9E745C000441E5 /* EmojiCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiCollectionViewCell.swift; sourceTree = "<group>"; };
|
||||||
|
A97BFFC12F9E7F10000441E5 /* EmojiCollectionFlowLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiCollectionFlowLayout.swift; sourceTree = "<group>"; };
|
||||||
A986A6AD2EB658DF00B6E0FA /* StickerSlackiMessageApp.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = StickerSlackiMessageApp.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
A986A6AD2EB658DF00B6E0FA /* StickerSlackiMessageApp.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = StickerSlackiMessageApp.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
A986A6C62EB659E000B6E0FA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
A986A6C62EB659E000B6E0FA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
A986A6C72EB659E000B6E0FA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
A986A6C72EB659E000B6E0FA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
@@ -426,8 +432,10 @@
|
|||||||
A94F3E642F9E385300FA6995 /* CollectionView */ = {
|
A94F3E642F9E385300FA6995 /* CollectionView */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
A97BFFC12F9E7F10000441E5 /* EmojiCollectionFlowLayout.swift */,
|
||||||
A917BACD2F9B787B008DB31E /* EmojiCollectionView.swift */,
|
A917BACD2F9B787B008DB31E /* EmojiCollectionView.swift */,
|
||||||
A917BAD02F9B7B68008DB31E /* PlainEmojiCollectionViewCell.swift */,
|
A917BAD02F9B7B68008DB31E /* PlainEmojiCollectionViewCell.swift */,
|
||||||
|
A97BFFBE2F9E745C000441E5 /* EmojiCollectionViewCell.swift */,
|
||||||
);
|
);
|
||||||
path = CollectionView;
|
path = CollectionView;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -688,6 +696,7 @@
|
|||||||
A9A7A4452F68360900BB84C6 /* Pagination.swift in Sources */,
|
A9A7A4452F68360900BB84C6 /* Pagination.swift in Sources */,
|
||||||
A9104C802EB4022500D160EA /* MSSticker.swift in Sources */,
|
A9104C802EB4022500D160EA /* MSSticker.swift in Sources */,
|
||||||
A9A7A43F2F6835F800BB84C6 /* Trending.swift in Sources */,
|
A9A7A43F2F6835F800BB84C6 /* Trending.swift in Sources */,
|
||||||
|
A97BFFC32F9E7F18000441E5 /* EmojiCollectionFlowLayout.swift in Sources */,
|
||||||
A9A7A4422F68360200BB84C6 /* GifObject.swift in Sources */,
|
A9A7A4422F68360200BB84C6 /* GifObject.swift in Sources */,
|
||||||
A97BFFBC2F9E6092000441E5 /* EmptyEmojiPackView.swift in Sources */,
|
A97BFFBC2F9E6092000441E5 /* EmptyEmojiPackView.swift in Sources */,
|
||||||
A957C1772ECD008E00EA3EE9 /* Bundle.swift in Sources */,
|
A957C1772ECD008E00EA3EE9 /* Bundle.swift in Sources */,
|
||||||
@@ -729,6 +738,7 @@
|
|||||||
A9A7A4482F68361200BB84C6 /* Meta.swift in Sources */,
|
A9A7A4482F68361200BB84C6 /* Meta.swift in Sources */,
|
||||||
A995D95C2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */,
|
A995D95C2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */,
|
||||||
A9BE30FE2F5FA47100A57668 /* Hoarder.swift in Sources */,
|
A9BE30FE2F5FA47100A57668 /* Hoarder.swift in Sources */,
|
||||||
|
A97BFFBF2F9E745C000441E5 /* EmojiCollectionViewCell.swift in Sources */,
|
||||||
A9C52F792F89BB0800078588 /* EmojiTableViewCell.swift in Sources */,
|
A9C52F792F89BB0800078588 /* EmojiTableViewCell.swift in Sources */,
|
||||||
A9C52F722F89A85F00078588 /* ShareSheet.swift in Sources */,
|
A9C52F722F89A85F00078588 /* ShareSheet.swift in Sources */,
|
||||||
);
|
);
|
||||||
@@ -807,8 +817,10 @@
|
|||||||
A97BFFBD2F9E6092000441E5 /* EmptyEmojiPackView.swift in Sources */,
|
A97BFFBD2F9E6092000441E5 /* EmptyEmojiPackView.swift in Sources */,
|
||||||
A955B3F62EC22EE900E1732D /* SearchView.swift in Sources */,
|
A955B3F62EC22EE900E1732D /* SearchView.swift in Sources */,
|
||||||
A9BDEADF2F82BC93002798DF /* NoStickersView.swift in Sources */,
|
A9BDEADF2F82BC93002798DF /* NoStickersView.swift in Sources */,
|
||||||
|
A97BFFC02F9E745C000441E5 /* EmojiCollectionViewCell.swift in Sources */,
|
||||||
A9B9A8322EB2CD29004C9245 /* SlackResponse.swift in Sources */,
|
A9B9A8322EB2CD29004C9245 /* SlackResponse.swift in Sources */,
|
||||||
A957C1782ECD008E00EA3EE9 /* Bundle.swift in Sources */,
|
A957C1782ECD008E00EA3EE9 /* Bundle.swift in Sources */,
|
||||||
|
A97BFFC22F9E7F18000441E5 /* EmojiCollectionFlowLayout.swift in Sources */,
|
||||||
A921C2E02ED067BB00E57B1A /* WelcomeView.swift in Sources */,
|
A921C2E02ED067BB00E57B1A /* WelcomeView.swift in Sources */,
|
||||||
A9B9A82E2EB2CCBE004C9245 /* StickerSlackTests.swift in Sources */,
|
A9B9A82E2EB2CCBE004C9245 /* StickerSlackTests.swift in Sources */,
|
||||||
A9A7A44F2F68383900BB84C6 /* GiphyImages.swift in Sources */,
|
A9A7A44F2F68383900BB84C6 /* GiphyImages.swift in Sources */,
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ struct EmojiPackDetailView: View {
|
|||||||
EmojiCollectionView(
|
EmojiCollectionView(
|
||||||
hoarder: hoarder,
|
hoarder: hoarder,
|
||||||
pack: pack,
|
pack: pack,
|
||||||
width: 80
|
width: 80,
|
||||||
|
style: .full
|
||||||
)
|
)
|
||||||
|
|
||||||
GeometryReader { geo in
|
GeometryReader { geo in
|
||||||
|
|||||||
@@ -116,7 +116,8 @@ struct SettingsView: View {
|
|||||||
EmojiCollectionView(
|
EmojiCollectionView(
|
||||||
hoarder: hoarder,
|
hoarder: hoarder,
|
||||||
pack: .test,
|
pack: .test,
|
||||||
width: 50
|
width: 50,
|
||||||
|
style: .plain
|
||||||
)
|
)
|
||||||
} label: {
|
} label: {
|
||||||
Label("grid view", systemImage: "square.grid.2x2.fill")
|
Label("grid view", systemImage: "square.grid.2x2.fill")
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// EmojiCollectionFlowLayout.swift
|
||||||
|
// StickerSlack
|
||||||
|
//
|
||||||
|
// Created by neon443 on 26/04/2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class EmojiCollectionFlowLayout: NSObject, UICollectionViewDelegateFlowLayout {
|
||||||
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
||||||
|
let emojiName = pack
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,11 +14,14 @@ struct EmojiCollectionView: UIViewRepresentable {
|
|||||||
let pack: EmojiPack
|
let pack: EmojiPack
|
||||||
let width: CGFloat
|
let width: CGFloat
|
||||||
let spacing: CGFloat = 16
|
let spacing: CGFloat = 16
|
||||||
|
let style: EmojiCollectionView.Style
|
||||||
|
|
||||||
func makeUIView(context: Context) -> UICollectionView {
|
func makeUIView(context: Context) -> UICollectionView {
|
||||||
let collectionView = context.coordinator as UICollectionViewController
|
let collectionView = context.coordinator as UICollectionViewController
|
||||||
collectionView.collectionView.register(PlainEmojiCollectionViewCell.self, forCellWithReuseIdentifier: "cell")
|
collectionView.collectionView.register(PlainEmojiCollectionViewCell.self, forCellWithReuseIdentifier: "plainCell")
|
||||||
|
collectionView.collectionView.register(EmojiCollectionViewCell.self, forCellWithReuseIdentifier: "cell")
|
||||||
collectionView.collectionView.dataSource = context.coordinator
|
collectionView.collectionView.dataSource = context.coordinator
|
||||||
|
collectionView.collectionView.delegate = context.coordinator
|
||||||
return collectionView.collectionView
|
return collectionView.collectionView
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,21 +32,41 @@ struct EmojiCollectionView: UIViewRepresentable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func makeCoordinator() -> Coordinator {
|
func makeCoordinator() -> Coordinator {
|
||||||
Coordinator(hoarder: hoarder, pack: pack, width: width, spacing: spacing)
|
Coordinator(
|
||||||
|
hoarder: hoarder,
|
||||||
|
pack: pack,
|
||||||
|
width: width,
|
||||||
|
spacing: spacing,
|
||||||
|
style: style
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
final class Coordinator: UICollectionViewController {
|
enum Style {
|
||||||
|
case plain
|
||||||
|
case full
|
||||||
|
}
|
||||||
|
|
||||||
|
final class Coordinator: UICollectionViewController, UICollectionViewDelegateFlowLayout {
|
||||||
var hoarder: EmojiHoarder
|
var hoarder: EmojiHoarder
|
||||||
var pack: EmojiPack
|
var pack: EmojiPack
|
||||||
var width: CGFloat
|
var width: CGFloat
|
||||||
var spacing: CGFloat
|
var spacing: CGFloat
|
||||||
|
var style: EmojiCollectionView.Style
|
||||||
|
|
||||||
var layout = UICollectionViewFlowLayout()
|
var layout = UICollectionViewFlowLayout()
|
||||||
|
|
||||||
init(hoarder: EmojiHoarder, pack: EmojiPack, width: CGFloat, spacing: CGFloat) {
|
init(
|
||||||
|
hoarder: EmojiHoarder,
|
||||||
|
pack: EmojiPack,
|
||||||
|
width: CGFloat,
|
||||||
|
spacing: CGFloat,
|
||||||
|
style: EmojiCollectionView.Style
|
||||||
|
) {
|
||||||
self.hoarder = hoarder
|
self.hoarder = hoarder
|
||||||
self.pack = pack
|
self.pack = pack
|
||||||
self.width = width
|
self.width = width
|
||||||
self.spacing = spacing
|
self.spacing = spacing
|
||||||
|
self.style = style
|
||||||
|
|
||||||
layout.sectionInset.left = 16
|
layout.sectionInset.left = 16
|
||||||
layout.sectionInset.right = 16
|
layout.sectionInset.right = 16
|
||||||
@@ -69,17 +92,32 @@ struct EmojiCollectionView: UIViewRepresentable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! PlainEmojiCollectionViewCell
|
let cell: PlainEmojiCollectionViewCell
|
||||||
|
switch style {
|
||||||
|
case .plain:
|
||||||
|
cell = collectionView.dequeueReusableCell(withReuseIdentifier: "plainCell", for: indexPath) as! PlainEmojiCollectionViewCell
|
||||||
|
case .full:
|
||||||
|
cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! EmojiCollectionViewCell
|
||||||
|
}
|
||||||
|
|
||||||
guard !hoarder.trie.dict.isEmpty else { return cell }
|
guard !hoarder.trie.dict.isEmpty else { return cell }
|
||||||
|
|
||||||
let emojiName = pack.items[indexPath.item]
|
let emojiName = pack.items[indexPath.item]
|
||||||
|
|
||||||
guard let emoji = hoarder.trie.dict[emojiName] else { return cell }
|
guard let emoji = hoarder.trie.dict[emojiName] else { return cell }
|
||||||
|
|
||||||
cell.configure(with: hoarder, emoji: emoji)
|
cell.configure(with: hoarder, emoji: emoji)
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// func collectionView(
|
||||||
|
// _ collectionView: UICollectionView,
|
||||||
|
// layout collectionViewLayout: UICollectionViewLayout,
|
||||||
|
// sizeForItemAt indexPath: IndexPath
|
||||||
|
// ) -> CGSize {
|
||||||
|
// let defaultSize = CGSize(width: width, height: width)
|
||||||
|
//
|
||||||
|
// guard !hoarder.trie.dict.isEmpty else { return defaultSize }
|
||||||
|
// let emojiName = pack.items[indexPath.item]
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
//
|
||||||
|
// EmojiCollectionViewCell.swift
|
||||||
|
// StickerSlack
|
||||||
|
//
|
||||||
|
// Created by neon443 on 26/04/2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class EmojiCollectionViewCell: PlainEmojiCollectionViewCell {
|
||||||
|
let label = UILabel()
|
||||||
|
|
||||||
|
override init(frame: CGRect) {
|
||||||
|
super.init(frame: frame)
|
||||||
|
|
||||||
|
label.font = .preferredFont(forTextStyle: .caption1)
|
||||||
|
label.textAlignment = .center
|
||||||
|
contentView.addSubview(label)
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override func configureSkeleton() {
|
||||||
|
super.configureSkeleton()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func configure(with: EmojiHoarder, emoji: Emoji) {
|
||||||
|
super.configure(with: with, emoji: emoji)
|
||||||
|
label.text = emoji.UIName
|
||||||
|
setNeedsLayout()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func layoutSubviews() {
|
||||||
|
super.layoutSubviews()
|
||||||
|
|
||||||
|
label.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
label.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
|
||||||
|
label.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
|
||||||
|
label.trailingAnchor.constraint(equalTo: contentView.trailingAnchor)
|
||||||
|
])
|
||||||
|
|
||||||
|
// label.frame = contentView.bounds
|
||||||
|
contentView.bringSubviewToFront(label)
|
||||||
|
}
|
||||||
|
|
||||||
|
override func prepareForReuse() {
|
||||||
|
super.prepareForReuse()
|
||||||
|
label.text = nil
|
||||||
|
}
|
||||||
|
}
|
||||||