ios

ios


//

// StatusCustomController.swift

// yamagoo-ios-app

//

// Created by Artyom Popov on 31.10.17.

// Copyright © 2017 Artyom Popov. All rights reserved.

//


import UIKit


class StatusCustomController: UIViewController, UITableViewDelegate, UITableViewDataSource {


  //MARK: - link with view

  @IBOutlet var tableView: UITableView!

   

  @IBOutlet var imgStatus: UIImageView!

  @IBOutlet var lblStatus: UILabel!

  @IBOutlet var lblTyeOfService: UILabel!

  @IBOutlet var btnCash: UIButton!

   

  var headerView = UITableViewCell()

   

  //MARK: - utils

  let shape = Shape()

  let colorHex = ColorToHex()

   

  //MARK: - const

  let translusentCellHeight: CGFloat = 198

  //4

  let countCell = 13

   

  //MARK: - create

  override func viewDidLoad() {

    super.viewDidLoad()

     

    tableView.delegate = self

    tableView.dataSource = self

     

    tableView.estimatedRowHeight = 140

    tableView.rowHeight = UITableViewAutomaticDimension

     

    settingView()

    navigationControllerSetting()

  }

   

  //MARK: - start

  override func viewWillAppear(_ animated: Bool) {

    super.viewWillAppear(animated)

    navigationViewSetting(true)

  }

   

   func settingView() {

    shape.circle(imgStatus)

    btnCash.layer.cornerRadius = 9

  }

   

  func navigationControllerSetting() {

    navigationItem.title = "Имя Фамилия"

    navigationItem.backBarButtonItem = UIBarButtonItem(title: "Назад", style: .plain, target: self, action: nil)

  }

   

  //TODO: - допилить фичу(else)

  func navigationViewSetting(_ isStart: Bool) {

     

    if isStart {

      UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent

      navigationController?.navigationBar.tintColor = UIColor.white

      navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]

      self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)

      self.navigationController?.navigationBar.shadowImage = UIImage()

      self.navigationController?.navigationBar.isTranslucent = true

      self.navigationController?.view.backgroundColor = .clear

       

    } else {

//      UIApplication.shared.statusBarStyle = UIStatusBarStyle.default

//      navigationController?.navigationBar.tintColor = UIColor.black

//      navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.black]

//      self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)

//      self.navigationController?.navigationBar.shadowImage = nil

//      self.navigationController?.navigationBar.isTranslucent = false

//      self.navigationController?.view.backgroundColor = nil

    }

  }

}



extension StatusCustomController {

   

  public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

    return countCell

  }

   

  public func numberOfSections(in tableView: UITableView) -> Int {

    return 1

  }

   

  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    var cellId : String


    if indexPath.row == 0 {

      cellId = "CellTransparent"

      let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! CellTransparent

      tableView.rowHeight = translusentCellHeight

      return cell

       

    } else if indexPath.row == 1 {

      cellId = "CellHeader"

      headerView = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! CellHeader

       tableView.rowHeight = UITableViewAutomaticDimension

       

      return headerView

       

    } else if indexPath.row == 2 {

      cellId = "CellDetail"

      let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! CellDetail

      tableView.rowHeight = UITableViewAutomaticDimension

      return cell

    } else {

      cellId = "CellTableViwe"

      let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! CellTableViwe

      tableView.rowHeight = UITableViewAutomaticDimension

      return cell

    }

  }

   

  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    print(headerView.frame)

  }

}