-
Notifications
You must be signed in to change notification settings - Fork 13
/
ModalViewController.swift
44 lines (35 loc) · 1.14 KB
/
ModalViewController.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
//
// ModalViewController.swift
// ACKategories-Example
//
// Created by Jakub Olejník on 22/10/2019.
// Copyright © 2019 Ackee, s.r.o. All rights reserved.
//
import UIKit
protocol ModalFlowDelegate: AnyObject {
func didTapDismiss(in viewController: ModalViewController)
}
final class ModalViewController: BaseViewControllerNoVM {
weak var flowDelegate: ModalFlowDelegate?
private weak var button: UIButton!
// MARK: - View life cycle
override func loadView() {
super.loadView()
let button = UIButton(type: .system)
button.setTitle("Dismiss", for: .normal)
view.addSubview(button)
button.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
button.centerXAnchor.constraint(equalTo: view.centerXAnchor),
button.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
self.button = button
}
override func viewDidLoad() {
super.viewDidLoad()
button.on { [weak self] _ in
guard let self = self else { return }
self.flowDelegate?.didTapDismiss(in: self)
}
}
}