Skip to content

Commit

Permalink
Merge branch 'master' into fix/torch-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vadymmarkov committed Feb 1, 2018
2 parents 3cbe0c2 + 6eee165 commit 4a8ae52
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
2 changes: 1 addition & 1 deletion BarcodeScanner.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "BarcodeScanner"
s.summary = "Simple and beautiful barcode scanner."
s.version = "4.1.0"
s.version = "4.1.1"
s.homepage = "https://github.com/hyperoslo/BarcodeScanner"
s.license = 'MIT'
s.author = { "Hyper Interaktiv AS" => "[email protected]" }
Expand Down
4 changes: 2 additions & 2 deletions Example/BarcodeScannerExample/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- BarcodeScanner (4.1.0)
- BarcodeScanner (4.1.1)

DEPENDENCIES:
- BarcodeScanner (from `../../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: ../../

SPEC CHECKSUMS:
BarcodeScanner: 1d811612a55549741cc9dcfecdd6e562d9982edb
BarcodeScanner: 91ac9634d249b4e59a5b57dff9264b691bc99ea6

PODFILE CHECKSUM: ea40d735f047f0ae7ae319d7a320a82facf3361f

Expand Down
58 changes: 34 additions & 24 deletions Sources/Controllers/MessageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public final class MessageViewController: UIViewController {
// MARK: - UI properties

/// Text label.
public private(set) lazy var textLabel: UILabel = .init()
public private(set) lazy var textLabel: UILabel = self.makeTextLabel()
/// Info image view.
public private(set) lazy var imageView: UIImageView = .init()
public private(set) lazy var imageView: UIImageView = self.makeImageView()
/// Border view.
public private(set) lazy var borderView: UIView = .init()
public private(set) lazy var borderView: UIView = self.makeBorderView()

/// Blur effect view.
private lazy var blurView: UIVisualEffectView = .init(effect: UIBlurEffect(style: .extraLight))
Expand All @@ -37,7 +37,6 @@ public final class MessageViewController: UIViewController {
super.viewDidLoad()
view.addSubview(blurView)
blurView.contentView.addSubviews(textLabel, imageView, borderView)
setupSubviews()
handleStatusUpdate()
}

Expand Down Expand Up @@ -99,24 +98,6 @@ public final class MessageViewController: UIViewController {
}))
}

// MARK: - Subviews

private func setupSubviews() {
textLabel.translatesAutoresizingMaskIntoConstraints = false
textLabel.textColor = .black
textLabel.numberOfLines = 3

imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.image = imageNamed("info").withRenderingMode(.alwaysTemplate)
imageView.tintColor = .black

borderView.translatesAutoresizingMaskIntoConstraints = false
borderView.backgroundColor = .clear
borderView.layer.borderWidth = 2
borderView.layer.cornerRadius = 10
borderView.layer.borderColor = UIColor.black.cgColor
}

// MARK: - State handling

private func handleStatusUpdate() {
Expand All @@ -126,12 +107,10 @@ public final class MessageViewController: UIViewController {

switch status.state {
case .scanning, .unauthorized:
textLabel.font = UIFont.boldSystemFont(ofSize: 14)
textLabel.numberOfLines = 3
textLabel.textAlignment = .left
imageView.tintColor = regularTintColor
case .processing:
textLabel.font = UIFont.boldSystemFont(ofSize: 16)
textLabel.numberOfLines = 10
textLabel.textAlignment = .center
borderView.isHidden = false
Expand All @@ -153,6 +132,37 @@ public final class MessageViewController: UIViewController {
}
}

// MARK: - Subviews factory

private extension MessageViewController {
func makeTextLabel() -> UILabel {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = .black
label.numberOfLines = 3
label.font = UIFont.boldSystemFont(ofSize: 14)
return label
}

func makeImageView() -> UIImageView {
let imageView = UIImageView()
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.image = imageNamed("info").withRenderingMode(.alwaysTemplate)
imageView.tintColor = .black
return imageView
}

func makeBorderView() -> UIView {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .clear
view.layer.borderWidth = 2
view.layer.cornerRadius = 10
view.layer.borderColor = UIColor.black.cgColor
return view
}
}

// MARK: - Layout

extension MessageViewController {
Expand Down

0 comments on commit 4a8ae52

Please sign in to comment.