Skip to content

Commit

Permalink
chore: Fix typos (#307)
Browse files Browse the repository at this point in the history
* Fix typos

* Fix typos
  • Loading branch information
woxtu committed May 22, 2023
1 parent cdb7117 commit a2a48e2
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 87 deletions.
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -54,7 +54,7 @@ github "guoyingtao/Mantis"
<details>
<summary><strong>Swift Packages</strong></summary>

* Respository: https://github.com/guoyingtao/Mantis.git
* Repository: https://github.com/guoyingtao/Mantis.git
* Rules: Version - Exact - 2.9.1

</details>
Expand All @@ -80,7 +80,7 @@ public protocol CropViewControllerDelegate: class {
func cropViewControllerDidCrop(_ cropViewController: CropViewController, cropped: UIImage, transformation: Transformation, cropInfo: CropInfo)
func cropViewControllerDidCancel(_ cropViewController: CropViewController, original: UIImage)

// The implementaion of the following functions are optional
// The implementation of the following functions are optional
func cropViewControllerDidFailToCrop(_ cropViewController: CropViewController, original: UIImage)
func cropViewControllerDidBeginResize(_ cropViewController: CropViewController)
func cropViewControllerDidEndResize(_ cropViewController: CropViewController, original: UIImage, cropInfo: CropInfo)
Expand Down Expand Up @@ -188,18 +188,18 @@ public enum CropShapeType {
public enum PresetTransformationType {
case none
case presetInfo(info: Transformation)
case presetNormalizedInfo(normailizedInfo: CGRect)
case presetNormalizedInfo(normalizedInfo: CGRect)
}
```
Please use the transformation infomation obtained previously from delegate method cropViewControllerDidCrop(_ cropViewController: CropViewController, cropped: UIImage, transformation: Transformation, , cropInfo: CropInfo).
Please use the transformation information obtained previously from delegate method cropViewControllerDidCrop(_ cropViewController: CropViewController, cropped: UIImage, transformation: Transformation, , cropInfo: CropInfo).

</details>
<details>
<summary><strong>Localization</strong></summary>

* UIKit project
Add more languages support to the Localizaions section for Project Info tab
Add more languages support to the Localizations section for Project Info tab

<p align="center">
<img src="https://user-images.githubusercontent.com/26723384/128650945-5a1da648-7e7d-4faf-9c95-232725b05dcc.png" height="200" alt="Mantis" />
Expand Down Expand Up @@ -236,7 +236,7 @@ Then you'll need to configure Mantis:
```
let config = Mantis.Config()
config.localizationConfig.bundle = // a bundle where strings file is located
config.localizationConfig.tableName = // a localizaed strings file name within the bundle
config.localizationConfig.tableName = // a localized strings file name within the bundle
```

</details>
Expand Down
2 changes: 1 addition & 1 deletion Sources/Mantis/CropData.swift
Expand Up @@ -29,7 +29,7 @@ public typealias Transformation = (
rotation: CGFloat,
scale: CGFloat,
manualZoomed: Bool,
intialMaskFrame: CGRect,
initialMaskFrame: CGRect,
maskFrame: CGRect,
cropWorkbenchViewBounds: CGRect
)
Expand Down
30 changes: 15 additions & 15 deletions Sources/Mantis/CropView/CropAuxiliaryIndicatorView.swift
Expand Up @@ -15,7 +15,7 @@ class CropAuxiliaryIndicatorView: UIView, CropAuxiliaryIndicatorViewProtocol {
private let edgeLineHandleLength = CGFloat(30.0)
private let handleThickness = CGFloat(3.0)
private let borderThickness = CGFloat(1.0)
private let hineLineThickness = CGFloat(2.0)
private let hintLineThickness = CGFloat(2.0)

private var hintLine = UIView()
private var tappedEdge: CropViewAuxiliaryIndicatorHandleType = .none
Expand Down Expand Up @@ -162,35 +162,35 @@ class CropAuxiliaryIndicatorView: UIView, CropAuxiliaryIndicatorViewProtocol {
}

private func layoutCornerHandles() {
let topLeftHorizonalLayerFrame = CGRect(x: -handleThickness, y: -handleThickness, width: cornerHandleLength, height: handleThickness)
let topLeftHorizontalLayerFrame = CGRect(x: -handleThickness, y: -handleThickness, width: cornerHandleLength, height: handleThickness)
let topLeftVerticalLayerFrame = CGRect(x: -handleThickness, y: -handleThickness, width: handleThickness, height: cornerHandleLength)

let horizontalDistanceForHCorner = bounds.width + 2 * handleThickness - cornerHandleLength
let verticalDistanceForHCorner = bounds.height + handleThickness
let horizontalDistanceForVCorner = bounds.width + handleThickness
let veticalDistanceForVCorner = bounds.height + 2 * handleThickness - cornerHandleLength
let verticalDistanceForVCorner = bounds.height + 2 * handleThickness - cornerHandleLength

for (index, line) in cornerHandles.enumerated() {
guard let lineType = CropAuxiliaryIndicatorView.CornerHandleType(rawValue: index) else {
continue
}
switch lineType {
case .topLeftHorizontal:
line.frame = topLeftHorizonalLayerFrame
line.frame = topLeftHorizontalLayerFrame
case .topLeftVertical:
line.frame = topLeftVerticalLayerFrame
case .topRightHorizontal:
line.frame = topLeftHorizonalLayerFrame.offsetBy(dx: horizontalDistanceForHCorner, dy: 0)
line.frame = topLeftHorizontalLayerFrame.offsetBy(dx: horizontalDistanceForHCorner, dy: 0)
case .topRightVertical:
line.frame = topLeftVerticalLayerFrame.offsetBy(dx: horizontalDistanceForVCorner, dy: 0)
case .bottomRightHorizontal:
line.frame = topLeftHorizonalLayerFrame.offsetBy(dx: horizontalDistanceForHCorner, dy: verticalDistanceForHCorner)
line.frame = topLeftHorizontalLayerFrame.offsetBy(dx: horizontalDistanceForHCorner, dy: verticalDistanceForHCorner)
case .bottomRightVertical:
line.frame = topLeftVerticalLayerFrame.offsetBy(dx: horizontalDistanceForVCorner, dy: veticalDistanceForVCorner)
line.frame = topLeftVerticalLayerFrame.offsetBy(dx: horizontalDistanceForVCorner, dy: verticalDistanceForVCorner)
case .bottomLeftHorizontal:
line.frame = topLeftHorizonalLayerFrame.offsetBy(dx: 0, dy: verticalDistanceForHCorner)
line.frame = topLeftHorizontalLayerFrame.offsetBy(dx: 0, dy: verticalDistanceForHCorner)
case .bottomLeftVertical:
line.frame = topLeftVerticalLayerFrame.offsetBy(dx: 0, dy: veticalDistanceForVCorner)
line.frame = topLeftVerticalLayerFrame.offsetBy(dx: 0, dy: verticalDistanceForVCorner)
}
}
}
Expand Down Expand Up @@ -250,21 +250,21 @@ class CropAuxiliaryIndicatorView: UIView, CropAuxiliaryIndicatorViewProtocol {
hintLine.frame = CGRect(x: borderLine.frame.minX,
y: borderLine.frame.minY,
width: borderLine.frame.width,
height: hineLineThickness)
height: hintLineThickness)
case .bottom:
hintLine.frame = CGRect(x: borderLine.frame.minX,
y: borderLine.frame.maxY - hineLineThickness,
y: borderLine.frame.maxY - hintLineThickness,
width: borderLine.frame.width,
height: hineLineThickness)
height: hintLineThickness)
case .left:
hintLine.frame = CGRect(x: borderLine.frame.minX,
y: borderLine.frame.minY,
width: hineLineThickness,
width: hintLineThickness,
height: borderLine.frame.height)
case .right:
hintLine.frame = CGRect(x: borderLine.frame.maxX - hineLineThickness,
hintLine.frame = CGRect(x: borderLine.frame.maxX - hintLineThickness,
y: borderLine.frame.minY,
width: hineLineThickness,
width: hintLineThickness,
height: borderLine.frame.height)
default:
break
Expand Down
40 changes: 20 additions & 20 deletions Sources/Mantis/CropView/CropView.swift
Expand Up @@ -605,7 +605,7 @@ extension CropView {
rotation: getTotalRadians(),
scale: cropWorkbenchView.zoomScale,
manualZoomed: manualZoomed,
intialMaskFrame: getInitialCropBoxRect(),
initialMaskFrame: getInitialCropBoxRect(),
maskFrame: cropAuxiliaryIndicatorView.frame,
cropWorkbenchViewBounds: cropWorkbenchView.bounds
)
Expand Down Expand Up @@ -755,7 +755,7 @@ extension CropView: CropViewProtocol {
setForceFixedRatio(by: presetFixedRatioType)
}

func getRatioType(byImageIsOriginalisHorizontal isHorizontal: Bool) -> RatioType {
func getRatioType(byImageIsOriginalHorizontal isHorizontal: Bool) -> RatioType {
return viewModel.getRatioType(byImageIsOriginalHorizontal: isHorizontal)
}

Expand Down Expand Up @@ -845,7 +845,7 @@ extension CropView: CropViewProtocol {
updatePositionFor90Rotation(by: rotateAngle + viewModel.radians)
}

func handleRoteteCompletion() {
func handleRotateCompletion() {
cropWorkbenchView.updateMinZoomScale()
viewModel.rotateBy90(withRotateType: newRotateType)
viewModel.setBetweenOperationStatus()
Expand All @@ -855,7 +855,7 @@ extension CropView: CropViewProtocol {
UIView.animate(withDuration: 0.25, animations: {
handleRotateAnimation()
}, completion: { _ in
handleRoteteCompletion()
handleRotateCompletion()
})
}

Expand Down Expand Up @@ -937,36 +937,36 @@ extension CropView: CropViewProtocol {
return newTransform
}

func getTransformInfo(byNormalizedInfo normailizedInfo: CGRect) -> Transformation {
func getTransformInfo(byNormalizedInfo normalizedInfo: CGRect) -> Transformation {
let cropFrame = viewModel.cropBoxFrame

let scale: CGFloat = min(1/normailizedInfo.width, 1/normailizedInfo.height)
let scale: CGFloat = min(1/normalizedInfo.width, 1/normalizedInfo.height)

var offset = cropFrame.origin
offset.x = cropFrame.width * normailizedInfo.origin.x * scale
offset.y = cropFrame.height * normailizedInfo.origin.y * scale
offset.x = cropFrame.width * normalizedInfo.origin.x * scale
offset.y = cropFrame.height * normalizedInfo.origin.y * scale

var maskFrame = cropFrame

if normailizedInfo.width > normailizedInfo.height {
let adjustScale = 1 / normailizedInfo.width
maskFrame.size.height = normailizedInfo.height * cropFrame.height * adjustScale
if normalizedInfo.width > normalizedInfo.height {
let adjustScale = 1 / normalizedInfo.width
maskFrame.size.height = normalizedInfo.height * cropFrame.height * adjustScale
maskFrame.origin.y += (cropFrame.height - maskFrame.height) / 2
} else if normailizedInfo.width < normailizedInfo.height {
let adjustScale = 1 / normailizedInfo.height
maskFrame.size.width = normailizedInfo.width * cropFrame.width * adjustScale
} else if normalizedInfo.width < normalizedInfo.height {
let adjustScale = 1 / normalizedInfo.height
maskFrame.size.width = normalizedInfo.width * cropFrame.width * adjustScale
maskFrame.origin.x += (cropFrame.width - maskFrame.width) / 2
}

let manualZoomed = (scale != 1.0)
let transformantion = Transformation(offset: offset,
let transformation = Transformation(offset: offset,
rotation: 0,
scale: scale,
manualZoomed: manualZoomed,
intialMaskFrame: .zero,
initialMaskFrame: .zero,
maskFrame: maskFrame,
cropWorkbenchViewBounds: .zero)
return transformantion
return transformation
}

func processPresetTransformation(completion: (Transformation) -> Void) {
Expand All @@ -979,12 +979,12 @@ extension CropView: CropViewProtocol {

// The second transform is for adjusting the scale of transformInfo
let adjustScale = (viewModel.cropBoxFrame.width / viewModel.cropBoxOriginFrame.width)
/ (transformInfo.maskFrame.width / transformInfo.intialMaskFrame.width)
/ (transformInfo.maskFrame.width / transformInfo.initialMaskFrame.width)
newTransform.scale *= adjustScale
transform(byTransformInfo: newTransform)
completion(transformInfo)
case .presetNormalizedInfo(let normailizedInfo):
let transformInfo = getTransformInfo(byNormalizedInfo: normailizedInfo)
case .presetNormalizedInfo(let normalizedInfo):
let transformInfo = getTransformInfo(byNormalizedInfo: normalizedInfo)
transform(byTransformInfo: transformInfo)
cropWorkbenchView.frame = transformInfo.maskFrame
completion(transformInfo)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Mantis/CropViewController/CropViewController.swift
Expand Up @@ -96,7 +96,7 @@ open class CropViewController: UIViewController {
private func getRatioType() -> RatioType {
switch config.cropToolbarConfig.fixedRatiosShowType {
case .adaptive:
return cropView.getRatioType(byImageIsOriginalisHorizontal: cropView.image.isHorizontal())
return cropView.getRatioType(byImageIsOriginalHorizontal: cropView.image.isHorizontal())
case .horizontal:
return .horizontal
case .vertical:
Expand Down
Expand Up @@ -115,13 +115,13 @@ extension ToolBarButtonImageBuilder {
rightarrowPath.fill()

let mirrorWidth = wholeWidth / 2 - 1
let mirrowHeight = wholeHeight - 8
let mirrorHeight = wholeHeight - 8

// left mirror
let leftMirror = UIBezierPath()
leftMirror.move(to: CGPoint(x: 0, y: wholeHeight))
leftMirror.addLine(to: CGPoint(x: mirrorWidth, y: wholeHeight))
leftMirror.addLine(to: CGPoint(x: mirrorWidth, y: wholeHeight - mirrowHeight))
leftMirror.addLine(to: CGPoint(x: mirrorWidth, y: wholeHeight - mirrorHeight))
leftMirror.addLine(to: CGPoint(x: 0, y: wholeHeight))
leftMirror.close()
UIColor.white.setFill()
Expand All @@ -131,7 +131,7 @@ extension ToolBarButtonImageBuilder {
let rightMirror = UIBezierPath()
rightMirror.move(to: CGPoint(x: wholeWidth, y: wholeHeight))
rightMirror.addLine(to: CGPoint(x: wholeWidth - mirrorWidth, y: wholeHeight))
rightMirror.addLine(to: CGPoint(x: wholeWidth - mirrorWidth, y: wholeHeight - mirrowHeight))
rightMirror.addLine(to: CGPoint(x: wholeWidth - mirrorWidth, y: wholeHeight - mirrorHeight))
rightMirror.addLine(to: CGPoint(x: wholeWidth, y: wholeHeight))
rightMirror.close()
UIColor.white.setFill()
Expand All @@ -152,9 +152,9 @@ extension ToolBarButtonImageBuilder {
context?.rotate(by: -.pi / 2)
context?.translateBy(x: -flippedHorizontallyImage.size.height, y: 0)
context?.draw(cgImage, in: CGRect(x: 0, y: 0, width: flippedHorizontallyImage.size.height, height: flippedHorizontallyImage.size.width))
let fippedVerticallyImage: UIImage? = UIGraphicsGetImageFromCurrentImageContext()
let flippedVerticallyImage: UIImage? = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return fippedVerticallyImage
return flippedVerticallyImage
}

static func drawClampImage() -> UIImage? {
Expand Down
Expand Up @@ -87,15 +87,15 @@ struct ToolBarButtonImageBuilder {

static func verticallyFlipImage() -> UIImage? {
if #available(macCatalyst 13.1, iOS 13.0, *) {
guard let horizontallyFippedImage = horizontallyFlipImage(),
let cgImage = horizontallyFippedImage.cgImage else {
guard let horizontallyFlippedImage = horizontallyFlipImage(),
let cgImage = horizontallyFlippedImage.cgImage else {
return nil
}

let rotatedImage = UIImage(cgImage: cgImage, scale: horizontallyFippedImage.scale, orientation: .leftMirrored)
let rotatedImage = UIImage(cgImage: cgImage, scale: horizontallyFlippedImage.scale, orientation: .leftMirrored)

let newSize = CGSize(width: horizontallyFippedImage.size.height, height: horizontallyFippedImage.size.width)
UIGraphicsBeginImageContextWithOptions(newSize, false, horizontallyFippedImage.scale)
let newSize = CGSize(width: horizontallyFlippedImage.size.height, height: horizontallyFlippedImage.size.width)
UIGraphicsBeginImageContextWithOptions(newSize, false, horizontallyFlippedImage.scale)
rotatedImage.draw(in: CGRect(origin: .zero, size: newSize))

let newImage = UIGraphicsGetImageFromCurrentImageContext()
Expand Down
4 changes: 2 additions & 2 deletions Sources/Mantis/Enum.swift
Expand Up @@ -27,7 +27,7 @@ import UIKit
public enum PresetTransformationType {
case none
case presetInfo(info: Transformation)
case presetNormalizedInfo(normailizedInfo: CGRect)
case presetNormalizedInfo(normalizedInfo: CGRect)
}

public enum PresetFixedRatioType {
Expand Down Expand Up @@ -79,7 +79,7 @@ public enum CropShapeType: Hashable {
case polygon(sides: Int, offset: CGFloat = 0, maskOnly: Bool = false)

/**
Each point should have normailzed values whose range is 0...1
Each point should have normalized values whose range is 0...1
*/
case path(points: [CGPoint], maskOnly: Bool = false)

Expand Down
4 changes: 2 additions & 2 deletions Sources/Mantis/Protocols/CropViewProtocol.swift
Expand Up @@ -20,7 +20,7 @@ protocol CropViewProtocol: UIView {

func initialSetup(delegate: CropViewDelegate, presetFixedRatioType: PresetFixedRatioType)
func setViewDefaultProperties()
func getRatioType(byImageIsOriginalisHorizontal isHorizontal: Bool) -> RatioType
func getRatioType(byImageIsOriginalHorizontal isHorizontal: Bool) -> RatioType
func getImageHorizontalToVerticalRatio() -> Double
func resetComponents()
func prepareForViewWillTransition()
Expand All @@ -32,7 +32,7 @@ protocol CropViewProtocol: UIView {

func transform(byTransformInfo transformation: Transformation, rotateDial: Bool)
func getTransformInfo(byTransformInfo transformInfo: Transformation) -> Transformation
func getTransformInfo(byNormalizedInfo normailizedInfo: CGRect) -> Transformation
func getTransformInfo(byNormalizedInfo normalizedInfo: CGRect) -> Transformation
func processPresetTransformation(completion: (Transformation) -> Void)

func horizontallyFlip()
Expand Down
12 changes: 6 additions & 6 deletions Tests/MantisTests/CropAuxiliaryIndicatorViewTests.swift
Expand Up @@ -31,20 +31,20 @@ final class CropAuxiliaryIndicatorViewTests: XCTestCase {
let container = UIView(frame: CGRect(x: 0, y: 0, width: 1000, height: 1000))
container.addSubview(cropAuxiliaryIndicatorView)

for subivew in cropAuxiliaryIndicatorView.subviews {
XCTAssertEqual(subivew.frame, .zero)
for subview in cropAuxiliaryIndicatorView.subviews {
XCTAssertEqual(subview.frame, .zero)
}

cropAuxiliaryIndicatorView = CropAuxiliaryIndicatorView(frame: CGRect(x: 0, y: 0, width: 100, height: 100), cropBoxHotAreaUnit: 42)

for subivew in cropAuxiliaryIndicatorView.subviews {
XCTAssertEqual(subivew.frame, .zero)
for subview in cropAuxiliaryIndicatorView.subviews {
XCTAssertEqual(subview.frame, .zero)
}

container.addSubview(cropAuxiliaryIndicatorView)

for subivew in cropAuxiliaryIndicatorView.subviews {
XCTAssertNotEqual(subivew.frame, .zero)
for subview in cropAuxiliaryIndicatorView.subviews {
XCTAssertNotEqual(subview.frame, .zero)
}
}

Expand Down

0 comments on commit a2a48e2

Please sign in to comment.