Skip to content

Commit 786822c

Browse files
committed
Finished & finalized calibration view
1 parent 297f014 commit 786822c

File tree

6 files changed

+63
-11
lines changed

6 files changed

+63
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x"
6+
},
7+
{
8+
"filename" : "calibrate@2x.png",
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"filename" : "calibrate@3x.png",
14+
"idiom" : "universal",
15+
"scale" : "3x"
16+
}
17+
],
18+
"info" : {
19+
"author" : "xcode",
20+
"version" : 1
21+
}
22+
}
Loading
Loading

Turbah/Classes/Views/CalibrateView.swift

+34-9
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,45 @@ import UIKit
1010

1111
class CalibrateView: UIVisualEffectView {
1212

13-
let instructionLabel: UILabel = {
14-
let label = UILabel()
15-
label.textAlignment = .center
16-
label.text = "Calibrate compass before use for better accuracy"
17-
label.numberOfLines = 2
18-
return label
19-
}()
13+
var stack = UIStackView()
14+
var vibrancyView = UIVisualEffectView()
15+
var instructionLabel = UILabel()
16+
var calibrateImageView = UIImageView()
17+
var removeButton = UIImageView()
2018

2119
private func setupViews() {
2220
effect = blurEffect
2321
translatesAutoresizingMaskIntoConstraints = false
2422

25-
contentView.addSubview(instructionLabel)
26-
instructionLabel.fillSuperview(padding: UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20))
23+
vibrancyView.effect = UIVibrancyEffect(blurEffect: blurEffect, style: .secondaryLabel)
24+
contentView.addSubview(vibrancyView)
25+
vibrancyView.fillSuperview()
26+
27+
instructionLabel.textAlignment = .center
28+
instructionLabel.numberOfLines = 2
29+
instructionLabel.font = .systemFont(ofSize: 16, weight: .semibold)
30+
instructionLabel.text = "Calibrate compass before use for better accuracy"
31+
32+
calibrateImageView.contentMode = .scaleAspectFit
33+
calibrateImageView.image = #imageLiteral(resourceName: "calibrate").withRenderingMode(.alwaysTemplate)
34+
calibrateImageView.widthAnchor.constraint(equalToConstant: 164).isActive = true
35+
calibrateImageView.heightAnchor.constraint(equalToConstant: 78).isActive = true
36+
37+
stack.axis = .vertical
38+
stack.distribution = .fill
39+
stack.alignment = .center
40+
stack.spacing = 30
41+
stack.addArrangedSubview(calibrateImageView)
42+
stack.addArrangedSubview(instructionLabel)
43+
44+
vibrancyView.contentView.addSubview(stack)
45+
stack.fillSuperview(padding: UIEdgeInsets(top: 40, left: 30, bottom: 30, right: 30))
46+
47+
removeButton.translatesAutoresizingMaskIntoConstraints = false
48+
removeButton.image = UIImage(systemName: "xmark.circle.fill", withConfiguration: UIImage.SymbolConfiguration(pointSize: 28))
49+
vibrancyView.contentView.addSubview(removeButton)
50+
removeButton.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 10).isActive = true
51+
removeButton.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -10).isActive = true
2752
}
2853

2954
override func layoutSubviews() {

Turbah/Controllers/ViewController.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -256,18 +256,23 @@ class ViewController: UIViewController, CLLocationManagerDelegate, ARCoachingOve
256256
var calibrateView: CalibrateView?
257257

258258
func showCalibrateView() {
259-
guard !save.didShowCalibration else { return }
259+
//guard !save.didShowCalibration else { return }
260260

261261
calibrateView = CalibrateView()
262262
calibrateView!.alpha = 0
263263
calibrateView!.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(removeCalibrateView)))
264264

265265
view.addSubview(calibrateView!)
266266
calibrateView!.centerInSuperview()
267+
calibrateView!.widthAnchor.constraint(equalToConstant: 273).isActive = true
267268

268269
UIView.animate(withDuration: 0.2, delay: 0.5, options: [], animations: {
269270
self.calibrateView?.alpha = 1
270-
})
271+
}) { _ in
272+
DispatchQueue.main.asyncAfter(deadline: .now() + 4) {
273+
self.removeCalibrateView()
274+
}
275+
}
271276
}
272277

273278
@objc func removeCalibrateView() {

0 commit comments

Comments
 (0)