-
Notifications
You must be signed in to change notification settings - Fork 895
/
Copy pathSEModalProgressView.swift
73 lines (60 loc) · 2.36 KB
/
SEModalProgressView.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
67
68
69
70
71
72
73
//
// SEModalProgressView.swift
// TelegramMac
//
// Created by keepcoder on 04/01/2017.
// Copyright © 2017 Telegram. All rights reserved.
//
import Cocoa
import Localization
import TGUIKit
class SEModalProgressView: View {
private let progress:LinearProgressControl = LinearProgressControl()
private let cancel:TextButton = TextButton()
private let header:TextView = TextView()
private let borderView:View = View()
private let containerView:View = View()
override init() {
super.init()
containerView.addSubview(progress)
containerView.addSubview(cancel)
containerView.addSubview(borderView)
containerView.addSubview(header)
addSubview(containerView)
self.backgroundColor = theme.colors.blackTransparent
self.containerView.backgroundColor = theme.colors.grayBackground
let layout = TextViewLayout(.initialize(string: L10n.shareExtensionShare, color: theme.colors.text, font: .normal(.title)))
layout.measure(width: .greatestFiniteMagnitude)
header.update(layout)
header.backgroundColor = theme.colors.grayBackground
containerView.setFrameSize(250, 80)
containerView.layer?.cornerRadius = .cornerRadius
progress.style = ControlStyle(foregroundColor: theme.colors.accent, backgroundColor: theme.colors.grayBackground)
progress.setFrameSize(250, 4)
cancel.set(font: .medium(.title), for: .Normal)
cancel.set(color: theme.colors.accent, for: .Normal)
cancel.set(text: L10n.shareExtensionCancel, for: .Normal)
_ = cancel.sizeToFit()
cancel.set(handler: { [weak self] _ in
self?.cancelImpl?()
}, for: .Click)
progress.set(progress: 0.0)
}
var cancelImpl:(()->Void)? = nil
func set(progress: CGFloat) {
self.progress.set(progress: progress, animated: true)
}
override func layout() {
super.layout()
containerView.center()
progress.center()
cancel.centerX(y: containerView.frame.height - cancel.frame.height - 10)
header.centerX(y: 10)
}
required init(frame frameRect: NSRect) {
fatalError("init(frame:) has not been implemented")
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}