<commit_before>//
//  TextViewElementCell.swift
//  Elemental
//
//  Created by <NAME> on 2/23/17.
//  Copyright © 2017 Incipia. All rights reserved.
//

import UIKit

class TextViewInputElementCell: BindableElementCell {
   @IBOutlet private var _label: UILabel!
   @IBOutlet private var _detailLabel: UILabel!
   @IBOutlet private var _labelVerticalSpaceConstraint: NSLayoutConstraint!
   @IBOutlet private var _detailLabelVerticalSpaceConstraint: NSLayoutConstraint!
   @IBOutlet fileprivate var _textView: PlaceholderTextView!
   @IBOutlet private var _textFieldHeightConstraint: NSLayoutConstraint!
   
   fileprivate var _action: InputElementAction?
   fileprivate var _isEnabled: Bool {
      get { return _textView.isEditable }
      set {
         if !newValue, _textView.isFirstResponder {
            _textView.resignFirstResponder()
         }
         _textView.isEditable = newValue
         _textView.isSelectable = newValue
      }
   }

   static var bindableKeys: [BindableElementKey] { return [.text, .isEnabled] }

   override func awakeFromNib() {
      super.awakeFromNib()
      _textView.textContainerInset = UIEdgeInsets(top: 16, left: 12, bottom: 16, right: 12)
      _textView.delegate = self
   }
   
   override func configure(with component: Elemental) {
      super.configure(with: component)
      guard let element = component as? TextViewInputElement else { fatalError() }
      let content = element.content
      let style = element.configuration
      let action = element.action
      _label.text = content.name
      _detailLabel.text = content.detail
      _label.font = style.nameStyle.font
      _textView.font = style.inputStyle.font
      _detailLabel.font = style.detailStyle?.font
      _label.textColor = style.nameStyle.color
      _textView.textColor = style.inputStyle.color
      _detailLabel.textColor = style.detailStyle?.color
      _textView.backgroundColor = style.inputBackgroundColor
      
      _textView.tintColor = style.inputStyle.color
      
      _textView.placeholder = content.placeholder ?? ""
      _textView.placeholderFont = style.placeholderStyle?.font
      _textView.placeholderColor = style.placeholderStyle?.color ?? .black
      <commit_msg>Added keyboard styling to TextViewInputElementCell.<commit_after>//
//  TextViewElementCell.swift
//  Elemental
//
//  Created by <NAME> on 2/23/17.
//  Copyright © 2017 Incipia. All rights reserved.
//

import UIKit

class TextViewInputElementCell: BindableElementCell {
   @IBOutlet private var _label: UILabel!
   @IBOutlet private var _detailLabel: UILabel!
   @IBOutlet private var _labelVerticalSpaceConstraint: NSLayoutConstraint!
   @IBOutlet private var _detailLabelVerticalSpaceConstraint: NSLayoutConstraint!
   @IBOutlet fileprivate var _textView: PlaceholderTextView!
   @IBOutlet private var _textFieldHeightConstraint: NSLayoutConstraint!
   
   fileprivate var _action: InputElementAction?
   fileprivate var _isEnabled: Bool {
      get { return _textView.isEditable }
      set {
         if !newValue, _textView.isFirstResponder {
            _textView.resignFirstResponder()
         }
         _textView.isEditable = newValue
         _textView.isSelectable = newValue
      }
   }

   static var bindableKeys: [BindableElementKey] { return [.text, .isEnabled] }

   override func awakeFromNib() {
      super.awakeFromNib()
      _textView.textContainerInset = UIEdgeInsets(top: 16, left: 12, bottom: 16, right: 12)
      _textView.delegate = self
   }
   
   override func configure(with component: Elemental) {
      super.configure(with: component)
      guard let element = component as? TextViewInputElement else { fatalError() }
      let content = element.content
      let style = element.configuration
      let action = element.action
      _label.text = content.name
      _detailLabel.text = content.detail
      _label.font = style.nameStyle.font
      _textView.font = style.inputStyle.font
      _detailLabel.font = style.detailStyle?.font
      _label.textColor = style.nameStyle.color
      _textView.textColor = style.inputStyle.color
      _detailLabel.textColor = style.detailStyle?.color
      _textView.backgroundColor = style.inputBackgroundColor
      
      _textView.keyboardType = style.keyboardStyle.type
      _textView.keyboardAppearance = style.keyboardStyle.appearance
      _textView.isSecureTextEntry = style.keyboardStyle.isSecureTextEntry
      _textView.autocapitalizationType = style.keyboardStyle.autocapitalizationType
      _textView.returnKeyType = style.keyboardStyle.returnKeyType
      _textView.tintColor = style.inputTintColor ?? style.inputStyle.color
      
      _textView.placeholder = content.placeholder ?? ""
      _textView.placeholderFont = style.placeholderStyle?.font
      _textView.placeholderColor = style.placeholderStyle?.color ?? .black
      
{'fraction_non_alphanumeric': 0.07797029702970297, 'fraction_numerical': 0.007013201320132013, 'mean_word_length': 3.3256021409455845, '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': '6739155', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1370, 'n_words': 301}