Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified ColorStyleNode and TextStyleNode Hasahble to avoid duplicated values #61

Merged
merged 1 commit into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Sources/Fugen/Models/ColorStyle/ColorStyleNode.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

struct ColorStyleNode: Encodable, Hashable {
struct ColorStyleNode: Encodable {

// MARK: - Instance Properties

Expand All @@ -9,3 +9,14 @@ struct ColorStyleNode: Encodable, Hashable {
let description: String?
let color: Color
}

extension ColorStyleNode: Hashable {
static func == (lhs: ColorStyleNode, rhs: ColorStyleNode) -> Bool {
return lhs.name == rhs.name && lhs.color == rhs.color
}

func hash(into hasher: inout Hasher) {
hasher.combine(name)
hasher.combine(color)
}
}
26 changes: 25 additions & 1 deletion Sources/Fugen/Models/TextStyle/TextStyleNode.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

struct TextStyleNode: Encodable, Hashable {
struct TextStyleNode: Encodable {

// MARK: - Instance Properties

Expand All @@ -15,3 +15,27 @@ struct TextStyleNode: Encodable, Hashable {
let lineHeight: Double?
let letterSpacing: Double?
}

extension TextStyleNode: Hashable {
static func == (lhs: TextStyleNode, rhs: TextStyleNode) -> Bool {
return lhs.name == rhs.name &&
lhs.font == rhs.font &&
lhs.strikethrough == rhs.strikethrough &&
lhs.underline == rhs.underline &&
lhs.paragraphSpacing == rhs.paragraphSpacing &&
lhs.paragraphIndent == rhs.paragraphIndent &&
lhs.lineHeight == rhs.lineHeight &&
lhs.letterSpacing == rhs.letterSpacing
}

func hash(into hasher: inout Hasher) {
hasher.combine(name)
hasher.combine(font)
hasher.combine(strikethrough)
hasher.combine(underline)
hasher.combine(paragraphSpacing)
hasher.combine(paragraphIndent)
hasher.combine(lineHeight)
hasher.combine(letterSpacing)
}
}