-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathOutgoingDeviceTransferInitialViewController.swift
65 lines (52 loc) · 2.31 KB
/
OutgoingDeviceTransferInitialViewController.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
//
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import Foundation
import Lottie
import SignalServiceKit
class OutgoingDeviceTransferInitialViewController: DeviceTransferBaseViewController {
let animationView = LottieAnimationView(name: "transfer")
override func viewDidLoad() {
super.viewDidLoad()
let titleLabel = self.titleLabel(
text: OWSLocalizedString("DEVICE_TRANSFER_PROMPT_TITLE",
comment: "The title on the acttion sheet prompting the user if they want to transfer their device.")
)
contentView.addArrangedSubview(titleLabel)
contentView.addArrangedSubview(.spacer(withHeight: 12))
let explanationLabel = self.explanationLabel(
explanationText: OWSLocalizedString("DEVICE_TRANSFER_PROMPT_EXPLANATION",
comment: "The explanation on the action sheet prompting the user if they want to transfer their device.")
)
contentView.addArrangedSubview(explanationLabel)
let topSpacer = UIView.vStretchingSpacer()
contentView.addArrangedSubview(topSpacer)
animationView.contentMode = .scaleAspectFit
animationView.loopMode = .loop
animationView.backgroundBehavior = .pauseAndRestore
animationView.autoSetDimension(.height, toSize: 110)
contentView.addArrangedSubview(animationView)
let bottomSpacer = UIView.vStretchingSpacer()
contentView.addArrangedSubview(bottomSpacer)
topSpacer.autoMatch(.height, to: .height, of: bottomSpacer)
let nextButton = button(title: CommonStrings.nextButton, selector: #selector(didTapNext))
contentView.addArrangedSubview(nextButton)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
animationView.play()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
animationView.stop()
}
@objc
private func didTapNext() {
ows_askForCameraPermissions { granted in
guard granted else { return }
let qrScanner = OutgoingDeviceTransferQRScanningViewController()
self.navigationController?.pushViewController(qrScanner, animated: true)
}
}
}