Skip to content

Instantly share code, notes, and snippets.

@shawnbierman
Created July 22, 2019 17:47
Show Gist options
  • Save shawnbierman/b71c162656eb19c25c8205b8177a3c25 to your computer and use it in GitHub Desktop.
Save shawnbierman/b71c162656eb19c25c8205b8177a3c25 to your computer and use it in GitHub Desktop.
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if let cell = collectionView.cellForItem(at: indexPath) as? ClinicianViewCell {
let clinician = clinicians[indexPath.item]
UIView.animate(withDuration: 0.1, delay: 0, options: [], animations: { [weak self] in
cell.transform = CGAffineTransform(scaleX: 0.95, y: 0.95)
cell.clinicianState.transform = CGAffineTransform(scaleX: 1, y: -1)
cell.photoImageView.transform = CGAffineTransform(translationX: -3, y: 3)
cell.taskItem.transform = CGAffineTransform(translationX: -4, y: 4)
cell.clinicianName.transform = CGAffineTransform(translationX: -3, y: -3)
AudioServicesPlaySystemSound (self!.systemSoundID)
}) { _ in
UIView.animate(withDuration: 0.2, animations: { [weak self] in
[cell, cell.photoImageView, cell.clinicianState, cell.taskItem, cell.clinicianName].forEach { $0.transform = .identity }
if cell.clinicianState.text == ClinicianState.assigned.rawValue {
cell.clinicianState.text = ClinicianState.inWithPatient.rawValue
self?.changeClinicianState(to: ClinicianState.inWithPatient, for: clinician.id, at: indexPath)
} else if cell.clinicianState.text == ClinicianState.inWithPatient.rawValue {
cell.clinicianState.text = ClinicianState.checkedOut.rawValue
self?.changeClinicianState(to: .checkedOut, for: clinician.id, at: indexPath)
} else {
cell.clinicianState.text = ClinicianState.inWithPatient.rawValue
self?.changeClinicianState(to: .inWithPatient, for: clinician.id, at: indexPath)
}
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment