mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-06-13 01:08:17 +08:00
* clean up title model * update title style * organize issue SC method * remove background colors from styled text in issues * collection view bg white * remove card inset and clean up snap superview code * clean up label design * thread is root and change base font size * remove borders on comment cells * adjust collapse design * adjust comment line spacing and make non-root body smaller * refactor detail view * viewer header background color * more buttons in reaction cell * vertical spacers working * design basically finished; * scroll to bottom accounts for inset * PR review background color white * fixup PR review comments * spacing on merge and review * readme background white * rename to just "spacer" * horizontal spacing * fix tests
88 lines
2.4 KiB
Swift
88 lines
2.4 KiB
Swift
//
|
|
// IssueReferencedModel.swift
|
|
// Freetime
|
|
//
|
|
// Created by Ryan Nystrom on 7/9/17.
|
|
// Copyright © 2017 Ryan Nystrom. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import IGListKit
|
|
import StyledTextKit
|
|
import DateAgo
|
|
import StringHelpers
|
|
|
|
final class IssueReferencedCommitModel: ListDiffable {
|
|
|
|
let id: String
|
|
let owner: String
|
|
let repo: String
|
|
let hash: String
|
|
let actor: String
|
|
let date: Date
|
|
let string: StyledTextRenderer
|
|
|
|
init(
|
|
id: String,
|
|
owner: String,
|
|
repo: String,
|
|
hash: String,
|
|
actor: String,
|
|
date: Date,
|
|
contentSizeCategory: UIContentSizeCategory,
|
|
width: CGFloat
|
|
) {
|
|
self.id = id
|
|
self.owner = owner
|
|
self.repo = repo
|
|
self.hash = hash
|
|
self.actor = actor
|
|
self.date = date
|
|
|
|
let builder = StyledTextBuilder(styledText: StyledText(
|
|
style: Styles.Text.secondary.with(foreground: Styles.Colors.Gray.medium.color)
|
|
))
|
|
.save()
|
|
.add(styledText: StyledText(text: actor, style: Styles.Text.secondaryBold.with(attributes: [
|
|
MarkdownAttribute.username: actor,
|
|
.foregroundColor: Styles.Colors.Gray.dark.color
|
|
])
|
|
))
|
|
.restore()
|
|
.add(text: NSLocalizedString(" referenced ", comment: ""))
|
|
.save()
|
|
.add(styledText: StyledText(
|
|
text: hash.hashDisplay,
|
|
style: Styles.Text.codeBold.with(attributes: [
|
|
.foregroundColor: Styles.Colors.Gray.dark.color,
|
|
MarkdownAttribute.commit: CommitDetails(owner: owner, repo: repo, hash: hash)
|
|
])
|
|
))
|
|
.restore()
|
|
.add(text: " \(date.agoString(.long))", attributes: [MarkdownAttribute.details: DateDetailsFormatter().string(from: date)])
|
|
|
|
self.string = StyledTextRenderer(
|
|
string: builder.build(),
|
|
contentSizeCategory: contentSizeCategory,
|
|
inset: UIEdgeInsets(
|
|
top: Styles.Sizes.inlineSpacing,
|
|
left: 0,
|
|
bottom: Styles.Sizes.inlineSpacing,
|
|
right: 0
|
|
)
|
|
).warm(width: width)
|
|
}
|
|
|
|
// MARK: ListDiffable
|
|
|
|
func diffIdentifier() -> NSObjectProtocol {
|
|
return id as NSObjectProtocol
|
|
}
|
|
|
|
func isEqual(toDiffableObject object: ListDiffable?) -> Bool {
|
|
return true
|
|
}
|
|
|
|
}
|
|
|