<commit_before>//
//  AlertView.swift
//  breadwallet
//
//  Created by <NAME> on 2016-11-22.
//  Copyright © 2016 breadwallet LLC. All rights reserved.
//

import UIKit

enum AlertType {
    case pinSet
    case paperKeySet

    var header: String {
        switch self {
        case .pinSet:
            return NSLocalizedString("PIN Set", comment: "Alert Header label")
        case .paperKeySet:
            return NSLocalizedString("Paper Key Set", comment: "Alert Header Label")
        }
    }

    var subheader: String {
        switch self {
        case .pinSet:
            return NSLocalizedString("Use your PIN to login and send money.", comment: "Alert Subheader label")
        case .paperKeySet:
            return NSLocalizedString("Awesome!", comment: "Alert Subheader label")
        }
    }

    var icon: UIView {
        return CheckView()
    }
}

class AlertView: UIView, GradientDrawable {

    let type: AlertType
    let header = UILabel()
    let subheader = UILabel()
    var icon: UIView

    init(type: AlertType) {
        self.type = type
        self.icon = type.icon

        super.init(frame: .zero)
        layer.cornerRadius = 6.0
        layer.masksToBounds = true
        setupSubviews()
    }

    func animate() {
        guard let animatableIcon = icon as? AnimatableIcon else { return }
        animatableIcon.animate()
    }

    private func setupSubviews() {
        addSubview(header)
        addSubview(subheader)
        addSubview(icon)

        header.constrainTopCorners(sidePadding: C.padding[2], topPadding: C.padding[4])

        header.text = type.header
        header.textAlignment = .center
        header.font = UIFont.customBold(size: 14.0)
        header.textColor = .white

        icon.backgroundColor = .clear
        icon.constrain([
                icon.constraint(.centerX, toView: self, constant: nil),
                icon.constraint(.centerY, toView: self, constant: nil),
                icon.constraint(.width, constant: 96.0),
                icon.constraint(.height, constant: 96.0)
            ])
    }

    override func draw(_ rect: CGRect) {
        drawGradient(rect)
    }
<commit_msg>Add missing Alert view subviews<commit_after>//
//  AlertView.swift
//  breadwallet
//
//  Created by <NAME> on 2016-11-22.
//  Copyright © 2016 breadwallet LLC. All rights reserved.
//

import UIKit

enum AlertType {
    case pinSet
    case paperKeySet

    var header: String {
        switch self {
        case .pinSet:
            return NSLocalizedString("PIN Set", comment: "Alert Header label")
        case .paperKeySet:
            return NSLocalizedString("Paper Key Set", comment: "Alert Header Label")
        }
    }

    var subheader: String {
        switch self {
        case .pinSet:
            return NSLocalizedString("Use your PIN to login and send money.", comment: "Alert Subheader label")
        case .paperKeySet:
            return NSLocalizedString("Awesome!", comment: "Alert Subheader label")
        }
    }

    var icon: UIView {
        return CheckView()
    }
}

class AlertView: UIView, GradientDrawable {

    private let type: AlertType
    private let header = UILabel()
    private let subheader = UILabel()
    private let separator = UIView()
    private let icon: UIView
    private let iconSize: CGFloat = 96.0
    private let separatorYOffset: CGFloat = 48.0

    init(type: AlertType) {
        self.type = type
        self.icon = type.icon

        super.init(frame: .zero)
        layer.cornerRadius = 6.0
        layer.masksToBounds = true
        setupSubviews()
    }

    func animate() {
        guard let animatableIcon = icon as? AnimatableIcon else { return }
        animatableIcon.animate()
    }

    private func setupSubviews() {
        addSubview(header)
        addSubview(subheader)
        addSubview(icon)
        addSubview(separator)

        setData()
        addConstraints()
    }

    private func setData() {
        header.text = type.header
        header.textAlignment = .center
        header.font = UIFont.customBold(size: 14.0)
        header.textColor = .white

        icon.backgroundColor = .clear
        separator.backgroundColor = UIColor(white: 1.0, alpha: 0.3)

        subheader.text = type.subheader
        subheader.textAlignment = .center
        subheader.font = UIFont.customBody(size: 14.0)
        subheader.textColor = .white
    }

    private func addConstraints() {

        //NB - In this alert view, constraints shouldn't be pinned to the bottom
        //of the view because the bottom actually extends off the bottom of the screen a bit.
        //It extends so that it still covers up the underlying view when it bounces on screen.

        header.constrainTopCorners(sidePadding: C.padding[2], topPadding: C.padding[2])
        separator.constrain([
            separator.constraint(.height, constant: 1.0),
            separator.constraint(.width, toView: self, constant: 0.0),
            separator.constraint(.top, toView: self, constant: separatorYOffset),
            separator.constraint(.leading, toView: self, constant: nil)
            ])
        icon.constrain([
                icon.constraint(.centerX, toView: self, constant: nil),
                icon.constraint(.centerY, toView: self, constant: nil),
                icon.constraint(.width, constant: iconSize),
                icon.constraint(.height, constant: iconSize)
            ])

        subheader.constrain([
                subheader.constraint(.leading, toView: self, constant: C.padding[2]),
                subheader.constraint(.trailing, toView: self, constant: -C.padding[2]),
                subheader.constraint(toBottom: icon, constant: C.padding[3])
            ])
    }

    override func draw(_ rect: CGRect) {
        drawGradient(rect)
    }

{'fraction_non_alphanumeric': 0.09735122119023047, 'fraction_numerical': 0.011007911936704506, 'mean_word_length': 2.119635193133047, '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': '7042505', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1600, 'n_words': 453}