-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comment Composer: Reply Preview & Drafts (#24075)
* Show the comment you are replying to in the comment composer * Add support for saving drafts * Remove unused NotificationReplyStore
- Loading branch information
Showing
9 changed files
with
142 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...s/Classes/ViewRelated/Comments/Controllers/Composer/CommentComposerReplyCommentView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import UIKit | ||
import WordPressUI | ||
|
||
final class CommentComposerReplyCommentView: UIView, UITableViewDataSource { | ||
private let tableView = UITableView(frame: .zero, style: .plain) | ||
private let comment: Comment | ||
private let helper = ReaderCommentsHelper() | ||
private lazy var heightConstraints = tableView.heightAnchor.constraint(equalToConstant: 120) | ||
|
||
init(comment: Comment) { | ||
self.comment = comment | ||
|
||
super.init(frame: .zero) | ||
|
||
addSubview(tableView) | ||
tableView.pinEdges() | ||
|
||
tableView.separatorStyle = .none | ||
tableView.alwaysBounceVertical = false | ||
tableView.register(CommentContentTableViewCell.defaultNib, forCellReuseIdentifier: CommentContentTableViewCell.defaultReuseID) | ||
|
||
tableView.dataSource = self | ||
heightConstraints.isActive = true | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
1 | ||
} | ||
|
||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = tableView.dequeueReusableCell(withIdentifier: CommentContentTableViewCell.defaultReuseID) as! CommentContentTableViewCell | ||
cell.configure(viewModel: .init(comment: comment), helper: helper) { [weak self, weak cell] _ in | ||
guard let self, let cell else { return } | ||
self.didUpdateHeight(cell) | ||
} | ||
cell.hideActions() | ||
return cell | ||
} | ||
|
||
private func didUpdateHeight(_ cell: CommentContentTableViewCell) { | ||
UIView.performWithoutAnimation { | ||
tableView.performBatchUpdates({}) | ||
heightConstraints.constant = min(130, cell.systemLayoutSizeFitting(bounds.size) | ||
.height + 8) // bottom padding | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.