2021-05-27 07:56:55 +02:00
|
|
|
//
|
|
|
|
// ProfileFieldItem.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK Cirno on 2021-5-25.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Combine
|
|
|
|
import MastodonSDK
|
2021-07-23 13:10:27 +02:00
|
|
|
import MastodonMeta
|
2021-05-27 07:56:55 +02:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
enum ProfileFieldItem: Hashable {
|
|
|
|
case field(field: FieldValue)
|
|
|
|
case editField(field: FieldValue)
|
|
|
|
case addEntry
|
2021-05-27 07:56:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extension ProfileFieldItem {
|
|
|
|
struct FieldValue: Equatable, Hashable {
|
|
|
|
let id: UUID
|
2021-06-24 13:20:41 +02:00
|
|
|
|
2021-05-27 07:56:55 +02:00
|
|
|
var name: CurrentValueSubject<String, Never>
|
|
|
|
var value: CurrentValueSubject<String, Never>
|
2022-01-27 14:23:39 +01:00
|
|
|
|
|
|
|
let emojiMeta: MastodonContent.Emojis
|
|
|
|
|
|
|
|
init(
|
|
|
|
id: UUID = UUID(),
|
|
|
|
name: String,
|
|
|
|
value: String,
|
|
|
|
emojiMeta: MastodonContent.Emojis
|
|
|
|
) {
|
2021-05-27 07:56:55 +02:00
|
|
|
self.id = id
|
|
|
|
self.name = CurrentValueSubject(name)
|
|
|
|
self.value = CurrentValueSubject(value)
|
2022-01-27 14:23:39 +01:00
|
|
|
self.emojiMeta = emojiMeta
|
2021-05-27 07:56:55 +02:00
|
|
|
}
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
static func == (
|
|
|
|
lhs: ProfileFieldItem.FieldValue,
|
|
|
|
rhs: ProfileFieldItem.FieldValue
|
|
|
|
) -> Bool {
|
2021-05-27 07:56:55 +02:00
|
|
|
return lhs.id == rhs.id
|
|
|
|
&& lhs.name.value == rhs.name.value
|
|
|
|
&& lhs.value.value == rhs.value.value
|
2022-01-27 14:23:39 +01:00
|
|
|
&& lhs.emojiMeta == rhs.emojiMeta
|
2021-05-27 07:56:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func hash(into hasher: inout Hasher) {
|
|
|
|
hasher.combine(id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|