added iOS source code
[wl-app.git] / iOS / WolneLektury / Screens / Menu / Cells / MenuBottomTableViewCell.swift
1 //
2 //  MenuBottomTableViewCell.swift
3 //  WolneLektury
4 //
5 //  Created by Pawel Dabrowski on 30/05/2018.
6 //  Copyright © 2018 Fundacja Nowoczesna Polska. All rights reserved.
7 //
8
9 import UIKit
10 protocol MenuBottomTableViewCellDelegate: class{
11     
12     func menuBottomProfileButtonTapped()
13     func menuBottomSignOutButtonButtonTapped()
14 }
15
16 class MenuBottomTableViewCell: WLTableViewCell {
17     weak var delegate: MenuBottomTableViewCellDelegate?
18     @IBOutlet weak var titleLabel: UILabel!
19     @IBOutlet weak var showProfileButton: UIButton!
20     @IBOutlet weak var signOutButton: UIButton!
21     
22     class func instance(delegate: MenuBottomTableViewCellDelegate?) -> MenuBottomTableViewCell{
23         let cell = MenuBottomTableViewCell.instance(type: MenuBottomTableViewCell.self)
24         cell.delegate = delegate
25         return cell
26     }
27
28     override func awakeFromNib() {
29         super.awakeFromNib()
30         
31         showProfileButton.layer.cornerRadius = 13
32         showProfileButton.layer.borderColor = UIColor.white.cgColor
33         showProfileButton.layer.borderWidth = 1
34         
35         let titleText = NSMutableAttributedString(attributedString: NSAttributedString(string: "logged_as".localized + "\n", font: UIFont.systemFont(ofSize: 10)))
36         titleText.append(NSAttributedString(string: "Zuzanna Stańska", font: UIFont.systemFont(ofSize: 12)))
37         titleLabel.attributedText = titleText
38         showProfileButton.text = "show_profile".localized
39         signOutButton.text = "sign_out".localized
40         
41         let bgColor = Constants.Colors.menuTintColor()
42         backgroundColor = bgColor
43         contentView.backgroundColor = bgColor
44     }
45     
46     override func getHeight() -> CGFloat {
47         return 180
48     }
49     
50     @IBAction func signoutButtonAction(_ sender: Any) {
51         delegate?.menuBottomSignOutButtonButtonTapped()
52     }
53     
54     @IBAction func profileButtonAction(_ sender: Any) {
55         delegate?.menuBottomProfileButtonTapped()
56     }
57 }