mirror of
https://github.com/metabolist/metatext.git
synced 2024-12-23 22:10:29 +00:00
33 lines
1,001 B
Swift
33 lines
1,001 B
Swift
// Copyright © 2021 Metabolist. All rights reserved.
|
|
|
|
import UIKit
|
|
import ViewModels
|
|
|
|
extension Dictionary where Key == PickerEmoji.Category, Value == [PickerEmoji] {
|
|
func snapshot() -> NSDiffableDataSourceSnapshot<PickerEmoji.Category, PickerEmoji> {
|
|
var snapshot = NSDiffableDataSourceSnapshot<PickerEmoji.Category, PickerEmoji>()
|
|
|
|
snapshot.appendSections(keys.sorted())
|
|
|
|
for (key, value) in self {
|
|
snapshot.appendItems(value, toSection: key)
|
|
}
|
|
|
|
return snapshot
|
|
}
|
|
}
|
|
|
|
extension PickerEmoji.Category {
|
|
var displayName: String {
|
|
switch self {
|
|
case .frequentlyUsed:
|
|
return NSLocalizedString("emoji.frequently-used", comment: "")
|
|
case .custom:
|
|
return NSLocalizedString("emoji.custom", comment: "")
|
|
case let .customNamed(name):
|
|
return name
|
|
case let .systemGroup(group):
|
|
return NSLocalizedString(group.localizedStringKey, comment: "")
|
|
}
|
|
}
|
|
}
|