<commit_before>//
//  AdjustingErrorView.swift
//  DACircularProgress
//
//  Created by <NAME> on 20/12/17.
//

import UIKit

private let textHeight: CGFloat = 50

/**
    A default view for displaying errors within the feed.
    This will center the text within a specified container and handle multiple
    line error messages as well as the formatting.
 */
class AdjustingErrorView: UITextView {
    var containerToCenterText:UIView? {
        didSet {
            adjustSize()
        }
    }

    override var text: String! {
        didSet {
            adjustSize()
        }
    }

    /**
     * Create a text view that will center the text within the container view
     */
    convenience init(centerTextWithin container:UIView) {
        // set frame to center within view
        self.init(
            frame: CGRect(
                x: 0,
                y: container.frame.height/2 - textHeight/2,
                width: container.frame.width,
                height: textHeight
            ), textContainer: nil
        )
        self.containerToCenterText = container
    }

    override init(frame: CGRect, textContainer: NSTextContainer?) {
        super.init(frame: frame, textContainer: textContainer)
        // default formatting and style
        self.font = UIFont(name: "Helvetica", size: 32)
        self.textAlignment = .center
        self.textColor = .gray
        self.isSelectable = false
        self.isEditable = false
        self.isScrollEnabled = false
    }

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

    // Adjust size for new message or new containing view
    private func adjustSize() {
        guard let parent = self.containerToCenterText else {
            return
        }
        self.sizeToFit()
        self.frame = CGRect(
            x: 0,
            y: parent.frame.height/2 - self.frame.height/2,
            width: parent.frame.width,
            height: self.frame.height
        )
    }
}<commit_msg>Fix AdjustingErrorView no longer errors when initialising via NSCoder<commit_after>//
//  AdjustingErrorView.swift
//  DACircularProgress
//
//  Created by <NAME> on 20/12/17.
//

import UIKit

private let textHeight: CGFloat = 50

/**
    A default view for displaying errors within the feed.
    This will center the text within a specified container and handle multiple
    line error messages as well as the formatting.
 */
class AdjustingErrorView: UITextView {
    var containerToCenterText:UIView? {
        didSet {
            adjustSize()
        }
    }

    override var text: String! {
        didSet {
            adjustSize()
        }
    }

    /**
     * Create a text view that will center the text within the container view
     */
    convenience init(centerTextWithin container: UIView) {
        // set frame to center within view
        self.init(
            frame: CGRect(
                x: 0,
                y: container.frame.height/2 - textHeight/2,
                width: container.frame.width,
                height: textHeight
            ), textContainer: nil
        )
        self.containerToCenterText = container
    }

    override init(frame: CGRect, textContainer: NSTextContainer?) {
        super.init(frame: frame, textContainer: textContainer)
        commonInit()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        commonInit()
    }

    private func commonInit() {
        // default formatting and style
        self.font = UIFont(name: "Helvetica", size: 32)
        self.textAlignment = .center
        self.textColor = .gray
        self.isSelectable = false
        self.isEditable = false
        self.isScrollEnabled = false
    }

    // Adjust size for new message or new containing view
    private func adjustSize() {
        guard let parent = self.containerToCenterText else {
            return
        }
        self.sizeToFit()
        self.frame = CGRect(
            x: 0,
            y: parent.frame.height/2 - self.frame.height/2,
            width: parent.frame.width,
            height: self.frame.height
        )
    }
}
{'fraction_non_alphanumeric': 0.08321342925659472, 'fraction_numerical': 0.007673860911270983, 'mean_word_length': 1.8686382393397525, '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': '6814618', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1119, 'n_words': 335}