mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-06-11 16:09:48 +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
92 lines
2.5 KiB
Swift
92 lines
2.5 KiB
Swift
//
|
|
// IssueRequestModel.swift
|
|
// Freetime
|
|
//
|
|
// Created by Ryan Nystrom on 7/12/17.
|
|
// Copyright © 2017 Ryan Nystrom. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import IGListKit
|
|
import StyledTextKit
|
|
import DateAgo
|
|
|
|
final class IssueRequestModel: ListDiffable {
|
|
|
|
enum Event {
|
|
case assigned
|
|
case unassigned
|
|
case reviewRequested
|
|
case reviewRequestRemoved
|
|
}
|
|
|
|
let id: String
|
|
let actor: String
|
|
let user: String
|
|
let date: Date
|
|
let event: Event
|
|
let string: StyledTextRenderer
|
|
|
|
init(
|
|
id: String,
|
|
actor: String,
|
|
user: String,
|
|
date: Date,
|
|
event: Event,
|
|
contentSizeCategory: UIContentSizeCategory,
|
|
width: CGFloat
|
|
) {
|
|
self.id = id
|
|
self.actor = actor
|
|
self.user = user
|
|
self.date = date
|
|
self.event = event
|
|
|
|
let phrase: String
|
|
switch event {
|
|
case .assigned: phrase = NSLocalizedString(" assigned", comment: "")
|
|
case .unassigned: phrase = NSLocalizedString(" unassigned", comment: "")
|
|
case .reviewRequested: phrase = NSLocalizedString(" requested", comment: "")
|
|
case .reviewRequestRemoved: phrase = NSLocalizedString(" removed", comment: "")
|
|
}
|
|
|
|
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: phrase)
|
|
.save()
|
|
.add(styledText: StyledText(text: " \(user)", style: Styles.Text.secondaryBold))
|
|
.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
|
|
}
|
|
|
|
}
|