Commit 1159282f by Demid Merzlyakov

Hide Premium button, when the app is purchased.

parent 365c3cda
......@@ -15,9 +15,6 @@ class MenuHeaderView: UIView {
private let buyButton = MenuBuyButton()
private let premiumImageView = UIImageView()
private let tvButton = MenuHeaderButton(image: UIImage(named: "menu_tv"), text: "menu.tv".localized())
private let radarButton = MenuHeaderButton(image: UIImage(named: "menu_radar"), text: "menu.radar".localized())
public var onTapBuy: (() -> ())?
init() {
......@@ -25,7 +22,6 @@ class MenuHeaderView: UIView {
prepareView()
preparePremium()
prepareButtons()
updateUI()
}
......@@ -101,6 +97,8 @@ private extension MenuHeaderView {
premiumContainer.snp.makeConstraints { (make) in
make.top.equalTo(30)
make.left.right.equalToSuperview().inset(18).priority(999)
make.height.equalTo(180)
make.bottom.equalToSuperview().inset(30)
}
premiumImageView.snp.makeConstraints { (make) in
......@@ -124,27 +122,4 @@ private extension MenuHeaderView {
make.bottom.equalToSuperview().inset(24)
}
}
func prepareButtons() {
tvButton.addTarget(self, action: #selector(handleButton(button:)), for: .touchUpInside)
addSubview(tvButton)
radarButton.addTarget(self, action: #selector(handleButton(button:)), for: .touchUpInside)
addSubview(radarButton)
//Constraints
tvButton.snp.makeConstraints { (make) in
make.left.equalTo(premiumContainer)
make.top.equalTo(premiumContainer.snp.bottom).offset(30).priority(999)
make.width.equalTo(165)
make.bottom.equalToSuperview().inset(30)
}
radarButton.snp.makeConstraints { (make) in
make.right.equalTo(premiumContainer)
make.top.equalTo(premiumContainer.snp.bottom).offset(30).priority(999)
make.width.equalTo(165)
make.bottom.equalToSuperview().inset(30)
}
}
}
......@@ -13,7 +13,7 @@ class MenuViewController: UIViewController {
private let viewModel:MenuViewModel
private let menuHeaderView = MenuHeaderView()
private let menuCellFactory:MenuCellFactory<MenuRow>
private let tableView = UITableView()
private let tableView = UITableView(frame: .zero, style: .grouped)
init(coordinator:MenuCoordinator, menuViewModel: MenuViewModel) {
self.coordinator = coordinator
......@@ -65,8 +65,6 @@ private extension MenuViewController {
func prepareTableViewHeader() {
menuHeaderView.onTapBuy = { [weak self] in
#warning("Not implemented!")
//TODO: Implement!
self?.viewModel.updateToPro()
}
}
......@@ -83,6 +81,8 @@ private extension MenuViewController {
tableView.tableHeaderView = menuHeaderView
tableView.tableFooterView = MenuFooterView()
tableView.contentInset = .init(top: 0, left: 0, bottom: 30, right: 0)
tableView.sectionHeaderHeight = 30
tableView.sectionFooterHeight = 0
view.addSubview(tableView)
tableView.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
......@@ -103,25 +103,10 @@ extension MenuViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return menuCellFactory.cellFromTableView(tableView: tableView, indexPath: indexPath)
}
}
//MARK:- UITableView Delegate
extension MenuViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 0 {
return 0
}
return menuCellFactory.kSectionHeight
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView()
view.backgroundColor = ThemeManager.currentTheme.baseBackgroundColor
return view
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let type = menuCellFactory.cellTypeAt(indexPath: indexPath) else {
return
......@@ -135,7 +120,12 @@ extension MenuViewController: UITableViewDelegate {
extension MenuViewController: MenuViewModelDelegate {
func viewModelDidChange<P: ViewModelProtocol>(model:P) {
tableView.reloadData()
onMain {
if isAppPro() {
self.tableView.tableHeaderView = nil
}
self.tableView.reloadData()
}
}
func viewControllerForPresentation() -> UIViewController {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment