Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,88 @@ import UIKit

class LoadingView: UIView {

// MARK: - Properties

var title: String = "Buscando endereços..."

// MARK: - Initializer

init(title: String? = nil) {
super.init(frame: .zero)

if let title = title {
self.title = title
}

self.setupViews()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - View Code

private lazy var titleLabel: UILabel = {
let label = UILabel()
label.text = title

label.translatesAutoresizingMaskIntoConstraints = false
label.font = .systemFont(ofSize: 16, weight: .semibold)

return label
}()

private lazy var loadingActivityIndicator: UIActivityIndicatorView = {
let indicator = UIActivityIndicatorView()
indicator.style = .large
indicator.startAnimating()
indicator.translatesAutoresizingMaskIntoConstraints = false

return indicator
}()

private lazy var stackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [titleLabel, loadingActivityIndicator])

stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 15
stackView.alignment = .center

return stackView
}()

}

private extension LoadingView {

func setupViews() {
self.backgroundColor = .white

self.configureSubviews()
self.configureSubviewsConstraints()
}

func configureSubviews() {
self.addSubview(stackView)
}

func configureSubviewsConstraints() {
NSLayoutConstraint.activate([
stackView.centerYAnchor.constraint(equalTo: self.centerYAnchor),
stackView.centerXAnchor.constraint(equalTo: self.centerXAnchor),
])
}
}


#if DEBUG
import SwiftUI

struct LoadingView_Preview: PreviewProvider {
static var previews: some View {
return LoadingView().showPreview()
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//
// LoadingViewSnapshotTest.swift
// DeliveryAppTests
//
// Created by Julia Frederico on 08/12/22.
//
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@
//

import XCTest
import SnapshotTesting
@testable import DeliveryApp

class LoadingViewSnapshotTests {
class LoadingViewSnapshotTests: XCTestCase {

func test_loadingView_defaultState() {
let loadingView = LoadingView()
loadingView.frame = CGRect(x: 0, y: 0, width: 390, height: 844)

let result = verifySnapshot(matching: loadingView,
as: .image,
named: "Default",
testName: "LoadingView")

XCTAssertNil(result)
}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.