Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor configs and add zoom scale limitation settings #184

Merged
merged 6 commits into from
Jul 20, 2022

Conversation

guoyingtao
Copy link
Owner

split config into 3 config files
put dial config into CropView Config
add Global.swift

split config into 3 config files
put dial config into CropView Config
add Global.swift
Copy link
Collaborator

@vanniktech vanniktech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. I did want to try this out but I'm getting:


Showing Recent Messages
Unable to load contents of file list: '/Target Support Files/Pods-MantisExample/Pods-MantisExample-frameworks-Debug-input-files.xcfilelist'

Unable to load contents of file list: '/Target Support Files/Pods-MantisExample/Pods-MantisExample-frameworks-Debug-output-files.xcfilelist'

Also it's not really clear to me which xworkspace file I should open. Sorry for that, I'm coming originally from Android.

@@ -76,8 +75,8 @@ extension EmbeddedCropViewController: CropViewControllerDelegate {
}

func cropViewControllerDidEndResize(_ cropViewController: CropViewController, original: UIImage, cropInfo: CropInfo) {
let croppedImage = Mantis.crop(image: original, by: cropInfo)
self.resolutionLabel.text = getResolution(image: croppedImage)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the Int(size.width) + 1?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's ceiling the value, right? If so should not we do this in the library itself? So that as a consumer you can just use size.width

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I am using floor() to get output image size, it might be one pixel different from what we expect. I think if user want to limit crop size, for the upper limit, user should use `Int(size.width) + 1` and `Int(size.height) + 1` to make sure the output size is in the valid range.

I will update code to make it less confusing.

Sources/Mantis/Config.swift Show resolved Hide resolved
Sources/Mantis/Config.swift Outdated Show resolved Hide resolved
Sources/Mantis/CropView/CropView+Touches.swift Outdated Show resolved Hide resolved
Sources/Mantis/CropView/CropView.swift Outdated Show resolved Hide resolved
public var hotAreaUnit: CGFloat = 32
public var cropShapeType: CropShapeType = .rect
public var cropVisualEffectType: CropVisualEffectType = .blurDark
public var minimumZoomScale: CGFloat = 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 1 really the lower bound or can we go even further down (e.g. 0.5), if so, I think we should document it.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially only zoom in is allowed (otherwise the crop box will be bigger than the image), so I think it is reasonable to set minimumZoomScale to 1, although it might be changed later.

Sources/Mantis/CropViewConfig.swift Outdated Show resolved Hide resolved
Sources/Mantis/CropViewConfig.swift Outdated Show resolved Hide resolved
Sources/Mantis/CropViewConfig.swift Outdated Show resolved Hide resolved
Sources/Mantis/CropViewConfig.swift Outdated Show resolved Hide resolved
guoyingtao and others added 5 commits July 19, 2022 07:23
Co-authored-by: Niklas Baudy <niklas.baudy@vanniktech.de>
Co-authored-by: Niklas Baudy <niklas.baudy@vanniktech.de>
Co-authored-by: Niklas Baudy <niklas.baudy@vanniktech.de>
Co-authored-by: Niklas Baudy <niklas.baudy@vanniktech.de>
Copy link
Collaborator

@vanniktech vanniktech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks juicy! Thanks ❤️

@@ -37,7 +37,7 @@ public enum PresetFixedRatioType {
case canUseMultiplePresetFixedRatio(defaultRatio: Double = 0)
}

public enum CropVisualEffectType {
public enum CropMaskVisualEffectType {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the new name!

@guoyingtao guoyingtao merged commit a46341d into master Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants