<commit_before>// Copyright 2017-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import UIKit

import MaterialComponents.MaterialButtons
import MaterialComponentsBeta.MaterialButtons_Theming
import MaterialComponentsBeta.MaterialContainerScheme

class ButtonsDynamicTypeViewController: UIViewController {

  class func catalogMetadata() -> [String: Any] {
    return [
      "breadcrumbs": ["Buttons", "Buttons (DynamicType)"],
      "primaryDemo": false,
      "presentable": false,
      "debug": true, 
    ]
  }

  var containerScheme = MDCContainerScheme()

  override func viewDidLoad() {
    super.viewDidLoad()

    view.backgroundColor = UIColor(white: 0.9, alpha:1.0)
    let titleColor = UIColor.white
    let backgroundColor = UIColor(white: 0.1, alpha: 1.0)

    let flatButtonStatic = MDCButton()
    flatButtonStatic.applyContainedTheme(withScheme: containerScheme)
    flatButtonStatic.setTitleColor(titleColor, for: .normal)
    flatButtonStatic.setBackgroundColor(backgroundColor, for: .normal)
    flatButtonStatic.setTitle("Static", for: UIControlState())
    flatButtonStatic.sizeToFit()
    flatButtonStatic.translatesAutoresizingMaskIntoConstraints = false
    flatButtonStatic.addTarget(self, action: #selector(tap), for: .touchUpInside)
    view.addSubview(flatButtonStatic)

    containerScheme.typographyScheme = MDCTypographyScheme.init(defaults: .material201902)
    let flatButtonDynamic = MDCButton()
    flatButtonDynamic.applyContainedTheme(withScheme: containerScheme)
    flatButtonDynamic.setTitleColor(titleColor, for: .normal)
    flatButtonDynamic.setBackgroundColor(backgroundColor, for: .normal)
    flatButtonDynamic.setTitle("Dynamic", for: UIControlState())
    flatButtonDynamic.sizeToFit()
    flatButtonDynamic.translatesAutoresizingMaskIntoConstraints = false
    flatButtonDynamic.addTarget(self, action: #selector(tap), for: .touchUpInside)
    flatButtonDynamic.mdc_adjustsFontForContentSizeCategory = true
    view.addSubview(flatButtonDynamic)

    containerScheme.typographyScheme = MDCTypographyScheme.init(defaults: .material201804)
    let flatButtonDynamicLegacy = MDCButton()
    flatButtonDynamicLegacy.applyContainedTheme(withScheme: containerScheme)
    flatButtonDynamicLegacy.setTitleColor(titleColor, for: .normal)
    flatButtonDynamicLegacy.setBackgroundColor(backgroundColor, for: .normal)
    flatButtonDynamicLegacy.setTitle("Dynamic (legacy)", for: UIControlState())
    flatButtonDynamicLegacy.sizeToFit()
    flatButtonDynamicLegacy.translatesAutoresizingMaskIntoConstraints = false
    flatButtonDynamicLegacy.addTarget(self, action: #selector(tap), for: .touchUpInside)
    flatButtonDynamicLegacy.mdc_adjustsFontForContentSizeCategory = true
    flatButtonDynamicLegacy.mdc_legacyFontScaling = true
    view.addSubview(flatButtonDynamicLegacy)

    let views = [
      "flatStatic": flatButtonStatic,
      "flatDynamic": flatButtonDynamic,
      "flatDynamicLegacy": flatButtonDynamicLegacy,
    ]

    centerView(view: flatButtonDynamic, onView: self.view)

    view.addConstraints(
      NSLayoutConstraint.constraints(withVisualFormat:
          "V:[flatStatic]-40-[flatDynamic]-40-[flatDynamicLegacy]",
              options: .alignAllCenterX, metrics: nil, views: views))
  }

  // MARK: Private

  func centerView(view: UIView, onView: UIView) {
    onView.addConstraint(NSLayoutConstraint(
      item: view,
      attribute: .centerX,
      relatedBy: .equal,
      toItem: onView,
      attribute: .centerX,
      multiplier: 1.0,
      constant: 0.0))

    onView.addConstraint(NSLayoutConstraint(
      item: view,
      attribute: .centerY,
      relatedBy: .equal,
      toItem: onView,
      attribute: .centerY,
      multiplier: 1.0,
      constant: 0.0))
  }

  @objc func tap(_ sender: Any) {
    print("\(type(of: sender)) was tapped.")
  }

}
<commit_msg>[Buttons] Don't make Buttons example launch screen. (#7016)<commit_after>// Copyright 2017-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import UIKit

import MaterialComponents.MaterialButtons
import MaterialComponentsBeta.MaterialButtons_Theming
import MaterialComponentsBeta.MaterialContainerScheme

class ButtonsDynamicTypeViewController: UIViewController {

  class func catalogMetadata() -> [String: Any] {
    return [
      "breadcrumbs": ["Buttons", "Buttons (DynamicType)"],
      "primaryDemo": false,
      "presentable": false,
    ]
  }

  var containerScheme = MDCContainerScheme()

  override func viewDidLoad() {
    super.viewDidLoad()

    view.backgroundColor = UIColor(white: 0.9, alpha:1.0)
    let titleColor = UIColor.white
    let backgroundColor = UIColor(white: 0.1, alpha: 1.0)

    let flatButtonStatic = MDCButton()
    flatButtonStatic.applyContainedTheme(withScheme: containerScheme)
    flatButtonStatic.setTitleColor(titleColor, for: .normal)
    flatButtonStatic.setBackgroundColor(backgroundColor, for: .normal)
    flatButtonStatic.setTitle("Static", for: UIControlState())
    flatButtonStatic.sizeToFit()
    flatButtonStatic.translatesAutoresizingMaskIntoConstraints = false
    flatButtonStatic.addTarget(self, action: #selector(tap), for: .touchUpInside)
    view.addSubview(flatButtonStatic)

    containerScheme.typographyScheme = MDCTypographyScheme.init(defaults: .material201902)
    let flatButtonDynamic = MDCButton()
    flatButtonDynamic.applyContainedTheme(withScheme: containerScheme)
    flatButtonDynamic.setTitleColor(titleColor, for: .normal)
    flatButtonDynamic.setBackgroundColor(backgroundColor, for: .normal)
    flatButtonDynamic.setTitle("Dynamic", for: UIControlState())
    flatButtonDynamic.sizeToFit()
    flatButtonDynamic.translatesAutoresizingMaskIntoConstraints = false
    flatButtonDynamic.addTarget(self, action: #selector(tap), for: .touchUpInside)
    flatButtonDynamic.mdc_adjustsFontForContentSizeCategory = true
    view.addSubview(flatButtonDynamic)

    containerScheme.typographyScheme = MDCTypographyScheme.init(defaults: .material201804)
    let flatButtonDynamicLegacy = MDCButton()
    flatButtonDynamicLegacy.applyContainedTheme(withScheme: containerScheme)
    flatButtonDynamicLegacy.setTitleColor(titleColor, for: .normal)
    flatButtonDynamicLegacy.setBackgroundColor(backgroundColor, for: .normal)
    flatButtonDynamicLegacy.setTitle("Dynamic (legacy)", for: UIControlState())
    flatButtonDynamicLegacy.sizeToFit()
    flatButtonDynamicLegacy.translatesAutoresizingMaskIntoConstraints = false
    flatButtonDynamicLegacy.addTarget(self, action: #selector(tap), for: .touchUpInside)
    flatButtonDynamicLegacy.mdc_adjustsFontForContentSizeCategory = true
    flatButtonDynamicLegacy.mdc_legacyFontScaling = true
    view.addSubview(flatButtonDynamicLegacy)

    let views = [
      "flatStatic": flatButtonStatic,
      "flatDynamic": flatButtonDynamic,
      "flatDynamicLegacy": flatButtonDynamicLegacy,
    ]

    centerView(view: flatButtonDynamic, onView: self.view)

    view.addConstraints(
      NSLayoutConstraint.constraints(withVisualFormat:
          "V:[flatStatic]-40-[flatDynamic]-40-[flatDynamicLegacy]",
              options: .alignAllCenterX, metrics: nil, views: views))
  }

  // MARK: Private

  func centerView(view: UIView, onView: UIView) {
    onView.addConstraint(NSLayoutConstraint(
      item: view,
      attribute: .centerX,
      relatedBy: .equal,
      toItem: onView,
      attribute: .centerX,
      multiplier: 1.0,
      constant: 0.0))

    onView.addConstraint(NSLayoutConstraint(
      item: view,
      attribute: .centerY,
      relatedBy: .equal,
      toItem: onView,
      attribute: .centerY,
      multiplier: 1.0,
      constant: 0.0))
  }

  @objc func tap(_ sender: Any) {
    print("\(type(of: sender)) was tapped.")
  }

}

{'fraction_non_alphanumeric': 0.0929054054054054, 'fraction_numerical': 0.00945945945945946, 'mean_word_length': 4.3955042527339, 'pattern_counts': {'":': 13, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3436186', 'n_tokens_mistral': 2566, 'n_tokens_neox': 2477, 'n_words': 577}