Skip to content

Commit

Permalink
[Dialogs] Adding dynamic type to accessory view examples
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 319075226
  • Loading branch information
galiak11 authored and material-automation committed Jun 30, 2020
1 parent 6b124ad commit 6f1b595
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ class DialogsAccessoryExampleViewController: MDCCollectionViewController {
namefield.clearButtonMode = UITextField.ViewMode.whileEditing
namefield.leadingAssistiveLabel.text = "An optional assistive message"
namefield.applyTheme(withScheme: containerScheme)
if #available(iOS 10.0, *) {
// Enable dynamic type.
namefield.adjustsFontForContentSizeCategory = true
namefield.font = UIFont.preferredFont(
forTextStyle: .body, compatibleWith: namefield.traitCollection)
namefield.leadingAssistiveLabel.font = UIFont.preferredFont(
forTextStyle: .caption2, compatibleWith: namefield.traitCollection)
}

label.translatesAutoresizingMaskIntoConstraints = false
namefield.translatesAutoresizingMaskIntoConstraints = false
Expand All @@ -115,6 +123,7 @@ class DialogsAccessoryExampleViewController: MDCCollectionViewController {
namefield.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true

alert.accessoryView = view
alert.mdc_adjustsFontForContentSizeCategory = true // Enable dynamic type.
alert.applyTheme(withScheme: self.containerScheme)
return alert
}
Expand All @@ -125,6 +134,7 @@ class DialogsAccessoryExampleViewController: MDCCollectionViewController {
textField.placeholder = "This is a text field"
alert.accessoryView = textField
alert.addAction(MDCAlertAction(title: "Dismiss", emphasis: .medium, handler: handler))
alert.mdc_adjustsFontForContentSizeCategory = true // Enable dynamic type.
alert.applyTheme(withScheme: self.containerScheme)
return alert
}
Expand Down Expand Up @@ -158,6 +168,7 @@ class DialogsAccessoryExampleViewController: MDCCollectionViewController {
button.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true

alert.accessoryView = view
alert.mdc_adjustsFontForContentSizeCategory = true // Enable dynamic type.
alert.applyTheme(withScheme: self.containerScheme)

return alert
Expand Down

0 comments on commit 6f1b595

Please sign in to comment.