-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathWelcomeViewController.swift
58 lines (47 loc) · 1.47 KB
/
WelcomeViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// WelcomeViewController.swift
// SuperwallUIKitExample
//
// Created by Yusuf Tör on 05/04/2022.
//
import UIKit
import SuperwallKit
final class WelcomeViewController: UIViewController {
@IBOutlet private var textFieldBackgroundView: UIView!
@IBOutlet private var textField: UITextField!
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.isNavigationBarHidden = true
}
override func viewDidLoad() {
super.viewDidLoad()
if Superwall.shared.isLoggedIn {
next()
}
textFieldBackgroundView.layer.cornerRadius = textFieldBackgroundView.frame.height / 2
textField.delegate = self
UINavigationBar.appearance().titleTextAttributes = [
.foregroundColor: UIColor.white,
.font: UIFont.rubikBold(.five)
]
navigationController?.interactivePopGestureRecognizer?.isEnabled = false
}
@IBAction private func logIn() {
if let name = textField.text {
Superwall.shared.setUserAttributes(["firstName": name])
}
Superwall.shared.identify(userId: "abc")
next()
}
private func next() {
let trackEventViewController = HomeViewController.fromStoryboard()
navigationController?.pushViewController(trackEventViewController, animated: true)
}
}
// MARK: - UITextFieldDelegate
extension WelcomeViewController: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
_ = textField.resignFirstResponder()
return true
}
}