-
Notifications
You must be signed in to change notification settings - Fork 895
/
Copy pathSEUnauthorizedViewController.swift
66 lines (54 loc) · 2 KB
/
SEUnauthorizedViewController.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
59
60
61
62
63
64
65
66
//
// SEUnauthorizedViewController.swift
// Telegram
//
// Created by keepcoder on 29/03/2017.
// Copyright © 2017 Telegram. All rights reserved.
//
import Cocoa
import TGUIKit
import Localization
class SEUnauthorizedView : View {
fileprivate let imageView:ImageView = ImageView()
fileprivate let cancel:TextButton = TextButton()
fileprivate let textView:TextView = TextView()
required init(frame frameRect: NSRect) {
super.init(frame: frameRect)
imageView.image = #imageLiteral(resourceName: "Icon_TelegramLogin").precomposed()
imageView.sizeToFit()
self.backgroundColor = theme.colors.background
cancel.set(font: .medium(.title), for: .Normal)
cancel.set(color: theme.colors.accent, for: .Normal)
cancel.set(text: L10n.shareExtensionUnauthorizedOK, for: .Normal)
let layout = TextViewLayout(.initialize(string: L10n.shareExtensionUnauthorizedDescription, color: theme.colors.text, font: .normal(.text)), alignment: .center)
textView.backgroundColor = theme.colors.background
textView.update(layout)
addSubview(cancel)
addSubview(textView)
addSubview(imageView)
}
override func layout() {
super.layout()
imageView.centerX(y: 30)
textView.textLayout?.measure(width: frame.width - 60)
textView.update(textView.textLayout)
textView.center()
cancel.centerX(y: textView.frame.maxY + 20)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class SEUnauthorizedViewController: GenericViewController<SEUnauthorizedView> {
private let cancelImpl:()->Void
init(cancelImpl:@escaping()->Void) {
self.cancelImpl = cancelImpl
super.init()
}
override func viewDidLoad() {
super.viewDidLoad()
genericView.cancel.set(handler: { [weak self] _ in
self?.cancelImpl()
}, for: .Click)
}
}