chore: update notification timeline margin

This commit is contained in:
CMK 2022-02-18 18:25:26 +08:00
parent 5be6211986
commit 78fc34c08d
4 changed files with 15 additions and 13 deletions

View File

@ -36,7 +36,7 @@ extension NotificationTableViewCell {
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): did layout for new cell")
notificationView.statusView.frame.size.width = tableView.frame.width - containerViewHorizontalMargin
notificationView.quoteStatusView.frame.size.width = tableView.frame.width - 2 * StatusView.containerLayoutMargin - containerViewHorizontalMargin
notificationView.quoteStatusView.frame.size.width = tableView.frame.width - containerViewHorizontalMargin // the as same width as statusView
}
switch viewModel.value {

View File

@ -21,25 +21,31 @@ public final class AdaptiveMarginContainerView: UIView {
contentView.translatesAutoresizingMaskIntoConstraints = false
addSubview(contentView)
let _topLayoutConstraint = contentView.topAnchor.constraint(equalTo: topAnchor)
let _leadingLayoutConstraint = contentView.leadingAnchor.constraint(equalTo: leadingAnchor)
let _trailingLayoutConstraint = trailingAnchor.constraint(equalTo: contentView.trailingAnchor)
let _bottomLayoutConstraint = bottomAnchor.constraint(equalTo: contentView.bottomAnchor)
NSLayoutConstraint.activate([
contentView.topAnchor.constraint(equalTo: topAnchor),
_topLayoutConstraint,
_leadingLayoutConstraint,
_trailingLayoutConstraint,
contentView.bottomAnchor.constraint(equalTo: bottomAnchor),
_bottomLayoutConstraint
])
topLayoutConstraint = _topLayoutConstraint
leadingLayoutConstraint = _leadingLayoutConstraint
trailingLayoutConstraint = _trailingLayoutConstraint
bottomLayoutConstraint = _bottomLayoutConstraint
updateConstraints()
}
}
var leadingLayoutConstraint: NSLayoutConstraint?
var trailingLayoutConstraint: NSLayoutConstraint?
private(set) var topLayoutConstraint: NSLayoutConstraint?
private(set) var leadingLayoutConstraint: NSLayoutConstraint?
private(set) var trailingLayoutConstraint: NSLayoutConstraint?
private(set) var bottomLayoutConstraint: NSLayoutConstraint?
}

View File

@ -226,15 +226,9 @@ extension NotificationView {
// quoteStatusView
containerStackView.addArrangedSubview(quoteStatusViewContainerView)
quoteStatusViewContainerView.layoutMargins = UIEdgeInsets(
top: 0,
left: StatusView.containerLayoutMargin,
bottom: 16,
right: StatusView.containerLayoutMargin
)
quoteStatusViewContainerView.layoutMargins.bottom = 16
quoteBackgroundView.layoutMargins = UIEdgeInsets(top: 16, left: 0, bottom: 0, right: 0)
quoteBackgroundView.translatesAutoresizingMaskIntoConstraints = false
quoteStatusViewContainerView.addSubview(quoteBackgroundView)
NSLayoutConstraint.activate([
@ -301,6 +295,7 @@ extension NotificationView {
extension NotificationView: AdaptiveContainerView {
public func updateContainerViewComponentsLayoutMarginsRelativeArrangementBehavior(isEnabled: Bool) {
statusView.updateContainerViewComponentsLayoutMarginsRelativeArrangementBehavior(isEnabled: isEnabled)
quoteStatusView.updateContainerViewComponentsLayoutMarginsRelativeArrangementBehavior(isEnabled: true) // always set margins
}
}

View File

@ -611,7 +611,8 @@ extension StatusView.Style {
func notificationQuote(statusView: StatusView) {
base(statusView: statusView) // override the base style
statusView.contentContainer.layoutMargins.bottom = 16 // fix contentText align to edge issue
statusView.contentAdaptiveMarginContainerView.bottomLayoutConstraint?.constant = 16 // fix bottom margin missing issue
statusView.pollAdaptiveMarginContainerView.bottomLayoutConstraint?.constant = 16 // fix bottom margin missing issue
statusView.contentSensitiveeToggleButton.removeFromSuperview()
statusView.menuButton.removeFromSuperview()
statusView.actionToolbarAdaptiveMarginContainerView.removeFromSuperview()