blob: 0e51e3f6b2bd451981b9630bdf1d70a0eae23a51 (
plain)
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
|
//
// AccountTextField.swift
// MullvadVPN
//
// Created by pronebird on 20/03/2019.
// Copyright © 2019 Mullvad VPN AB. All rights reserved.
//
import UIKit
@IBDesignable class AccountTextField: UITextField {
private let input = AccountTokenInput()
override init(frame: CGRect) {
super.init(frame: frame)
setup()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}
private func setup() {
backgroundColor = UIColor.clear
delegate = input
pasteDelegate = input
}
var autoformattingText: String {
set {
input.replace(with: newValue)
input.updateTextField(self)
}
get {
input.formattedString
}
}
var parsedToken: String {
return input.parsedString
}
override func textRect(forBounds bounds: CGRect) -> CGRect {
return bounds.insetBy(dx: 14, dy: 12)
}
override func editingRect(forBounds bounds: CGRect) -> CGRect {
return textRect(forBounds: bounds)
}
}
|