feat: Implement real numbers of HashtagTimelineHeader
This commit is contained in:
parent
9d245d3205
commit
b020f566f4
|
@ -8,6 +8,7 @@
|
||||||
import UIKit
|
import UIKit
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
import MastodonUI
|
import MastodonUI
|
||||||
|
import MastodonAsset
|
||||||
|
|
||||||
fileprivate extension CGFloat {
|
fileprivate extension CGFloat {
|
||||||
static let padding: CGFloat = 16
|
static let padding: CGFloat = 16
|
||||||
|
@ -32,7 +33,6 @@ final class HashtagTimelineHeaderView: UIView {
|
||||||
button.cornerRadius = 10
|
button.cornerRadius = 10
|
||||||
button.contentEdgeInsets = UIEdgeInsets(top: 6, left: 16, bottom: 5, right: 16) // set 28pt height
|
button.contentEdgeInsets = UIEdgeInsets(top: 6, left: 16, bottom: 5, right: 16) // set 28pt height
|
||||||
button.titleLabel?.font = .systemFont(ofSize: 14, weight: .bold)
|
button.titleLabel?.font = .systemFont(ofSize: 14, weight: .bold)
|
||||||
button.backgroundColor = .black
|
|
||||||
return button
|
return button
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -101,8 +101,7 @@ private extension HashtagTimelineHeaderView {
|
||||||
|
|
||||||
followButton.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -CGFloat.padding),
|
followButton.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -CGFloat.padding),
|
||||||
followButton.bottomAnchor.constraint(equalTo: postsTodayDescLabel.bottomAnchor),
|
followButton.bottomAnchor.constraint(equalTo: postsTodayDescLabel.bottomAnchor),
|
||||||
followButton.topAnchor.constraint(equalTo: postsTodayLabel.topAnchor),
|
followButton.topAnchor.constraint(equalTo: postsTodayLabel.topAnchor)
|
||||||
followButton.widthAnchor.constraint(equalToConstant: 84)
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +110,28 @@ extension HashtagTimelineHeaderView {
|
||||||
func update(_ entity: Mastodon.Entity.Tag) {
|
func update(_ entity: Mastodon.Entity.Tag) {
|
||||||
titleLabel.text = "#\(entity.name)"
|
titleLabel.text = "#\(entity.name)"
|
||||||
followButton.setTitle(entity.following == true ? "Unfollow" : "Follow", for: .normal)
|
followButton.setTitle(entity.following == true ? "Unfollow" : "Follow", for: .normal)
|
||||||
|
|
||||||
|
followButton.backgroundColor = entity.following == true ? Asset.Colors.Button.tagUnfollow.color : Asset.Colors.Button.tagFollow.color
|
||||||
|
followButton.setTitleColor(
|
||||||
|
entity.following == true ? Asset.Colors.Button.tagFollow.color : Asset.Colors.Button.tagUnfollow.color,
|
||||||
|
for: .normal
|
||||||
|
)
|
||||||
|
|
||||||
|
if let history = entity.history {
|
||||||
|
postCountLabel.text = String(
|
||||||
|
history.reduce(0) { res, acc in
|
||||||
|
res + (Int(acc.uses) ?? 0)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
participantsLabel.text = String(
|
||||||
|
history.reduce(0) { res, acc in
|
||||||
|
res + (Int(acc.accounts) ?? 0)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
postsTodayLabel.text = history.first?.uses
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateWidthConstraint(_ constant: CGFloat) {
|
func updateWidthConstraint(_ constant: CGFloat) {
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"colors" : [
|
||||||
|
{
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0x38",
|
||||||
|
"green" : "0x29",
|
||||||
|
"red" : "0x2B"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "0.700",
|
||||||
|
"blue" : "0x38",
|
||||||
|
"green" : "0x29",
|
||||||
|
"red" : "0x2B"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"colors" : [
|
||||||
|
{
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0xFF",
|
||||||
|
"green" : "0xFF",
|
||||||
|
"red" : "0xFF"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "0.250",
|
||||||
|
"blue" : "0x38",
|
||||||
|
"green" : "0x29",
|
||||||
|
"red" : "0x2B"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,6 +49,8 @@ public enum Asset {
|
||||||
public static let actionToolbar = ColorAsset(name: "Colors/Button/action.toolbar")
|
public static let actionToolbar = ColorAsset(name: "Colors/Button/action.toolbar")
|
||||||
public static let disabled = ColorAsset(name: "Colors/Button/disabled")
|
public static let disabled = ColorAsset(name: "Colors/Button/disabled")
|
||||||
public static let inactive = ColorAsset(name: "Colors/Button/inactive")
|
public static let inactive = ColorAsset(name: "Colors/Button/inactive")
|
||||||
|
public static let tagFollow = ColorAsset(name: "Colors/Button/tagFollow")
|
||||||
|
public static let tagUnfollow = ColorAsset(name: "Colors/Button/tagUnfollow")
|
||||||
}
|
}
|
||||||
public enum Icon {
|
public enum Icon {
|
||||||
public static let plus = ColorAsset(name: "Colors/Icon/plus")
|
public static let plus = ColorAsset(name: "Colors/Icon/plus")
|
||||||
|
|
Loading…
Reference in New Issue