Skip to content

Commit

Permalink
优化富文本设置的复用问题
Browse files Browse the repository at this point in the history
  • Loading branch information
fun committed Jul 20, 2022
1 parent ee059c1 commit 0238c36
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Jenga.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "Jenga"
s.version = "1.1.4"
s.version = "1.1.5"
s.summary = "像SwiftUI一样使用DSL代码搭建UITableView"

s.homepage = "https://github.com/fanglinwei/Jenga"
Expand Down
12 changes: 7 additions & 5 deletions Sources/Jenga/Core/Model/DetailText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import UIKit
public struct DetailText: Equatable {

public var type: `Type` = .none
public var text: TextValues
public var text: TextValues = .init()

public enum `Type` {
case none
Expand All @@ -22,10 +22,7 @@ public struct DetailText: Equatable {
}
}

public init(_ type: `Type` = .none, _ string: String? = .none) {
self.type = type
self.text = .init(string: string)
}
public init() { }
}

public extension DetailText {
Expand All @@ -43,4 +40,9 @@ public extension DetailText {
static func value2(_ value: String) -> DetailText {
return .init(.value2, value)
}

private init(_ type: `Type`, _ string: String?) {
self.type = type
self.text.string = string
}
}
4 changes: 3 additions & 1 deletion Sources/Jenga/Core/Model/Text.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public protocol TextKey {

public struct TextValues: Equatable {

private var options = [OptionsKeys: Any]()
private var options: [OptionsKeys: Any] = [:]

public init() { }

public init(string value: String?) {
self.string = value
Expand Down
8 changes: 7 additions & 1 deletion Sources/Jenga/Core/Row/System/SystemRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ public extension SystemRow {
}

func detail(_ value: DetailText.`Type`) -> Self {
reform { $0.detailText = detailText.map { .init(value, $0.text.string) } }
reform {
$0.detailText = detailText.map { detailText in
var temp = detailText
temp.type = value
return temp
}
}
}
}

Expand Down

0 comments on commit 0238c36

Please sign in to comment.