fixed display etc but like lowk cooked cos massive memory leaks

This commit is contained in:
neon443 committed 2026-05-04 19:58:34 +01:00
1 parent 6a92586535
commit 0957e3b4c3
3 files changed
+38 -32

No files matched your search

+16 -17
View File
@@ -19,21 +19,6 @@ struct JumboMoji: CustomStringConvertible, Hashable {
self.baseName + " " + "\(width)x\(height)"
}
init(baseName: String, items: [String]) {
fatalError()
let itemsBaseNameRemoved = items.map { String($0.dropFirst(baseName.count+1)) }
var coordinates: [(Int, Int)] = []
for item in itemsBaseNameRemoved {
let split = item.dropLast(item.split(separator: "-").last?.count ?? 0)
print(split)
}
self.width = 0
self.height = 0
self.baseName = baseName
self.type = .grid
self.items = items
}
init?(components: [JumboMoji.Components]) {
guard components.allSatisfy({$0.baseName == components.first?.baseName}) else { return nil }
self.baseName = components.first!.baseName
@@ -45,7 +30,16 @@ struct JumboMoji: CustomStringConvertible, Hashable {
self.height = height
self.type = .grid
self.items = components.map { "\($0.baseName)-\($0.coordinate)-\($0.id)-" }
guard width*height == components.count else { return nil }
let sorted = components.sorted {
if $0.y != $1.y {
return $0.y < $1.y
} else {
return $0.x < $1.x
}
}
self.items = sorted.map { $0.name }
}
enum Style {
@@ -123,6 +117,8 @@ struct JumboMoji: CustomStringConvertible, Hashable {
struct Components {
var baseName: String
var coordinate: String
var id: String
var x: Int {
let split = coordinate.split(separator: "-").first ?? "0"
return Int(split) ?? 0
@@ -131,6 +127,9 @@ struct JumboMoji: CustomStringConvertible, Hashable {
let split = coordinate.split(separator: "-").last ?? "0"
return Int(split) ?? 0
}
var id: String
var name: String {
return "\(self.baseName)-\(self.coordinate)-\(self.id)"
}
}
}
+14 -13
View File
@@ -13,7 +13,7 @@ struct JumboMojiTestView: View {
@State var searchResult: [String] = []
var body: some View {
ScrollView {
List {
TextField("search", text: $searchTerm)
.autocorrectionDisabled()
.onChange(of: searchTerm) { _ in
@@ -21,18 +21,19 @@ struct JumboMojiTestView: View {
}
ForEach(JumboMoji.from(names: searchResult), id: \.self) { jumboMoji in
VStack {
ForEach(0..<jumboMoji.height, id: \.self) { row in
ForEach(0..<jumboMoji.width, id: \.self) { col in
StickerPreview(sticker: hoarder.trie.dict[jumboMoji.items[row+col]] ?? .test)
}
}
// EmojiCollectionView(
// hoarder: hoarder,
// items: jumboMoji.items,
// pack: nil,
// width: CGFloat(jumboMoji.width),
// style: .jumboMoji
// )
// ForEach(0..<jumboMoji.height, id: \.self) { row in
// ForEach(0..<jumboMoji.width, id: \.self) { col in
// StickerPreview(sticker: hoarder.trie.dict[jumboMoji.items[row+col]] ?? .test)
// }
// }
EmojiCollectionView(
hoarder: hoarder,
items: jumboMoji.items,
pack: nil,
width: CGFloat(jumboMoji.width),
style: .jumboMoji
)
.frame(width: 100, height: 100)
Text(jumboMoji.description)
}
}
@@ -105,7 +105,6 @@ struct EmojiCollectionView: UIViewRepresentable {
self.width = width
self.style = style
layout.minimumInteritemSpacing = style == .jumboMoji ? 0 : 8
super.init(collectionViewLayout: layout)
self.dataSource = UICollectionViewDiffableDataSource<Int, String>(collectionView: collectionView) { (collectionView: UICollectionView, indexPath: IndexPath, itemIdentifier: String) -> UICollectionViewCell? in
@@ -113,7 +112,14 @@ struct EmojiCollectionView: UIViewRepresentable {
}
collectionView.dataSource = dataSource
collectionView.contentInset = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
if self.style == .jumboMoji {
self.layout.minimumInteritemSpacing = 0
self.layout.minimumLineSpacing = 0
collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
} else {
self.layout.minimumInteritemSpacing = 8
collectionView.contentInset = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
}
}
required init?(coder: NSCoder) {
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.