mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-06-15 01:59:07 +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
//
|
|
// IssueMilestoneEventModel.swift
|
|
// Freetime
|
|
//
|
|
// Created by Ryan Nystrom on 7/19/17.
|
|
// Copyright © 2017 Ryan Nystrom. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import IGListKit
|
|
import StyledTextKit
|
|
import DateAgo
|
|
|
|
final class IssueMilestoneEventModel: ListDiffable {
|
|
|
|
enum MilestoneType {
|
|
case milestoned
|
|
case demilestoned
|
|
}
|
|
|
|
let id: String
|
|
let actor: String
|
|
let milestone: String
|
|
let date: Date
|
|
let type: MilestoneType
|
|
let string: StyledTextRenderer
|
|
|
|
init(
|
|
id: String,
|
|
actor: String,
|
|
milestone: String,
|
|
date: Date,
|
|
type: MilestoneType,
|
|
contentSizeCategory: UIContentSizeCategory,
|
|
width: CGFloat
|
|
) {
|
|
self.id = id
|
|
self.actor = actor
|
|
self.milestone = milestone
|
|
self.date = date
|
|
self.type = type
|
|
|
|
let action: String
|
|
switch type {
|
|
case .milestoned: action = NSLocalizedString(" added to milestone ", comment: "")
|
|
case .demilestoned: action = NSLocalizedString(" removed from milestone ", 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: action)
|
|
.save()
|
|
.add(styledText: StyledText(
|
|
text: milestone,
|
|
style: Styles.Text.secondaryBold.with(foreground: Styles.Colors.Gray.dark.color)
|
|
))
|
|
.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
|
|
}
|
|
|
|
}
|
|
|