Contents

rillieux/photoselectandcrop

Photo Select and Crop

Implementation

Add an ImagePane view to your parent view like this:

ImagePane(image: image, isEditMode: $isEditMode, renderingMode: renderingMode, colors: colors)

<img align="right" src="Screenshots/coreDataEntity.png" width="60%">

Using CoreData, one might do the following. Define two entities: Contact and ProfileImage, where Contact has a To One relationship to ProfileImage. The ProfileImage entity should have properties that can be mapped to the variables provided to the ImageDisplay struct after the user has selected an image from their library.

Then, an ImageAttributes class should be initialized with the properties from the Core Data entity. This ImageAttributes class is then passed to the ImagePane as in the above code. For the nil case, a second ImageAttributes struct is initialzed, this time with a default image named avatar which was saved to the project's Image Assets folder.

An ImageAttributes object can easily be defined as a placeholder.

With an SF Symbol: let placeholderAperture = ImageAttributes(withSFSymbol: "camera.aperture")

With an image from the Assets folder: let placeholderAvatar = ImageAttributes(withImage: "avatar")

Examples of working apps using this Package can be found at: https://github.com/Rillieux/Contacts (using CoreData), and https://github.com/Rillieux/PhotoSelectAndCropDemo (a basic working implementation which does not cover persistence).

Package Metadata

Repository: rillieux/photoselectandcrop

Default branch: main

README: README.md