<commit_before>//: [Previous](@previous)
/*:
 # KeyboardNotificationReceiving
 */
import UIKit
import XCPlayground
import PlaygroundSupport
import Prelude

let textFieldOriginY: CGFloat = 667.0 - 50.0
let textFieldOriginalFrame = CGRect(x: 0.0, y: textFieldOriginY, width: 375.0, height: 50.0)

class ViewController: UIViewController {
    
    private lazy var textField: UITextField = {
        let textField = UITextField(frame: textFieldOriginalFrame)
        textField.borderStyle = .line
        textField.placeholder = "Text Field"
        return textField
    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.addSubview(textField)
        let tapGesture = UITapGestureRecognizer(
            target: self,
            action: #selector(ViewController.viewTapped)
        )
        self.view.addGestureRecognizer(tapGesture)

        NotificationCenter.default.addObserver(
            self,
            selector: #selector(ViewController.keyboardWillShow(_:)),
            name: .UIKeyboardWillShow,
            object: nil
        )
        NotificationCenter.default.addObserver(
            self,
            selector: #selector(ViewController.keyboardWillHide(_:)),
            name: .UIKeyboardWillHide,
            object: nil
        )
    }
    
    @objc func viewTapped() {
        view.endEditing(true)
    }
    @objc func keyboardWillShow(_ notification: Notification) {
        handleKeyboardWillShow(notification)
    }
    @objc func keyboardWillHide(_ notification: Notification) {
        handleKeyboardWillHide(notification)
    }
}

extension ViewController: KeyboardNotificationReceiving {
    func animationsWhenKeyboardWillMove(keyboardRect: CGRect, show: Bool) {
        // add custom animation here
        textField.frame = CGRect(
            x: textFieldOriginalFrame.origin.x,
            y: textFieldOriginalFrame.origin.y - (show ? keyboardRect.size.height : 0),
            width: textFieldOriginalFrame.size.width,
            height: textFieldOriginalFrame.size.height
        )
    }
}

let viewController = ViewController()
viewController.view.backgroundColor = .white
PlaygroundPage.current.liveView = viewController

//: [Next](@next)<commit_msg>Update KeyboardNotificationReceiving format<commit_after>//: [Previous](@previous)
/*:
 # KeyboardNotificationReceiving
 */
import UIKit
import XCPlayground
import PlaygroundSupport
import Prelude

let textFieldOriginalFrame = CGRect(x: 0.0, y: 667.0 - 50.0, width: 375.0, height: 50.0)

class ViewController: UIViewController {
    
    lazy var textField: UITextField = {
        let textField = UITextField(frame: textFieldOriginalFrame)
        textField.borderStyle = .line
        textField.placeholder = "Text Field"
        return textField
    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = .white
        view.addSubview(textField)
        let tapGesture = UITapGestureRecognizer(
            target: self,
            action: #selector(ViewController.viewTapped)
        )
        view.addGestureRecognizer(tapGesture)

        NotificationCenter.default.addObserver(
            self,
            selector: #selector(ViewController.keyboardWillShow(_:)),
            name: .UIKeyboardWillShow,
            object: nil
        )
        NotificationCenter.default.addObserver(
            self,
            selector: #selector(ViewController.keyboardWillHide(_:)),
            name: .UIKeyboardWillHide,
            object: nil
        )
    }
    
    @objc func viewTapped() {
        view.endEditing(true)
    }
    @objc func keyboardWillShow(_ notification: Notification) {
        handleKeyboardWillShow(notification)
    }
    @objc func keyboardWillHide(_ notification: Notification) {
        handleKeyboardWillHide(notification)
    }
}

extension ViewController: KeyboardNotificationReceiving {
    func animationsWhenKeyboardWillMove(keyboardRect: CGRect, show: Bool) {
        // add custom animation here
        textField.frame = CGRect(
            x: textFieldOriginalFrame.origin.x,
            y: textFieldOriginalFrame.origin.y - (show ? keyboardRect.size.height : 0),
            width: textFieldOriginalFrame.size.width,
            height: textFieldOriginalFrame.size.height
        )
    }
}

let viewController = ViewController()
PlaygroundPage.current.liveView = viewController

//: [Next](@next)
{'fraction_non_alphanumeric': 0.08767557770729498, 'fraction_numerical': 0.007702763932940644, 'mean_word_length': 2.6791666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '23438', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1192, 'n_words': 242}