chore: update UI appearance. remove not used separator line component

This commit is contained in:
CMK 2021-02-24 18:40:47 +08:00
parent 6182390699
commit 2988e71611
8 changed files with 23 additions and 40 deletions

View File

@ -30,32 +30,22 @@ protocol StatusContentWarningAttribute {
extension Item { extension Item {
class StatusTimelineAttribute: Hashable, StatusContentWarningAttribute { class StatusTimelineAttribute: Hashable, StatusContentWarningAttribute {
var separatorLineStyle: SeparatorLineStyle = .indent
var isStatusTextSensitive: Bool = false var isStatusTextSensitive: Bool = false
public init( public init(
separatorLineStyle: Item.StatusTimelineAttribute.SeparatorLineStyle = .indent,
isStatusTextSensitive: Bool isStatusTextSensitive: Bool
) { ) {
self.separatorLineStyle = separatorLineStyle
self.isStatusTextSensitive = isStatusTextSensitive self.isStatusTextSensitive = isStatusTextSensitive
} }
static func == (lhs: Item.StatusTimelineAttribute, rhs: Item.StatusTimelineAttribute) -> Bool { static func == (lhs: Item.StatusTimelineAttribute, rhs: Item.StatusTimelineAttribute) -> Bool {
return lhs.separatorLineStyle == rhs.separatorLineStyle && return lhs.isStatusTextSensitive == rhs.isStatusTextSensitive
lhs.isStatusTextSensitive == rhs.isStatusTextSensitive
} }
func hash(into hasher: inout Hasher) { func hash(into hasher: inout Hasher) {
hasher.combine(separatorLineStyle)
hasher.combine(isStatusTextSensitive) hasher.combine(isStatusTextSensitive)
} }
enum SeparatorLineStyle {
case indent // alignment to name label
case expand // alignment to table view two edges
case normal // alignment to readable guideline
}
} }
} }

View File

@ -20,10 +20,6 @@ extension UIView {
return 1.0 / view.traitCollection.displayScale return 1.0 / view.traitCollection.displayScale
} }
static var floatyButtonBottomMargin: CGFloat {
return 16
}
} }
// MARK: - Convinience view appearance modification method // MARK: - Convinience view appearance modification method

View File

@ -85,7 +85,7 @@ extension StatusProviderFacade {
os_log("%{public}s[%{public}ld], %{public}s: [Like] update local toot like status to: %s", ((#file as NSString).lastPathComponent), #line, #function, favoriteKind == .create ? "like" : "unlike") os_log("%{public}s[%{public}ld], %{public}s: [Like] update local toot like status to: %s", ((#file as NSString).lastPathComponent), #line, #function, favoriteKind == .create ? "like" : "unlike")
} receiveCompletion: { completion in } receiveCompletion: { completion in
switch completion { switch completion {
case .failure(let error): case .failure:
// TODO: handle error // TODO: handle error
break break
case .finished: case .finished:

View File

@ -90,16 +90,12 @@ extension HomeTimelineViewModel: NSFetchedResultsControllerDelegate {
let isLast = i == timelineIndexes.count - 1 let isLast = i == timelineIndexes.count - 1
switch (isLast, timelineIndex.hasMore) { switch (isLast, timelineIndex.hasMore) {
case (true, false):
attribute.separatorLineStyle = .normal
case (false, true): case (false, true):
attribute.separatorLineStyle = .expand
newTimelineItems.append(.homeMiddleLoader(upperTimelineIndexAnchorObjectID: timelineIndex.objectID)) newTimelineItems.append(.homeMiddleLoader(upperTimelineIndexAnchorObjectID: timelineIndex.objectID))
case (true, true): case (true, true):
attribute.separatorLineStyle = .normal
shouldAddBottomLoader = true shouldAddBottomLoader = true
case (false, false): default:
attribute.separatorLineStyle = .indent break
} }
} // end for } // end for

View File

@ -18,6 +18,7 @@ protocol StatusTableViewCellDelegate: class {
final class StatusTableViewCell: UITableViewCell { final class StatusTableViewCell: UITableViewCell {
static let bottomPaddingHeight: CGFloat = 10
weak var delegate: StatusTableViewCellDelegate? weak var delegate: StatusTableViewCellDelegate?
@ -28,6 +29,7 @@ final class StatusTableViewCell: UITableViewCell {
override func prepareForReuse() { override func prepareForReuse() {
super.prepareForReuse() super.prepareForReuse()
statusView.isStatusTextSensitive = false
statusView.cleanUpContentWarning() statusView.cleanUpContentWarning()
disposeBag.removeAll() disposeBag.removeAll()
observations.removeAll() observations.removeAll()
@ -43,6 +45,13 @@ final class StatusTableViewCell: UITableViewCell {
_init() _init()
} }
override func layoutSubviews() {
super.layoutSubviews()
DispatchQueue.main.async {
self.statusView.drawContentWarningImageView()
}
}
} }
extension StatusTableViewCell { extension StatusTableViewCell {
@ -68,7 +77,7 @@ extension StatusTableViewCell {
bottomPaddingView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), bottomPaddingView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
bottomPaddingView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), bottomPaddingView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
bottomPaddingView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), bottomPaddingView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
bottomPaddingView.heightAnchor.constraint(equalToConstant: 10).priority(.defaultHigh), bottomPaddingView.heightAnchor.constraint(equalToConstant: StatusTableViewCell.bottomPaddingHeight).priority(.defaultHigh),
]) ])
statusView.delegate = self statusView.delegate = self

View File

@ -10,7 +10,9 @@ import Combine
class TimelineLoaderTableViewCell: UITableViewCell { class TimelineLoaderTableViewCell: UITableViewCell {
static let cellHeight: CGFloat = 48 static let cellHeight: CGFloat = 44 + TimelineLoaderTableViewCell.extraTopPadding + TimelineLoaderTableViewCell.bottomPadding
static let extraTopPadding: CGFloat = 3 // the status cell already has 10pt bottom padding
static let bottomPadding: CGFloat = StatusTableViewCell.bottomPaddingHeight + TimelineLoaderTableViewCell.extraTopPadding // make balance
var disposeBag = Set<AnyCancellable>() var disposeBag = Set<AnyCancellable>()
@ -50,18 +52,18 @@ class TimelineLoaderTableViewCell: UITableViewCell {
loadMoreButton.translatesAutoresizingMaskIntoConstraints = false loadMoreButton.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(loadMoreButton) contentView.addSubview(loadMoreButton)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
loadMoreButton.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8), loadMoreButton.topAnchor.constraint(equalTo: contentView.topAnchor, constant: TimelineLoaderTableViewCell.extraTopPadding),
loadMoreButton.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor), loadMoreButton.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor),
contentView.readableContentGuide.trailingAnchor.constraint(equalTo: loadMoreButton.trailingAnchor), contentView.readableContentGuide.trailingAnchor.constraint(equalTo: loadMoreButton.trailingAnchor),
contentView.bottomAnchor.constraint(equalTo: loadMoreButton.bottomAnchor, constant: 8), contentView.bottomAnchor.constraint(equalTo: loadMoreButton.bottomAnchor, constant: TimelineLoaderTableViewCell.bottomPadding),
loadMoreButton.heightAnchor.constraint(equalToConstant: TimelineLoaderTableViewCell.cellHeight - 2 * 8).priority(.defaultHigh), loadMoreButton.heightAnchor.constraint(equalToConstant: 44).priority(.defaultHigh),
]) ])
activityIndicatorView.translatesAutoresizingMaskIntoConstraints = false activityIndicatorView.translatesAutoresizingMaskIntoConstraints = false
addSubview(activityIndicatorView) addSubview(activityIndicatorView)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
activityIndicatorView.centerXAnchor.constraint(equalTo: centerXAnchor), activityIndicatorView.centerXAnchor.constraint(equalTo: loadMoreButton.centerXAnchor),
activityIndicatorView.centerYAnchor.constraint(equalTo: centerYAnchor), activityIndicatorView.centerYAnchor.constraint(equalTo: loadMoreButton.centerYAnchor),
]) ])
loadMoreButton.isHidden = true loadMoreButton.isHidden = true

View File

@ -23,16 +23,6 @@ final class TimelineMiddleLoaderTableViewCell: TimelineLoaderTableViewCell {
backgroundColor = .clear backgroundColor = .clear
let separatorLine = UIView.separatorLine
separatorLine.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(separatorLine)
NSLayoutConstraint.activate([
separatorLine.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
contentView.trailingAnchor.constraint(equalTo: separatorLine.trailingAnchor),
contentView.bottomAnchor.constraint(equalTo: separatorLine.bottomAnchor),
separatorLine.heightAnchor.constraint(equalToConstant: UIView.separatorLineHeight(of: separatorLine))
])
loadMoreButton.isHidden = false loadMoreButton.isHidden = false
loadMoreButton.setImage(Asset.Arrows.arrowTriangle2Circlepath.image.withRenderingMode(.alwaysTemplate), for: .normal) loadMoreButton.setImage(Asset.Arrows.arrowTriangle2Circlepath.image.withRenderingMode(.alwaysTemplate), for: .normal)
loadMoreButton.setInsets(forContentPadding: .zero, imageTitlePadding: 4) loadMoreButton.setInsets(forContentPadding: .zero, imageTitlePadding: 4)

View File

@ -139,7 +139,7 @@ extension APIService {
return APIService.Persist.persistTimeline( return APIService.Persist.persistTimeline(
managedObjectContext: self.backgroundManagedObjectContext, managedObjectContext: self.backgroundManagedObjectContext,
domain: mastodonAuthenticationBox.domain, domain: mastodonAuthenticationBox.domain,
query: query as! TimelineQueryType, query: query,
response: response, response: response,
persistType: .likeList, persistType: .likeList,
requestMastodonUserID: requestMastodonUserID, requestMastodonUserID: requestMastodonUserID,