diff options
Diffstat (limited to 'Hotline/Models/NewsCategory.swift')
| -rw-r--r-- | Hotline/Models/NewsCategory.swift | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Hotline/Models/NewsCategory.swift b/Hotline/Models/NewsCategory.swift new file mode 100644 index 0000000..0ba87a7 --- /dev/null +++ b/Hotline/Models/NewsCategory.swift @@ -0,0 +1,34 @@ +import SwiftUI + +enum NewsCategoryType { + case bundle + case category +} + +@Observable class NewsCategory: Identifiable, Hashable { + let id: UUID = UUID() + + let name: String + let count: UInt16 + let type: NewsCategoryType + + init(hotlineNewsCategory: HotlineNewsCategory) { + self.name = hotlineNewsCategory.name + self.count = hotlineNewsCategory.count + + if hotlineNewsCategory.type == 2 { + self.type = .bundle + } + else { + self.type = .category + } + } + + func hash(into hasher: inout Hasher) { + hasher.combine(self.id) + } + + static func == (lhs: NewsCategory, rhs: NewsCategory) -> Bool { + return lhs.id == rhs.id + } +} |