mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-06-18 04:08:16 +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
94 lines
2.4 KiB
Swift
94 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
|
|
|
|
final class IssueReferencedModel: ListDiffable {
|
|
|
|
enum State: Int {
|
|
case open
|
|
case closed
|
|
case merged
|
|
}
|
|
|
|
let id: String
|
|
let owner: String
|
|
let repo: String
|
|
let number: Int
|
|
let pullRequest: Bool
|
|
let state: State
|
|
let date: Date
|
|
let title: String
|
|
let actor: String
|
|
let string: StyledTextRenderer
|
|
|
|
init(
|
|
id: String,
|
|
owner: String,
|
|
repo: String,
|
|
number: Int,
|
|
pullRequest: Bool,
|
|
state: State,
|
|
date: Date,
|
|
title: String,
|
|
actor: String,
|
|
contentSizeCategory: UIContentSizeCategory,
|
|
width: CGFloat
|
|
) {
|
|
self.id = id
|
|
self.owner = owner
|
|
self.repo = repo
|
|
self.number = number
|
|
self.pullRequest = pullRequest
|
|
self.state = state
|
|
self.date = date
|
|
self.title = title
|
|
self.actor = actor
|
|
|
|
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(text: date.agoString(.long), attributes: [MarkdownAttribute.details: DateDetailsFormatter().string(from: date)])
|
|
.restore()
|
|
.add(text: "\n")
|
|
.save()
|
|
.add(styledText: StyledText(text: title, style: Styles.Text.secondaryBold))
|
|
.restore()
|
|
.add(text: " #\(number)")
|
|
|
|
self.string = StyledTextRenderer(
|
|
string: builder.build(),
|
|
contentSizeCategory: contentSizeCategory,
|
|
inset: IssueReferencedCell.inset
|
|
).warm(width: width)
|
|
}
|
|
|
|
// MARK: ListDiffable
|
|
|
|
func diffIdentifier() -> NSObjectProtocol {
|
|
return id as NSObjectProtocol
|
|
}
|
|
|
|
func isEqual(toDiffableObject object: ListDiffable?) -> Bool {
|
|
return true
|
|
}
|
|
|
|
}
|