2020-09-27 05:54:06 +00:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import Combine
|
|
|
|
import UIKit
|
|
|
|
import ViewModels
|
|
|
|
|
|
|
|
final class ProfileViewController: TableViewController {
|
|
|
|
private let viewModel: ProfileViewModel
|
|
|
|
private var cancellables = Set<AnyCancellable>()
|
|
|
|
|
2020-10-07 00:31:29 +00:00
|
|
|
required init(viewModel: ProfileViewModel, identification: Identification) {
|
2020-09-27 05:54:06 +00:00
|
|
|
self.viewModel = viewModel
|
|
|
|
|
2020-10-07 00:31:29 +00:00
|
|
|
super.init(viewModel: viewModel, identification: identification)
|
2020-09-27 05:54:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
|
|
// Initial size is to avoid unsatisfiable constraint warning
|
|
|
|
let accountHeaderView = AccountHeaderView(frame: .init(origin: .zero, size: .init(width: 100, height: 100)))
|
|
|
|
|
|
|
|
accountHeaderView.viewModel = viewModel
|
|
|
|
|
|
|
|
viewModel.$accountViewModel
|
|
|
|
.receive(on: DispatchQueue.main)
|
|
|
|
.sink { [weak self] _ in
|
|
|
|
accountHeaderView.viewModel = self?.viewModel
|
|
|
|
self?.sizeTableHeaderFooterViews()
|
|
|
|
}
|
|
|
|
.store(in: &cancellables)
|
|
|
|
|
|
|
|
tableView.tableHeaderView = accountHeaderView
|
|
|
|
}
|
|
|
|
}
|