added iOS source code
[wl-app.git] / iOS / WolneLektury / Screens / About / AboutViewController.swift
1 //
2 //  AboutViewController.swift
3 //  WolneLektury
4 //
5 //  Created by Pawel Dabrowski on 18/09/2018.
6 //  Copyright © 2018 Fundacja Nowoczesna Polska. All rights reserved.
7 //
8
9 import UIKit
10 import MessageUI
11
12 class AboutViewController: MainViewController, MFMailComposeViewControllerDelegate {
13     
14     @IBOutlet weak var firstTextView: UITextView!
15     @IBOutlet weak var secondLabel: UILabel!
16     @IBOutlet weak var thirdLabel: UILabel!
17     @IBOutlet weak var contactButton: UIButton!
18     @IBOutlet weak var becomeFriendButton: UIButton!
19     @IBOutlet weak var logoTopConstraint: NSLayoutConstraint!
20     
21     override func viewDidLoad() {
22         super.viewDidLoad()
23
24         title = "nav_about".localized
25
26         firstTextView.textContainerInset = UIEdgeInsets.zero
27         firstTextView.textContainer.lineFragmentPadding = 0
28  
29         becomeFriendButton.layer.cornerRadius = 18
30         
31         if DatabaseManager.shared.isUserPremium() || Constants.donateEnabled == false{
32             becomeFriendButton.isHidden = true
33             logoTopConstraint.constant = 30
34         }
35         else {
36             becomeFriendButton.isHidden = false
37             logoTopConstraint.constant = 70
38         }
39         
40         
41         if let htmlString = try? NSAttributedString(html: "about_text".localized){
42             firstTextView.attributedText =  htmlString
43         }
44         else {
45             firstTextView.text = "about_text".localized
46         }
47         firstTextView.tintColor = Constants.Colors.darkGreenBgColor()
48
49         secondLabel.text = "about_text_fundation".localized
50         thirdLabel.text = "about_text_mkdn".localized
51         contactButton.text = "about_text_contact".localized
52     }
53     
54     @IBAction func becomeFriendButtonAction(_ sender: Any) {
55         onBecomeFriendButtonTapped()
56     }
57     
58     @IBAction func contactButtonAction(_ sender: Any) {
59
60         let email = contactButton.text
61         if let url = URL(string: "mailto:\(email)") {
62             if #available(iOS 10.0, *) {
63                 UIApplication.shared.open(url)
64             } else {
65                 UIApplication.shared.openURL(url)
66             }
67         }
68     }
69 }