<commit_before>//
//  ModalViewController.swift
//  IBFiP01ShowingAModal
//
//  Created by <NAME> on 12/1/16.
//  Copyright © 2016 Raizlabs. All rights reserved.
//

import Anchorage
import UIKit

/// A modal with dark blurred background and light UIStatusBar
class ModalViewController: UIViewController {

    fileprivate let blurView: UIVisualEffectView = {
        let effect = UIBlurEffect(style: UIBlurEffectStyle.dark)
        return UIVisualEffectView(effect: effect)
    }()

    fileprivate let dismissButton = DismissButton()

    override func viewDidLoad() {
        configureActions()
        configureView()
    }
}

// MARK: - UIViewContoller style overrides
extension ModalViewController {

    override var modalPresentationStyle: UIModalPresentationStyle {
        get {
            return .overFullScreen
        }
        set {
            print("ModalViewController: ignoring setting the modal presentation style: this controller is designed to be presented full screen and so should always be .overFullScreen (plus, it would kill the blur if its not .overFullScreen or .overCurrentContext)")
        }
    }

    /// Apple docs state that this value should be ignored when a view controller is presented full screen, but this doesn't appear to be the case, we still need to override it to control the status bar appearance (https://developer.apple.com/reference/uikit/uiviewcontroller/1621453-modalpresentationcapturesstatusb)
    override var modalPresentationCapturesStatusBarAppearance: Bool {
        get {
            return true
        }
        set {
            print("ModalViewController: ignoring setting the modalPresentationCapturesStatusBarAppearance style, it would not allow this controller to control the status bar")
        }
    }

    override var prefersStatusBarHidden: Bool {
        return false
    }

    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }

}

// MARK: - Actions
private extension ModalViewController {

    func configureActions() {
        dismissButton.addTarget(self, action: #selector(dismissButtonTapped), for: .touchUpInside)
    }

    @objc func dismissButtonTapped() {
        presentingViewController?.dismiss(animated: true, completion: nil)

    }
}

// MARK: - View Configuration
private extension ModalViewController {

    enum Constants {
        static let dismissButtonMarginRight = CGFloat(10)
        static let dismissButtonMarginTop = CGFloat(30)
    }

    func configureView() {

        // View Hierarchy
        view.addSubview(blurView)
        view.addSubview(dismissButton)

        // Style
        view.isOpaque = false
        view.backgroundColor = AppColor.clear

        // Layout

        // blurView shares all edges w/its parent
        blurView.edgeAnchors == view.edgeAnchors

        // dismissButton is placed at the top right
        dismissButton.topAnchor == view.topAnchor + Constants.dismissButtonMarginTop
        dismissButton.rightAnchor == view.rightAnchor - Constants.dismissButtonMarginRight
    }

}
<commit_msg>removing perfersStatusBarHidden as well<commit_after>//
//  ModalViewController.swift
//  IBFiP01ShowingAModal
//
//  Created by <NAME> on 12/1/16.
//  Copyright © 2016 Raizlabs. All rights reserved.
//

import Anchorage
import UIKit

/// A modal with dark blurred background and light UIStatusBar
class ModalViewController: UIViewController {

    fileprivate let blurView: UIVisualEffectView = {
        let effect = UIBlurEffect(style: UIBlurEffectStyle.dark)
        return UIVisualEffectView(effect: effect)
    }()

    fileprivate let dismissButton = DismissButton()

    override func viewDidLoad() {
        configureActions()
        configureView()
    }
}

// MARK: - UIViewContoller style overrides
extension ModalViewController {

    override var modalPresentationStyle: UIModalPresentationStyle {
        get {
            return .overFullScreen
        }
        set {
            print("ModalViewController: ignoring setting the modal presentation style: this controller is designed to be presented full screen and so should always be .overFullScreen (plus, it would kill the blur if its not .overFullScreen or .overCurrentContext)")
        }
    }

    /// Apple docs state that this value should be ignored when a view controller is presented full screen, but this doesn't appear to be the case, we still need to override it to control the status bar appearance (https://developer.apple.com/reference/uikit/uiviewcontroller/1621453-modalpresentationcapturesstatusb)
    override var modalPresentationCapturesStatusBarAppearance: Bool {
        get {
            return true
        }
        set {
            print("ModalViewController: ignoring setting the modalPresentationCapturesStatusBarAppearance style, it would not allow this controller to control the status bar")
        }
    }

    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }

}

// MARK: - Actions
private extension ModalViewController {

    func configureActions() {
        dismissButton.addTarget(self, action: #selector(dismissButtonTapped), for: .touchUpInside)
    }

    @objc func dismissButtonTapped() {
        presentingViewController?.dismiss(animated: true, completion: nil)

    }
}

// MARK: - View Configuration
private extension ModalViewController {

    enum Constants {
        static let dismissButtonMarginRight = CGFloat(10)
        static let dismissButtonMarginTop = CGFloat(30)
    }

    func configureView() {

        // View Hierarchy
        view.addSubview(blurView)
        view.addSubview(dismissButton)

        // Style
        view.isOpaque = false
        view.backgroundColor = AppColor.clear

        // Layout

        // blurView shares all edges w/its parent
        blurView.edgeAnchors == view.edgeAnchors

        // dismissButton is placed at the top right
        dismissButton.topAnchor == view.topAnchor + Constants.dismissButtonMarginTop
        dismissButton.rightAnchor == view.rightAnchor - Constants.dismissButtonMarginRight
    }
}

{'fraction_non_alphanumeric': 0.06841673502871205, 'fraction_numerical': 0.007219031993437244, 'mean_word_length': 2.9076923076923076, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '256152', 'n_tokens_mistral': 1647, 'n_tokens_neox': 1549, 'n_words': 481}