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") 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.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 { switch viewModel.value {

View File

@ -21,25 +21,31 @@ public final class AdaptiveMarginContainerView: UIView {
contentView.translatesAutoresizingMaskIntoConstraints = false contentView.translatesAutoresizingMaskIntoConstraints = false
addSubview(contentView) addSubview(contentView)
let _topLayoutConstraint = contentView.topAnchor.constraint(equalTo: topAnchor)
let _leadingLayoutConstraint = contentView.leadingAnchor.constraint(equalTo: leadingAnchor) let _leadingLayoutConstraint = contentView.leadingAnchor.constraint(equalTo: leadingAnchor)
let _trailingLayoutConstraint = trailingAnchor.constraint(equalTo: contentView.trailingAnchor) let _trailingLayoutConstraint = trailingAnchor.constraint(equalTo: contentView.trailingAnchor)
let _bottomLayoutConstraint = bottomAnchor.constraint(equalTo: contentView.bottomAnchor)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
contentView.topAnchor.constraint(equalTo: topAnchor), _topLayoutConstraint,
_leadingLayoutConstraint, _leadingLayoutConstraint,
_trailingLayoutConstraint, _trailingLayoutConstraint,
contentView.bottomAnchor.constraint(equalTo: bottomAnchor), _bottomLayoutConstraint
]) ])
topLayoutConstraint = _topLayoutConstraint
leadingLayoutConstraint = _leadingLayoutConstraint leadingLayoutConstraint = _leadingLayoutConstraint
trailingLayoutConstraint = _trailingLayoutConstraint trailingLayoutConstraint = _trailingLayoutConstraint
bottomLayoutConstraint = _bottomLayoutConstraint
updateConstraints() updateConstraints()
} }
} }
var leadingLayoutConstraint: NSLayoutConstraint? private(set) var topLayoutConstraint: NSLayoutConstraint?
var trailingLayoutConstraint: 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 // quoteStatusView
containerStackView.addArrangedSubview(quoteStatusViewContainerView) containerStackView.addArrangedSubview(quoteStatusViewContainerView)
quoteStatusViewContainerView.layoutMargins = UIEdgeInsets( quoteStatusViewContainerView.layoutMargins.bottom = 16
top: 0,
left: StatusView.containerLayoutMargin,
bottom: 16,
right: StatusView.containerLayoutMargin
)
quoteBackgroundView.layoutMargins = UIEdgeInsets(top: 16, left: 0, bottom: 0, right: 0) quoteBackgroundView.layoutMargins = UIEdgeInsets(top: 16, left: 0, bottom: 0, right: 0)
quoteBackgroundView.translatesAutoresizingMaskIntoConstraints = false quoteBackgroundView.translatesAutoresizingMaskIntoConstraints = false
quoteStatusViewContainerView.addSubview(quoteBackgroundView) quoteStatusViewContainerView.addSubview(quoteBackgroundView)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
@ -301,6 +295,7 @@ extension NotificationView {
extension NotificationView: AdaptiveContainerView { extension NotificationView: AdaptiveContainerView {
public func updateContainerViewComponentsLayoutMarginsRelativeArrangementBehavior(isEnabled: Bool) { public func updateContainerViewComponentsLayoutMarginsRelativeArrangementBehavior(isEnabled: Bool) {
statusView.updateContainerViewComponentsLayoutMarginsRelativeArrangementBehavior(isEnabled: isEnabled) statusView.updateContainerViewComponentsLayoutMarginsRelativeArrangementBehavior(isEnabled: isEnabled)
quoteStatusView.updateContainerViewComponentsLayoutMarginsRelativeArrangementBehavior(isEnabled: true) // always set margins
} }
} }

View File

@ -611,7 +611,8 @@ extension StatusView.Style {
func notificationQuote(statusView: StatusView) { func notificationQuote(statusView: StatusView) {
base(statusView: statusView) // override the base style 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.contentSensitiveeToggleButton.removeFromSuperview()
statusView.menuButton.removeFromSuperview() statusView.menuButton.removeFromSuperview()
statusView.actionToolbarAdaptiveMarginContainerView.removeFromSuperview() statusView.actionToolbarAdaptiveMarginContainerView.removeFromSuperview()