handle seed view reminder and search bar
This commit is contained in:
parent
715c9eff98
commit
037d70b185
|
@ -6,7 +6,6 @@
|
|||
final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConversationButtonSetDelegate, SeedReminderViewDelegate {
|
||||
private var threads: YapDatabaseViewMappings!
|
||||
private var threadViewModelCache: [String:ThreadViewModel] = [:] // Thread ID to ThreadViewModel
|
||||
private var tableViewTopConstraint: NSLayoutConstraint!
|
||||
|
||||
private var threadCount: UInt {
|
||||
threads.numberOfItems(inGroup: TSInboxGroup)
|
||||
|
@ -102,24 +101,12 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
|||
}
|
||||
updateNavBarButtons()
|
||||
setUpNavBarSessionHeading()
|
||||
// Recovery phrase reminder
|
||||
let hasViewedSeed = UserDefaults.standard[.hasViewedSeed]
|
||||
if !hasViewedSeed {
|
||||
view.addSubview(seedReminderView)
|
||||
seedReminderView.pin(.leading, to: .leading, of: view)
|
||||
seedReminderView.pin(.top, to: .top, of: view)
|
||||
seedReminderView.pin(.trailing, to: .trailing, of: view)
|
||||
}
|
||||
// Table view
|
||||
tableView.dataSource = self
|
||||
tableView.delegate = self
|
||||
view.addSubview(tableView)
|
||||
tableView.pin(.leading, to: .leading, of: view)
|
||||
if !hasViewedSeed {
|
||||
tableViewTopConstraint = tableView.pin(.top, to: .bottom, of: seedReminderView)
|
||||
} else {
|
||||
tableViewTopConstraint = tableView.pin(.top, to: .top, of: view, withInset: Values.smallSpacing)
|
||||
}
|
||||
tableView.pin(.top, to: .top, of: view, withInset: Values.verySmallSpacing)
|
||||
tableView.pin(.trailing, to: .trailing, of: view)
|
||||
tableView.pin(.bottom, to: .bottom, of: view)
|
||||
view.addSubview(fadeView)
|
||||
|
@ -178,11 +165,14 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
|||
searchBarContainer.addSubview(searchBar)
|
||||
searchBar.autoPinEdgesToSuperviewMargins()
|
||||
tableView.tableHeaderView = searchBarContainer
|
||||
if #available(iOS 15.0, *) {
|
||||
tableView.sectionHeaderTopPadding = 0
|
||||
}
|
||||
|
||||
addChild(searchResultsController)
|
||||
view.addSubview(searchResultsController.view)
|
||||
searchResultsController.view.autoPinEdgesToSuperviewEdges(with: .zero, excludingEdge: .top)
|
||||
searchResultsController.view.autoPinEdge(toSuperviewEdge: .top, withInset: 64)
|
||||
searchResultsController.view.autoPinEdge(toSuperviewEdge: .top, withInset: 60)
|
||||
searchResultsController.view.isHidden = true
|
||||
}
|
||||
|
||||
|
@ -221,6 +211,22 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
|||
cell.threadViewModel = threadViewModel(at: indexPath.row)
|
||||
return cell
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
||||
let hasViewedSeed = UserDefaults.standard[.hasViewedSeed]
|
||||
if !hasViewedSeed {
|
||||
return seedReminderView
|
||||
}
|
||||
return UIView()
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
||||
let hasViewedSeed = UserDefaults.standard[.hasViewedSeed]
|
||||
if !hasViewedSeed {
|
||||
return UITableView.automaticDimension
|
||||
}
|
||||
return .leastNonzeroMagnitude
|
||||
}
|
||||
|
||||
// MARK: Updating
|
||||
private func reload() {
|
||||
|
@ -299,9 +305,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
|||
}
|
||||
|
||||
@objc private func handleSeedViewedNotification(_ notification: Notification) {
|
||||
tableViewTopConstraint.isActive = false
|
||||
tableViewTopConstraint = tableView.pin(.top, to: .top, of: view, withInset: Values.smallSpacing)
|
||||
seedReminderView.removeFromSuperview()
|
||||
self.tableView.reloadSections(IndexSet(integer: 0), with: .none) // TODO: Just reload header
|
||||
}
|
||||
|
||||
@objc private func handleBlockedContactsUpdatedNotification(_ notification: Notification) {
|
||||
|
|
Loading…
Reference in New Issue