mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-06 15:08:50 +00:00
30 lines
694 B
Swift
30 lines
694 B
Swift
|
|
//
|
||
|
|
// UserCollectionViewCell.swift
|
||
|
|
// IGListKitExamples
|
||
|
|
//
|
||
|
|
// Created by Weyert de Boer on 27/08/2017.
|
||
|
|
// Copyright © 2017 Instagram. All rights reserved.
|
||
|
|
//
|
||
|
|
|
||
|
|
import Cocoa
|
||
|
|
|
||
|
|
protocol UserCollectionViewCellDelegate: class {
|
||
|
|
|
||
|
|
func itemDeleted(_ user: User)
|
||
|
|
}
|
||
|
|
|
||
|
|
final class UserCollectionViewCell: NSCollectionViewItem {
|
||
|
|
|
||
|
|
weak var delegate: UserCollectionViewCellDelegate?
|
||
|
|
|
||
|
|
@IBAction func deleteButtonClicked(_ sender: AnyObject) {
|
||
|
|
guard let user = representedObject as? User else { return }
|
||
|
|
delegate?.itemDeleted(user)
|
||
|
|
}
|
||
|
|
|
||
|
|
func bindViewModel(_ user: User) {
|
||
|
|
representedObject = user
|
||
|
|
textField?.stringValue = user.name
|
||
|
|
}
|
||
|
|
}
|