chore: fix order of notification and layout issue
This commit is contained in:
parent
288a8025ce
commit
2d71a48e36
|
@ -95,6 +95,6 @@ extension MastodonNotification {
|
||||||
|
|
||||||
extension MastodonNotification: Managed {
|
extension MastodonNotification: Managed {
|
||||||
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
||||||
return [NSSortDescriptor(keyPath: \MastodonNotification.updatedAt, ascending: false)]
|
return [NSSortDescriptor(keyPath: \MastodonNotification.createAt, ascending: false)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,9 +70,10 @@ extension NotificationSection {
|
||||||
if let status = notification.status {
|
if let status = notification.status {
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: NotificationStatusTableViewCell.self), for: indexPath) as! NotificationStatusTableViewCell
|
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: NotificationStatusTableViewCell.self), for: indexPath) as! NotificationStatusTableViewCell
|
||||||
cell.delegate = delegate
|
cell.delegate = delegate
|
||||||
|
let frame = CGRect(x: 0, y: 0, width: tableView.readableContentGuide.layoutFrame.width - NotificationStatusTableViewCell.statusPadding.left - NotificationStatusTableViewCell.statusPadding.right, height: tableView.readableContentGuide.layoutFrame.height)
|
||||||
NotificationSection.configure(cell: cell,
|
NotificationSection.configure(cell: cell,
|
||||||
dependency: dependency,
|
dependency: dependency,
|
||||||
readableLayoutFrame: nil,
|
readableLayoutFrame: frame,
|
||||||
timestampUpdatePublisher: timestampUpdatePublisher,
|
timestampUpdatePublisher: timestampUpdatePublisher,
|
||||||
status: status,
|
status: status,
|
||||||
requestUserID: requestUserID,
|
requestUserID: requestUserID,
|
||||||
|
|
|
@ -35,6 +35,7 @@ final class NotificationViewController: UIViewController, NeedsDependency {
|
||||||
tableView.register(NotificationStatusTableViewCell.self, forCellReuseIdentifier: String(describing: NotificationStatusTableViewCell.self))
|
tableView.register(NotificationStatusTableViewCell.self, forCellReuseIdentifier: String(describing: NotificationStatusTableViewCell.self))
|
||||||
tableView.register(SearchBottomLoader.self, forCellReuseIdentifier: String(describing: SearchBottomLoader.self))
|
tableView.register(SearchBottomLoader.self, forCellReuseIdentifier: String(describing: SearchBottomLoader.self))
|
||||||
tableView.tableFooterView = UIView()
|
tableView.tableFooterView = UIView()
|
||||||
|
tableView.rowHeight = UITableView.automaticDimension
|
||||||
return tableView
|
return tableView
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -135,9 +136,7 @@ extension NotificationViewController {
|
||||||
// MARK: - UITableViewDelegate
|
// MARK: - UITableViewDelegate
|
||||||
extension NotificationViewController: UITableViewDelegate {
|
extension NotificationViewController: UITableViewDelegate {
|
||||||
|
|
||||||
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
||||||
return 68
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - ContentOffsetAdjustableTimelineViewControllerDelegate
|
// MARK: - ContentOffsetAdjustableTimelineViewControllerDelegate
|
||||||
|
|
|
@ -12,6 +12,7 @@ import UIKit
|
||||||
final class NotificationStatusTableViewCell: UITableViewCell {
|
final class NotificationStatusTableViewCell: UITableViewCell {
|
||||||
static let actionImageBorderWidth: CGFloat = 2
|
static let actionImageBorderWidth: CGFloat = 2
|
||||||
|
|
||||||
|
static let statusPadding: UIEdgeInsets = UIEdgeInsets(top: 50, left: 73, bottom: 24, right: 24)
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
|
|
||||||
var delegate: NotificationTableViewCellDelegate?
|
var delegate: NotificationTableViewCellDelegate?
|
||||||
|
@ -136,7 +137,7 @@ extension NotificationStatusTableViewCell {
|
||||||
statusContainer.pin(top: 40, left: 63, bottom: 14, right: 14)
|
statusContainer.pin(top: 40, left: 63, bottom: 14, right: 14)
|
||||||
|
|
||||||
contentView.addSubview(statusView)
|
contentView.addSubview(statusView)
|
||||||
statusView.pin(top: 40 + 12, left: 63 + 12, bottom: 14 + 12, right: 14 + 12)
|
statusView.pin(top: NotificationStatusTableViewCell.statusPadding.top, left: NotificationStatusTableViewCell.statusPadding.left, bottom: NotificationStatusTableViewCell.statusPadding.bottom, right: NotificationStatusTableViewCell.statusPadding.right)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||||
|
|
|
@ -43,5 +43,8 @@ final class SearchBottomLoader: UITableViewCell {
|
||||||
backgroundColor = Asset.Colors.Background.systemGroupedBackground.color
|
backgroundColor = Asset.Colors.Background.systemGroupedBackground.color
|
||||||
contentView.addSubview(activityIndicatorView)
|
contentView.addSubview(activityIndicatorView)
|
||||||
activityIndicatorView.constrainToCenter()
|
activityIndicatorView.constrainToCenter()
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
contentView.heightAnchor.constraint(equalToConstant: 44)
|
||||||
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ extension APIService {
|
||||||
status = statusInCoreData
|
status = statusInCoreData
|
||||||
}
|
}
|
||||||
// use constrain to avoid repeated save
|
// use constrain to avoid repeated save
|
||||||
let notification = MastodonNotification.insert(into: self.backgroundManagedObjectContext, domain: domain, property: MastodonNotification.Property(id: notification.id, type: notification.type.rawValue, account: mastodonUser, status: status, createdAt: Date()))
|
let notification = MastodonNotification.insert(into: self.backgroundManagedObjectContext, domain: domain, property: MastodonNotification.Property(id: notification.id, type: notification.type.rawValue, account: mastodonUser, status: status, createdAt: notification.createdAt))
|
||||||
os_log(.info, log: log, "%{public}s[%{public}ld], %{public}s: fetch mastodon user [%s](%s)", (#file as NSString).lastPathComponent, #line, #function, notification.type, notification.account.username)
|
os_log(.info, log: log, "%{public}s[%{public}ld], %{public}s: fetch mastodon user [%s](%s)", (#file as NSString).lastPathComponent, #line, #function, notification.type, notification.account.username)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue