ImageCollectionViewController
class ImageCollectionViewController : UICollectionViewController
Undocumented
-
An array of
UIImage
objects to display.Declaration
Swift
var images: [UIImage]
-
A label that apppears if there are no images.
Todo
use closure syntax to set it up at declarationTodo
make private and lazyDeclaration
Swift
var noImagesLabel: UILabel
-
The currently selected index.
This is mainly used for interactions with a
ImagePagingCollectionViewController
Declaration
Swift
var currentIndex: Int
-
An object that manages the array of
Plant
objects.Declaration
Swift
var plantsManager: PlantsManager!
-
The number of images in a row
Todo
make privateDeclaration
Swift
let numberOfImagesPerRow: CGFloat
-
The spacing between images.
Todo
make privateDeclaration
Swift
let spacingBetweenCells: CGFloat
-
A
boolean
indicating whether multiple cells be selected. The selected images can then be shared or deleted.Todo
make privateDeclaration
Swift
var inMultiSelectMode: Bool { get set }
-
Indices of selected images.
Todo
make privateDeclaration
Swift
var selectedImageIndices: [Int]
-
The standard title to use when not in multi-select mode (
inMultiSelectMode == false
). It is set to the sameString
asself.title
inviewDidLoad()
.Declaration
Swift
var standardTitle: String?
-
Undocumented
Declaration
Swift
override func viewDidLoad()
-
Load the images of a plant into
images: [UIImage]
. It is called once during set up and when the user is done selecting new images.Todo
experiment with loading the images incellForRowAt:
Todo
make privateDeclaration
Swift
func loadImages()
-
Undocumented
Declaration
Swift
override func viewWillAppear(_ animated: Bool)
-
Undocumented
Declaration
Swift
override func viewWillDisappear(_ animated: Bool)
-
An action sheet is presented to imort or edit images.
Declaration
Swift
@objc func editButtonTapped()
-
Undocumented
Declaration
Swift
override func numberOfSections(in collectionView: UICollectionView) -> Int
-
Undocumented
Declaration
Swift
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
-
Undocumented
Declaration
Swift
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
-
Undocumented
Declaration
Swift
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
-
Undocumented
Declaration
Swift
override func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath)
-
Add images to the plant using
PlantAssetsPickerViewController
.self
is set as the delegate.Declaration
Swift
@objc func addImages(_ alert: UIAlertAction)
Parameters
alert
The alert action that called the function (not used).
-
This function is called when the user is done selecting images. It saves the plants, loads the images into
images: [UIImage]
and reloads the data.Declaration
Swift
func didFinishSelecting(assetPicker: PlantAssetsPickerViewController)
Parameters
assetPicker
The
PlantAssetsPickerViewController
that called the function.
-
Organize the tool bar for multi-select mode. The tool bar will have a trash and a share icons for deleting or sharing images.
Declaration
Swift
func setupToolbar()
-
Called to turn on miltu-select mode by setting
inMultiSelectMode
totrue
.Declaration
Swift
@objc func selectMultipleImages(_ alert: UIAlertAction)
Parameters
alert
The alert action that called the function (not used).
-
Delete the currently selected images. The images are deleted from
images: [UIImage]
, theplant.images: [String]
, removed from disk And from the collection view. The deletion is animated by callingcollectionView.deleteItems(at: [IndexPath])
.Declaration
Swift
@objc func deleteSelectedImages(_ alert: UIAlertAction)
Parameters
alert
The alert action that called the function (not used).
-
Share the currently selected images using the satandard
UIActivityViewController(activityItems:applicationActivities:)
.Declaration
Swift
@objc func shareSelectedImages(_ alert: UIAlertAction)
Parameters
alert
The alert action that called the function (not used).
-
Deactivate multi-select mode by setting
inMultiSelectMode
tofalse
.Declaration
Swift
@objc func exitMultiSelectionMode(_ alert: UIAlertAction)
-
Undocumented
Declaration
Swift
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize
-
Undocumented
Declaration
Swift
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat
-
Undocumented
Declaration
Swift
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat
-
Undocumented
Declaration
Swift
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool
-
Undocumented
Declaration
Swift
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
-
Declaration
Swift
func transitionWillStartWith(zoomAnimator: ZoomAnimator)
-
Declaration
Swift
func transitionDidEndWith(zoomAnimator: ZoomAnimator)
-
Retrieve the cell at
currentIndex
for a zoom animation.Declaration
Swift
func getCell(for zoomAnimator: ZoomAnimator) -> ImageCollectionViewCell?
Parameters
zoomAnimator
The
ZoomAnimator
object organizing the transition animation. -
Declaration
Swift
func referenceImageView(for zoomAnimator: ZoomAnimator) -> UIImageView?
-
Declaration
Swift
func referenceImageViewFrameInTransitioningView(for zoomAnimator: ZoomAnimator) -> CGRect?
-
Respond to a change in index of the current image when in the paging view.
Todo
change name of first parameter to
imagePagingCollectionViewController
Declaration
Swift
func containerViewController(_ containerViewController: ImagePagingCollectionViewController, indexDidChangeTo currentIndex: Int)
Parameters
containerViewController
The view controller that called the function.
currentIndex
The index of the paging view controller.
self.currentIndex
is assigned this value to stay in sync. -
A notification from the
ImagePagingCollectionViewController
to delete the image at an index.Note
The image is already deleted from the plant, erased from disk, and removed from
images: [UIImage]
. The only task to be done, here, is to remove the image from the collection view usingcollectionView.deleteItems(at: [IndexPath])
.Todo
add first paramter as
_ containerViewController: ImagePagingCollectionViewController
Declaration
Swift
func removeCell(at index: Int)
Parameters
index
Index at which to delete the image.
-
Set the profile or the
plant: Plant
using the image at the specified index ofimages: [UIImage]
.Declaration
Swift
func setProfileAs(imageAt index: Int)
Parameters
index
index of
images: [UIImage]
for which to pull the image for the profile image. -
Delete an image from
plant: Plant
at the specific index.Declaration
Swift
func deleteImage(at index: Int)
Parameters
index
index of
images: [UIImage]
and theplant: Plant
object’s image array. -
Save changes to an image at the specific index.
Note
The image is replaced, not appended. Therefore, it retains the same file name and UUID. Therefore, anything that references this image (eg. the header image) will be affected by the change.
Declaration
Swift
func save(image: UIImage, withIndex index: Int)
Parameters
image
The new (edited) image to replace the old one with.
index
The index of the image being replaced.