2019-12-19 17:32:49 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
|
*
|
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2018-11-01 17:56:41 +00:00
|
|
|
*/
|
2017-09-01 20:49:12 +00:00
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
|
|
|
|
|
protocol UserCollectionViewCellDelegate: class {
|
2017-12-19 17:23:37 +00:00
|
|
|
|
2017-09-01 20:49:12 +00:00
|
|
|
func itemDeleted(_ user: User)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final class UserCollectionViewCell: NSCollectionViewItem {
|
2017-12-19 17:23:37 +00:00
|
|
|
|
2017-09-01 20:49:12 +00:00
|
|
|
weak var delegate: UserCollectionViewCellDelegate?
|
2017-12-19 17:23:37 +00:00
|
|
|
|
2017-09-01 20:49:12 +00:00
|
|
|
@IBAction func deleteButtonClicked(_ sender: AnyObject) {
|
|
|
|
|
guard let user = representedObject as? User else { return }
|
|
|
|
|
delegate?.itemDeleted(user)
|
|
|
|
|
}
|
2017-12-19 17:23:37 +00:00
|
|
|
|
2017-09-01 20:49:12 +00:00
|
|
|
func bindViewModel(_ user: User) {
|
|
|
|
|
representedObject = user
|
|
|
|
|
textField?.stringValue = user.name
|
|
|
|
|
}
|
|
|
|
|
}
|