forked from microsoft/fluentui-apple
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contact collection large text accessibility support, bug fixes and sm…
…all size (microsoft#193) * added small size for colletion view * Improvements * size fix * Large text AX support * Refactoring * more explicit comment Co-authored-by: Mathieu Kavalec <[email protected]>
- Loading branch information
1 parent
d38fa9c
commit fe45056
Showing
6 changed files
with
385 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,25 +6,97 @@ | |
import FluentUI | ||
import UIKit | ||
|
||
class ContactCollectionViewDemoController: UIViewController { | ||
private let contactCollectionView = ContactCollectionView() | ||
|
||
class ContactCollectionViewDemoController: DemoController { | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
view.backgroundColor = Colors.surfacePrimary | ||
view.backgroundColor = Colors.surfaceSecondary | ||
|
||
let largeTitleLabel = createlabel(text: "Large") | ||
scrollingContainer.addSubview(largeTitleLabel) | ||
|
||
let largeCollectionView = ContactCollectionView(personas: personas) | ||
largeCollectionView.contactCollectionViewDelegate = self | ||
largeCollectionView.translatesAutoresizingMaskIntoConstraints = false | ||
scrollingContainer.addSubview(largeCollectionView) | ||
|
||
contactCollectionView.contactCollectionViewDelegate = self | ||
contactCollectionView.translatesAutoresizingMaskIntoConstraints = false | ||
contactCollectionView.contactList = samplePersonas | ||
let smallTitleLabel = createlabel(text: "Small") | ||
scrollingContainer.addSubview(smallTitleLabel) | ||
|
||
view.addSubview(contactCollectionView) | ||
let smallCollectionView = ContactCollectionView(size: .small, personas: personas) | ||
smallCollectionView.contactCollectionViewDelegate = self | ||
smallCollectionView.translatesAutoresizingMaskIntoConstraints = false | ||
scrollingContainer.addSubview(smallCollectionView) | ||
|
||
let stackView = UIStackView(frame: .zero) | ||
stackView.translatesAutoresizingMaskIntoConstraints = false | ||
stackView.axis = .vertical | ||
stackView.spacing = Constants.spacing | ||
stackView.alignment = .center | ||
scrollingContainer.addSubview(stackView) | ||
|
||
stackView.addArrangedSubview(createlabel(text: "Large")) | ||
stackView.addArrangedSubview(ContactView(identifier: "Kat Larrson")) | ||
stackView.addArrangedSubview(ContactView(title: "Kristin", subtitle: "Patterson")) | ||
stackView.addArrangedSubview(createlabel(text: "Small")) | ||
stackView.addArrangedSubview(ContactView(identifier: "Kat Larrson", size: .small)) | ||
stackView.addArrangedSubview(ContactView(title: "Kristin", subtitle: "Patterson", size: .small)) | ||
|
||
NSLayoutConstraint.activate([ | ||
contactCollectionView.topAnchor.constraint(equalTo: view.topAnchor, constant: 20), | ||
contactCollectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), | ||
contactCollectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor) | ||
largeTitleLabel.topAnchor.constraint(equalTo: scrollingContainer.topAnchor, constant: Constants.spacing), | ||
largeTitleLabel.leadingAnchor.constraint(equalTo: scrollingContainer.leadingAnchor, constant: Constants.leadingSpacing), | ||
largeCollectionView.topAnchor.constraint(equalTo: largeTitleLabel.bottomAnchor, constant: Constants.spacing), | ||
largeCollectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), | ||
largeCollectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), | ||
smallTitleLabel.topAnchor.constraint(equalTo: largeCollectionView.bottomAnchor, constant: Constants.spacing), | ||
smallTitleLabel.leadingAnchor.constraint(equalTo: scrollingContainer.leadingAnchor, constant: Constants.leadingSpacing), | ||
smallCollectionView.topAnchor.constraint(equalTo: smallTitleLabel.bottomAnchor, constant: Constants.spacing), | ||
smallCollectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), | ||
smallCollectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), | ||
stackView.leadingAnchor.constraint(equalTo: scrollingContainer.leadingAnchor, constant: Constants.leadingSpacing), | ||
stackView.topAnchor.constraint(equalTo: smallCollectionView.bottomAnchor, constant: Constants.spacing), | ||
stackView.bottomAnchor.constraint(equalTo: scrollingContainer.bottomAnchor) | ||
]) | ||
} | ||
|
||
private func createlabel(text: String) -> Label { | ||
let label = Label(style: .title2) | ||
label.translatesAutoresizingMaskIntoConstraints = false | ||
label.text = text | ||
|
||
return label | ||
} | ||
|
||
private struct Constants { | ||
static let spacing: CGFloat = 20 | ||
static let leadingSpacing: CGFloat = 30 | ||
} | ||
|
||
private let personas: [PersonaData] = [ | ||
PersonaData(firstName: "Kat", lastName: "Larrson", avatarImage: UIImage(named: "avatar_kat_larsson")), | ||
PersonaData(firstName: "Ashley", lastName: "McCarthy", avatarImage: UIImage(named: "avatar_ashley_mccarthy")), | ||
PersonaData(firstName: "Allan", lastName: "Munger", avatarImage: UIImage(named: "avatar_allan_munger")), | ||
PersonaData(firstName: "Amanda", lastName: "Brady", avatarImage: UIImage(named: "avatar_amanda_brady")), | ||
PersonaData(firstName: "Kevin", lastName: "Sturgis"), | ||
PersonaData(firstName: "Lydia", lastName: "Bauer", avatarImage: UIImage(named: "avatar_lydia_bauer")), | ||
PersonaData(firstName: "Robin", lastName: "Counts"), | ||
PersonaData(firstName: "Tim", lastName: "Deboer", avatarImage: UIImage(named: "avatar_tim_deboer")), | ||
PersonaData(firstName: "Daisy", lastName: "Phillips", avatarImage: UIImage(named: "avatar_daisy_phillips")), | ||
PersonaData(firstName: "Mona", lastName: "Kane", email: "[email protected]"), | ||
PersonaData(firstName: "Elvia", lastName: "Atkins", avatarImage: UIImage(named: "avatar_elvia_atkins")), | ||
PersonaData(firstName: "Johnie", lastName: "McConnell", subtitle: "Designer", avatarImage: UIImage(named: "avatar_johnie_mcconnell")), | ||
PersonaData(firstName: "Charlotte", lastName: "Waltsson"), | ||
PersonaData(firstName: "Mauricio", lastName: "August", avatarImage: UIImage(named: "avatar_mauricio_august")), | ||
PersonaData(firstName: "Robert", lastName: "Tolbert", avatarImage: UIImage(named: "avatar_robert_tolbert")), | ||
PersonaData(firstName: "Isaac", lastName: "Fielder", avatarImage: UIImage(named: "avatar_isaac_fielder")), | ||
PersonaData(firstName: "Carole", lastName: "Poland"), | ||
PersonaData(firstName: "Elliot", lastName: "Woodward"), | ||
PersonaData(firstName: "Henry", lastName: "Brill", avatarImage: UIImage(named: "avatar_henry_brill")), | ||
PersonaData(firstName: "Cecil", lastName: "Folk", avatarImage: UIImage(named: "avatar_cecil_folk")), | ||
PersonaData(name: "Katri Ahokas", avatarImage: UIImage(named: "avatar_katri_ahokas")), | ||
PersonaData(name: "Colin Ballinger", email: "[email protected]", avatarImage: UIImage(named: "avatar_colin_ballinger")), | ||
PersonaData(email: "[email protected]"), | ||
PersonaData(email: "[email protected]", subtitle: "Software Engineer") | ||
] | ||
} | ||
|
||
extension ContactCollectionViewDemoController: ContactCollectionViewDelegate { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.