forked from zelo72/mastodon-ios
chore: update UI appearance. remove not used separator line component
This commit is contained in:
parent
6182390699
commit
2988e71611
|
@ -30,32 +30,22 @@ protocol StatusContentWarningAttribute {
|
|||
|
||||
extension Item {
|
||||
class StatusTimelineAttribute: Hashable, StatusContentWarningAttribute {
|
||||
var separatorLineStyle: SeparatorLineStyle = .indent
|
||||
var isStatusTextSensitive: Bool = false
|
||||
|
||||
public init(
|
||||
separatorLineStyle: Item.StatusTimelineAttribute.SeparatorLineStyle = .indent,
|
||||
isStatusTextSensitive: Bool
|
||||
) {
|
||||
self.separatorLineStyle = separatorLineStyle
|
||||
self.isStatusTextSensitive = isStatusTextSensitive
|
||||
}
|
||||
|
||||
static func == (lhs: Item.StatusTimelineAttribute, rhs: Item.StatusTimelineAttribute) -> Bool {
|
||||
return lhs.separatorLineStyle == rhs.separatorLineStyle &&
|
||||
lhs.isStatusTextSensitive == rhs.isStatusTextSensitive
|
||||
return lhs.isStatusTextSensitive == rhs.isStatusTextSensitive
|
||||
}
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(separatorLineStyle)
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,6 @@ extension UIView {
|
|||
return 1.0 / view.traitCollection.displayScale
|
||||
}
|
||||
|
||||
static var floatyButtonBottomMargin: CGFloat {
|
||||
return 16
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Convinience view appearance modification method
|
||||
|
|
|
@ -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")
|
||||
} receiveCompletion: { completion in
|
||||
switch completion {
|
||||
case .failure(let error):
|
||||
case .failure:
|
||||
// TODO: handle error
|
||||
break
|
||||
case .finished:
|
||||
|
|
|
@ -90,16 +90,12 @@ extension HomeTimelineViewModel: NSFetchedResultsControllerDelegate {
|
|||
|
||||
let isLast = i == timelineIndexes.count - 1
|
||||
switch (isLast, timelineIndex.hasMore) {
|
||||
case (true, false):
|
||||
attribute.separatorLineStyle = .normal
|
||||
case (false, true):
|
||||
attribute.separatorLineStyle = .expand
|
||||
newTimelineItems.append(.homeMiddleLoader(upperTimelineIndexAnchorObjectID: timelineIndex.objectID))
|
||||
case (true, true):
|
||||
attribute.separatorLineStyle = .normal
|
||||
shouldAddBottomLoader = true
|
||||
case (false, false):
|
||||
attribute.separatorLineStyle = .indent
|
||||
default:
|
||||
break
|
||||
}
|
||||
} // end for
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ protocol StatusTableViewCellDelegate: class {
|
|||
|
||||
final class StatusTableViewCell: UITableViewCell {
|
||||
|
||||
static let bottomPaddingHeight: CGFloat = 10
|
||||
|
||||
weak var delegate: StatusTableViewCellDelegate?
|
||||
|
||||
|
@ -28,6 +29,7 @@ final class StatusTableViewCell: UITableViewCell {
|
|||
|
||||
override func prepareForReuse() {
|
||||
super.prepareForReuse()
|
||||
statusView.isStatusTextSensitive = false
|
||||
statusView.cleanUpContentWarning()
|
||||
disposeBag.removeAll()
|
||||
observations.removeAll()
|
||||
|
@ -43,6 +45,13 @@ final class StatusTableViewCell: UITableViewCell {
|
|||
_init()
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
DispatchQueue.main.async {
|
||||
self.statusView.drawContentWarningImageView()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension StatusTableViewCell {
|
||||
|
@ -68,7 +77,7 @@ extension StatusTableViewCell {
|
|||
bottomPaddingView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
|
||||
bottomPaddingView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
|
||||
bottomPaddingView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
|
||||
bottomPaddingView.heightAnchor.constraint(equalToConstant: 10).priority(.defaultHigh),
|
||||
bottomPaddingView.heightAnchor.constraint(equalToConstant: StatusTableViewCell.bottomPaddingHeight).priority(.defaultHigh),
|
||||
])
|
||||
|
||||
statusView.delegate = self
|
||||
|
|
|
@ -10,7 +10,9 @@ import Combine
|
|||
|
||||
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>()
|
||||
|
||||
|
@ -50,18 +52,18 @@ class TimelineLoaderTableViewCell: UITableViewCell {
|
|||
loadMoreButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(loadMoreButton)
|
||||
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),
|
||||
contentView.readableContentGuide.trailingAnchor.constraint(equalTo: loadMoreButton.trailingAnchor),
|
||||
contentView.bottomAnchor.constraint(equalTo: loadMoreButton.bottomAnchor, constant: 8),
|
||||
loadMoreButton.heightAnchor.constraint(equalToConstant: TimelineLoaderTableViewCell.cellHeight - 2 * 8).priority(.defaultHigh),
|
||||
contentView.bottomAnchor.constraint(equalTo: loadMoreButton.bottomAnchor, constant: TimelineLoaderTableViewCell.bottomPadding),
|
||||
loadMoreButton.heightAnchor.constraint(equalToConstant: 44).priority(.defaultHigh),
|
||||
])
|
||||
|
||||
activityIndicatorView.translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(activityIndicatorView)
|
||||
NSLayoutConstraint.activate([
|
||||
activityIndicatorView.centerXAnchor.constraint(equalTo: centerXAnchor),
|
||||
activityIndicatorView.centerYAnchor.constraint(equalTo: centerYAnchor),
|
||||
activityIndicatorView.centerXAnchor.constraint(equalTo: loadMoreButton.centerXAnchor),
|
||||
activityIndicatorView.centerYAnchor.constraint(equalTo: loadMoreButton.centerYAnchor),
|
||||
])
|
||||
|
||||
loadMoreButton.isHidden = true
|
||||
|
|
|
@ -23,16 +23,6 @@ final class TimelineMiddleLoaderTableViewCell: TimelineLoaderTableViewCell {
|
|||
|
||||
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.setImage(Asset.Arrows.arrowTriangle2Circlepath.image.withRenderingMode(.alwaysTemplate), for: .normal)
|
||||
loadMoreButton.setInsets(forContentPadding: .zero, imageTitlePadding: 4)
|
||||
|
|
|
@ -139,7 +139,7 @@ extension APIService {
|
|||
return APIService.Persist.persistTimeline(
|
||||
managedObjectContext: self.backgroundManagedObjectContext,
|
||||
domain: mastodonAuthenticationBox.domain,
|
||||
query: query as! TimelineQueryType,
|
||||
query: query,
|
||||
response: response,
|
||||
persistType: .likeList,
|
||||
requestMastodonUserID: requestMastodonUserID,
|
||||
|
|
Loading…
Reference in New Issue