<commit_before>//
//  LoadingViewController.swift
//  StripeIdentity
//
//  Created by <NAME> on 10/28/21.
//

import UIKit
@_spi(STP) import StripeUICore

/// Simple view controller with a spinner
final class LoadingViewController: UIViewController {
    private let spinner: UIActivityIndicatorView = {
        let style: UIActivityIndicatorView.Style
        if #available(iOS 13.0, *) {
            return UIActivityIndicatorView(style: .large)
        } else {
            return UIActivityIndicatorView(style: .gray)
        }
    }()

    init() {
        super.init(nibName: nil, bundle: nil)

        view.backgroundColor = CompatibleColor.systemBackground
        view.addSubview(spinner)

        spinner.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            spinner.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor),
            spinner.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor),
        ])
    }

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

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        spinner.startAnimating()
    }

    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)

        spinner.stopAnimating()
    }
}<commit_msg>IDPROD-2746: Update loading screen design  (#744)<commit_after>//
//  LoadingViewController.swift
//  StripeIdentity
//
//  Created by <NAME> on 10/28/21.
//

import UIKit
@_spi(STP) import StripeUICore

/// Simple view controller with a spinner
final class LoadingViewController: UIViewController {
    struct Styling {
        static let inset = NSDirectionalEdgeInsets(top: 32, leading: 16, bottom: 0, trailing: 16)
    }

    private let spinner: ActivityIndicator = {
        let activityIndicator = ActivityIndicator(size: .large)
        return activityIndicator
    }()

    private let loadingLabel: UILabel = {
        let label = UILabel()
        label.numberOfLines = 0
        label.adjustsFontForContentSizeCategory = true
        // TODO(IDPROD-3114): Localize `Loading`
        label.text = "Loading"
        label.font = IdentityUI.titleFont
        label.textAlignment = .center
        return label
    }()

    init() {
        super.init(nibName: nil, bundle: nil)
        view.backgroundColor = IdentityUI.containerColor
        installViews()
        installConstraints()
    }

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

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        spinner.startAnimating()
    }

    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)

        spinner.stopAnimating()
    }
}

private extension LoadingViewController {
    func installViews() {
        view.addSubview(spinner)
        view.addSubview(loadingLabel)
    }

    func installConstraints() {
        [spinner, loadingLabel].forEach { $0.translatesAutoresizingMaskIntoConstraints = false }

        NSLayoutConstraint.activate([
            loadingLabel.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor),
            loadingLabel.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor),
            loadingLabel.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: Styling.inset.leading),
            loadingLabel.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -Styling.inset.trailing),


            spinner.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor),
            spinner.bottomAnchor.constraint(equalTo: loadingLabel.topAnchor, constant: -Styling.inset.top),
        ])
    }
}
{'fraction_non_alphanumeric': 0.09325090159711488, 'fraction_numerical': 0.009015971148892323, 'mean_word_length': 2.954175152749491, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7155812', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1083, 'n_words': 213}