diff --git a/.DS_Store b/.DS_Store index e1fcced5fcaf1911be78ad5f61788a441f9cb554..9ec06f17cc82872370c33c1c489d0d7b508bdd5b 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/MiniScanner.xcodeproj/project.pbxproj b/MiniScanner.xcodeproj/project.pbxproj index 373e411b86302668b3df3a65e8f58591296bb39b..e12a7273305884e9c149be1fb2e895421d0b94d6 100644 --- a/MiniScanner.xcodeproj/project.pbxproj +++ b/MiniScanner.xcodeproj/project.pbxproj @@ -69,6 +69,55 @@ 535984202C14B8C5003EB6ED /* SearchFilesView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5359841F2C14B8C5003EB6ED /* SearchFilesView.xib */; }; 539996342C26D41300671340 /* OCRViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996322C26D41300671340 /* OCRViewController.swift */; }; 539996352C26D41300671340 /* OCRViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 539996332C26D41300671340 /* OCRViewController.xib */; }; + 539996492C26E86700671340 /* CDCameraOverlayView.m in Sources */ = {isa = PBXBuildFile; fileRef = 539996392C26E86700671340 /* CDCameraOverlayView.m */; }; + 5399964A2C26E86700671340 /* CropperConstantValues.m in Sources */ = {isa = PBXBuildFile; fileRef = 5399963A2C26E86700671340 /* CropperConstantValues.m */; }; + 5399964B2C26E86700671340 /* FlashButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 5399963B2C26E86700671340 /* FlashButton.m */; }; + 5399964C2C26E86700671340 /* CDCameraView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5399963C2C26E86700671340 /* CDCameraView.m */; }; + 5399964D2C26E86700671340 /* CDImageRectangleDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = 5399963E2C26E86700671340 /* CDImageRectangleDetector.m */; }; + 5399964E2C26E86700671340 /* CDZoomView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5399963F2C26E86700671340 /* CDZoomView.m */; }; + 5399964F2C26E86700671340 /* SelectableRoundView.m in Sources */ = {isa = PBXBuildFile; fileRef = 539996402C26E86700671340 /* SelectableRoundView.m */; }; + 539996502C26E86700671340 /* CDOverlayView.m in Sources */ = {isa = PBXBuildFile; fileRef = 539996412C26E86700671340 /* CDOverlayView.m */; }; + 539996512C26E86700671340 /* DefaultValues.m in Sources */ = {isa = PBXBuildFile; fileRef = 539996472C26E86700671340 /* DefaultValues.m */; }; + 539996542C2711BA00671340 /* ZLImageEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 539996532C2711BA00671340 /* ZLImageEditor */; }; + 539996572C27124B00671340 /* FontChooserContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996552C27124B00671340 /* FontChooserContainerView.swift */; }; + 539996582C27124B00671340 /* ImageStickerContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996562C27124B00671340 /* ImageStickerContainerView.swift */; }; + 539996802C27130000671340 /* ConstraintMultiplierTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399965A2C27130000671340 /* ConstraintMultiplierTarget.swift */; }; + 539996812C27130000671340 /* LayoutConstraintItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399965B2C27130000671340 /* LayoutConstraintItem.swift */; }; + 539996822C27130000671340 /* ConstraintDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399965C2C27130000671340 /* ConstraintDescription.swift */; }; + 539996832C27130000671340 /* ConstraintMakerPriortizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399965D2C27130000671340 /* ConstraintMakerPriortizable.swift */; }; + 539996842C27130000671340 /* ConstraintAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399965E2C27130000671340 /* ConstraintAttributes.swift */; }; + 539996852C27130000671340 /* ConstraintViewDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399965F2C27130000671340 /* ConstraintViewDSL.swift */; }; + 539996862C27130000671340 /* ConstraintPriorityTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996602C27130000671340 /* ConstraintPriorityTarget.swift */; }; + 539996872C27130000671340 /* ConstraintInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996612C27130000671340 /* ConstraintInsets.swift */; }; + 539996882C27130000671340 /* ConstraintMakerFinalizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996622C27130000671340 /* ConstraintMakerFinalizable.swift */; }; + 539996892C27130000671340 /* ConstraintDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996632C27130000671340 /* ConstraintDSL.swift */; }; + 5399968A2C27130000671340 /* ConstraintMakerExtendable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996642C27130000671340 /* ConstraintMakerExtendable.swift */; }; + 5399968B2C27130000671340 /* ConstraintPriority.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996652C27130000671340 /* ConstraintPriority.swift */; }; + 5399968C2C27130000671340 /* ConstraintInsetTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996662C27130000671340 /* ConstraintInsetTarget.swift */; }; + 5399968D2C27130000671340 /* ConstraintDirectionalInsetTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996672C27130000671340 /* ConstraintDirectionalInsetTarget.swift */; }; + 5399968E2C27130000671340 /* ConstraintMakerRelatable+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996692C27130000671340 /* ConstraintMakerRelatable+Extensions.swift */; }; + 5399968F2C27130000671340 /* ConstraintConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399966A2C27130000671340 /* ConstraintConfig.swift */; }; + 539996902C27130000671340 /* UILayoutSupport+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399966B2C27130000671340 /* UILayoutSupport+Extensions.swift */; }; + 539996912C27130000671340 /* ConstraintView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399966C2C27130000671340 /* ConstraintView.swift */; }; + 539996922C27130000671340 /* ConstraintLayoutGuide.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399966D2C27130000671340 /* ConstraintLayoutGuide.swift */; }; + 539996932C27130000671340 /* ConstraintLayoutSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399966E2C27130000671340 /* ConstraintLayoutSupport.swift */; }; + 539996942C27130000671340 /* Typealiases.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399966F2C27130000671340 /* Typealiases.swift */; }; + 539996952C27130000671340 /* ConstraintConstantTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996702C27130000671340 /* ConstraintConstantTarget.swift */; }; + 539996962C27130000671340 /* ConstraintOffsetTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996712C27130000671340 /* ConstraintOffsetTarget.swift */; }; + 539996972C27130000671340 /* ConstraintMakerEditable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996722C27130000671340 /* ConstraintMakerEditable.swift */; }; + 539996982C27130000671340 /* ConstraintMaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996732C27130000671340 /* ConstraintMaker.swift */; }; + 539996992C27130000671340 /* ConstraintRelation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996742C27130000671340 /* ConstraintRelation.swift */; }; + 5399969A2C27130000671340 /* ConstraintLayoutGuideDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996752C27130000671340 /* ConstraintLayoutGuideDSL.swift */; }; + 5399969B2C27130000671340 /* ConstraintView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996762C27130000671340 /* ConstraintView+Extensions.swift */; }; + 5399969C2C27130000671340 /* ConstraintItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996772C27130000671340 /* ConstraintItem.swift */; }; + 5399969D2C27130000671340 /* Constraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996782C27130000671340 /* Constraint.swift */; }; + 5399969E2C27130000671340 /* Debugging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539996792C27130000671340 /* Debugging.swift */; }; + 5399969F2C27130000671340 /* ConstraintRelatableTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399967A2C27130000671340 /* ConstraintRelatableTarget.swift */; }; + 539996A02C27130000671340 /* LayoutConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399967B2C27130000671340 /* LayoutConstraint.swift */; }; + 539996A12C27130000671340 /* ConstraintLayoutGuide+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399967C2C27130000671340 /* ConstraintLayoutGuide+Extensions.swift */; }; + 539996A22C27130000671340 /* ConstraintDirectionalInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399967D2C27130000671340 /* ConstraintDirectionalInsets.swift */; }; + 539996A32C27130000671340 /* ConstraintLayoutSupportDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399967E2C27130000671340 /* ConstraintLayoutSupportDSL.swift */; }; + 539996A42C27130000671340 /* ConstraintMakerRelatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5399967F2C27130000671340 /* ConstraintMakerRelatable.swift */; }; 539D1C852C164F85009DB24A /* CustomTabBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539D1C842C164F85009DB24A /* CustomTabBarView.swift */; }; 539D1C872C164F92009DB24A /* CustomTabBarView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 539D1C862C164F92009DB24A /* CustomTabBarView.xib */; }; 539D1C8B2C16E97F009DB24A /* ShareSheetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539D1C892C16E97F009DB24A /* ShareSheetViewController.swift */; }; @@ -235,6 +284,64 @@ 5359841F2C14B8C5003EB6ED /* SearchFilesView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SearchFilesView.xib; sourceTree = "<group>"; }; 539996322C26D41300671340 /* OCRViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OCRViewController.swift; sourceTree = "<group>"; }; 539996332C26D41300671340 /* OCRViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = OCRViewController.xib; sourceTree = "<group>"; }; + 539996372C26E86700671340 /* CDOverlayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDOverlayView.h; sourceTree = "<group>"; }; + 539996382C26E86700671340 /* SelectableRoundView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectableRoundView.h; sourceTree = "<group>"; }; + 539996392C26E86700671340 /* CDCameraOverlayView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDCameraOverlayView.m; sourceTree = "<group>"; }; + 5399963A2C26E86700671340 /* CropperConstantValues.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CropperConstantValues.m; sourceTree = "<group>"; }; + 5399963B2C26E86700671340 /* FlashButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlashButton.m; sourceTree = "<group>"; }; + 5399963C2C26E86700671340 /* CDCameraView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDCameraView.m; sourceTree = "<group>"; }; + 5399963D2C26E86700671340 /* DefaultValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultValues.h; sourceTree = "<group>"; }; + 5399963E2C26E86700671340 /* CDImageRectangleDetector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDImageRectangleDetector.m; sourceTree = "<group>"; }; + 5399963F2C26E86700671340 /* CDZoomView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDZoomView.m; sourceTree = "<group>"; }; + 539996402C26E86700671340 /* SelectableRoundView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SelectableRoundView.m; sourceTree = "<group>"; }; + 539996412C26E86700671340 /* CDOverlayView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDOverlayView.m; sourceTree = "<group>"; }; + 539996422C26E86700671340 /* CDCameraView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDCameraView.h; sourceTree = "<group>"; }; + 539996432C26E86700671340 /* FlashButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlashButton.h; sourceTree = "<group>"; }; + 539996442C26E86700671340 /* CropperConstantValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CropperConstantValues.h; sourceTree = "<group>"; }; + 539996452C26E86700671340 /* CDCameraOverlayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDCameraOverlayView.h; sourceTree = "<group>"; }; + 539996462C26E86700671340 /* CDImageRectangleDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDImageRectangleDetector.h; sourceTree = "<group>"; }; + 539996472C26E86700671340 /* DefaultValues.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DefaultValues.m; sourceTree = "<group>"; }; + 539996482C26E86700671340 /* CDZoomView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDZoomView.h; sourceTree = "<group>"; }; + 539996552C27124B00671340 /* FontChooserContainerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FontChooserContainerView.swift; sourceTree = "<group>"; }; + 539996562C27124B00671340 /* ImageStickerContainerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageStickerContainerView.swift; sourceTree = "<group>"; }; + 5399965A2C27130000671340 /* ConstraintMultiplierTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMultiplierTarget.swift; sourceTree = "<group>"; }; + 5399965B2C27130000671340 /* LayoutConstraintItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutConstraintItem.swift; sourceTree = "<group>"; }; + 5399965C2C27130000671340 /* ConstraintDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDescription.swift; sourceTree = "<group>"; }; + 5399965D2C27130000671340 /* ConstraintMakerPriortizable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerPriortizable.swift; sourceTree = "<group>"; }; + 5399965E2C27130000671340 /* ConstraintAttributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintAttributes.swift; sourceTree = "<group>"; }; + 5399965F2C27130000671340 /* ConstraintViewDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintViewDSL.swift; sourceTree = "<group>"; }; + 539996602C27130000671340 /* ConstraintPriorityTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintPriorityTarget.swift; sourceTree = "<group>"; }; + 539996612C27130000671340 /* ConstraintInsets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintInsets.swift; sourceTree = "<group>"; }; + 539996622C27130000671340 /* ConstraintMakerFinalizable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerFinalizable.swift; sourceTree = "<group>"; }; + 539996632C27130000671340 /* ConstraintDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDSL.swift; sourceTree = "<group>"; }; + 539996642C27130000671340 /* ConstraintMakerExtendable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerExtendable.swift; sourceTree = "<group>"; }; + 539996652C27130000671340 /* ConstraintPriority.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintPriority.swift; sourceTree = "<group>"; }; + 539996662C27130000671340 /* ConstraintInsetTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintInsetTarget.swift; sourceTree = "<group>"; }; + 539996672C27130000671340 /* ConstraintDirectionalInsetTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDirectionalInsetTarget.swift; sourceTree = "<group>"; }; + 539996682C27130000671340 /* SnapKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SnapKit.h; sourceTree = "<group>"; }; + 539996692C27130000671340 /* ConstraintMakerRelatable+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ConstraintMakerRelatable+Extensions.swift"; sourceTree = "<group>"; }; + 5399966A2C27130000671340 /* ConstraintConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintConfig.swift; sourceTree = "<group>"; }; + 5399966B2C27130000671340 /* UILayoutSupport+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UILayoutSupport+Extensions.swift"; sourceTree = "<group>"; }; + 5399966C2C27130000671340 /* ConstraintView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintView.swift; sourceTree = "<group>"; }; + 5399966D2C27130000671340 /* ConstraintLayoutGuide.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutGuide.swift; sourceTree = "<group>"; }; + 5399966E2C27130000671340 /* ConstraintLayoutSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutSupport.swift; sourceTree = "<group>"; }; + 5399966F2C27130000671340 /* Typealiases.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Typealiases.swift; sourceTree = "<group>"; }; + 539996702C27130000671340 /* ConstraintConstantTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintConstantTarget.swift; sourceTree = "<group>"; }; + 539996712C27130000671340 /* ConstraintOffsetTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintOffsetTarget.swift; sourceTree = "<group>"; }; + 539996722C27130000671340 /* ConstraintMakerEditable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerEditable.swift; sourceTree = "<group>"; }; + 539996732C27130000671340 /* ConstraintMaker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMaker.swift; sourceTree = "<group>"; }; + 539996742C27130000671340 /* ConstraintRelation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintRelation.swift; sourceTree = "<group>"; }; + 539996752C27130000671340 /* ConstraintLayoutGuideDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutGuideDSL.swift; sourceTree = "<group>"; }; + 539996762C27130000671340 /* ConstraintView+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ConstraintView+Extensions.swift"; sourceTree = "<group>"; }; + 539996772C27130000671340 /* ConstraintItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintItem.swift; sourceTree = "<group>"; }; + 539996782C27130000671340 /* Constraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constraint.swift; sourceTree = "<group>"; }; + 539996792C27130000671340 /* Debugging.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Debugging.swift; sourceTree = "<group>"; }; + 5399967A2C27130000671340 /* ConstraintRelatableTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintRelatableTarget.swift; sourceTree = "<group>"; }; + 5399967B2C27130000671340 /* LayoutConstraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutConstraint.swift; sourceTree = "<group>"; }; + 5399967C2C27130000671340 /* ConstraintLayoutGuide+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ConstraintLayoutGuide+Extensions.swift"; sourceTree = "<group>"; }; + 5399967D2C27130000671340 /* ConstraintDirectionalInsets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDirectionalInsets.swift; sourceTree = "<group>"; }; + 5399967E2C27130000671340 /* ConstraintLayoutSupportDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutSupportDSL.swift; sourceTree = "<group>"; }; + 5399967F2C27130000671340 /* ConstraintMakerRelatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerRelatable.swift; sourceTree = "<group>"; }; 539D1C842C164F85009DB24A /* CustomTabBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTabBarView.swift; sourceTree = "<group>"; }; 539D1C862C164F92009DB24A /* CustomTabBarView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CustomTabBarView.xib; sourceTree = "<group>"; }; 539D1C892C16E97F009DB24A /* ShareSheetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareSheetViewController.swift; sourceTree = "<group>"; }; @@ -331,6 +438,7 @@ files = ( 89A104FC06BB7828A032A87D /* Pods_MiniScanner.framework in Frameworks */, 539D1C972C171344009DB24A /* LNExtensionExecutor in Frameworks */, + 539996542C2711BA00671340 /* ZLImageEditor in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -530,6 +638,76 @@ path = OCRViewController; sourceTree = "<group>"; }; + 539996362C26E86700671340 /* CDOverlay */ = { + isa = PBXGroup; + children = ( + 539996372C26E86700671340 /* CDOverlayView.h */, + 539996382C26E86700671340 /* SelectableRoundView.h */, + 539996392C26E86700671340 /* CDCameraOverlayView.m */, + 5399963A2C26E86700671340 /* CropperConstantValues.m */, + 5399963B2C26E86700671340 /* FlashButton.m */, + 5399963C2C26E86700671340 /* CDCameraView.m */, + 5399963D2C26E86700671340 /* DefaultValues.h */, + 5399963E2C26E86700671340 /* CDImageRectangleDetector.m */, + 5399963F2C26E86700671340 /* CDZoomView.m */, + 539996402C26E86700671340 /* SelectableRoundView.m */, + 539996412C26E86700671340 /* CDOverlayView.m */, + 539996422C26E86700671340 /* CDCameraView.h */, + 539996432C26E86700671340 /* FlashButton.h */, + 539996442C26E86700671340 /* CropperConstantValues.h */, + 539996452C26E86700671340 /* CDCameraOverlayView.h */, + 539996462C26E86700671340 /* CDImageRectangleDetector.h */, + 539996472C26E86700671340 /* DefaultValues.m */, + 539996482C26E86700671340 /* CDZoomView.h */, + ); + path = CDOverlay; + sourceTree = "<group>"; + }; + 539996592C27130000671340 /* SnapKit */ = { + isa = PBXGroup; + children = ( + 5399965A2C27130000671340 /* ConstraintMultiplierTarget.swift */, + 5399965B2C27130000671340 /* LayoutConstraintItem.swift */, + 5399965C2C27130000671340 /* ConstraintDescription.swift */, + 5399965D2C27130000671340 /* ConstraintMakerPriortizable.swift */, + 5399965E2C27130000671340 /* ConstraintAttributes.swift */, + 5399965F2C27130000671340 /* ConstraintViewDSL.swift */, + 539996602C27130000671340 /* ConstraintPriorityTarget.swift */, + 539996612C27130000671340 /* ConstraintInsets.swift */, + 539996622C27130000671340 /* ConstraintMakerFinalizable.swift */, + 539996632C27130000671340 /* ConstraintDSL.swift */, + 539996642C27130000671340 /* ConstraintMakerExtendable.swift */, + 539996652C27130000671340 /* ConstraintPriority.swift */, + 539996662C27130000671340 /* ConstraintInsetTarget.swift */, + 539996672C27130000671340 /* ConstraintDirectionalInsetTarget.swift */, + 539996682C27130000671340 /* SnapKit.h */, + 539996692C27130000671340 /* ConstraintMakerRelatable+Extensions.swift */, + 5399966A2C27130000671340 /* ConstraintConfig.swift */, + 5399966B2C27130000671340 /* UILayoutSupport+Extensions.swift */, + 5399966C2C27130000671340 /* ConstraintView.swift */, + 5399966D2C27130000671340 /* ConstraintLayoutGuide.swift */, + 5399966E2C27130000671340 /* ConstraintLayoutSupport.swift */, + 5399966F2C27130000671340 /* Typealiases.swift */, + 539996702C27130000671340 /* ConstraintConstantTarget.swift */, + 539996712C27130000671340 /* ConstraintOffsetTarget.swift */, + 539996722C27130000671340 /* ConstraintMakerEditable.swift */, + 539996732C27130000671340 /* ConstraintMaker.swift */, + 539996742C27130000671340 /* ConstraintRelation.swift */, + 539996752C27130000671340 /* ConstraintLayoutGuideDSL.swift */, + 539996762C27130000671340 /* ConstraintView+Extensions.swift */, + 539996772C27130000671340 /* ConstraintItem.swift */, + 539996782C27130000671340 /* Constraint.swift */, + 539996792C27130000671340 /* Debugging.swift */, + 5399967A2C27130000671340 /* ConstraintRelatableTarget.swift */, + 5399967B2C27130000671340 /* LayoutConstraint.swift */, + 5399967C2C27130000671340 /* ConstraintLayoutGuide+Extensions.swift */, + 5399967D2C27130000671340 /* ConstraintDirectionalInsets.swift */, + 5399967E2C27130000671340 /* ConstraintLayoutSupportDSL.swift */, + 5399967F2C27130000671340 /* ConstraintMakerRelatable.swift */, + ); + path = SnapKit; + sourceTree = "<group>"; + }; 539D1C832C164F6D009DB24A /* CustomTabBarView */ = { isa = PBXGroup; children = ( @@ -785,6 +963,10 @@ EC8A9B0C254DC30800F9AF99 /* Supporting Files */ = { isa = PBXGroup; children = ( + 539996592C27130000671340 /* SnapKit */, + 539996552C27124B00671340 /* FontChooserContainerView.swift */, + 539996562C27124B00671340 /* ImageStickerContainerView.swift */, + 539996362C26E86700671340 /* CDOverlay */, 53E7D32B2C1B00880025A1D3 /* Sources */, 53D9D1BD2C1AF521004D1C1C /* LogoAnimationView */, 53D9D1C12C1AF521004D1C1C /* MyExtention.swift */, @@ -858,6 +1040,7 @@ name = MiniScanner; packageProductDependencies = ( 539D1C962C171344009DB24A /* LNExtensionExecutor */, + 539996532C2711BA00671340 /* ZLImageEditor */, ); productName = MiniScanner; productReference = EC0CF1FA254D8BBF00888722 /* MiniScanner.app */; @@ -896,6 +1079,7 @@ mainGroup = EC0CF1F1254D8BBF00888722; packageReferences = ( 539D1C952C171344009DB24A /* XCRemoteSwiftPackageReference "LNExtensionExecutor" */, + 539996522C2711BA00671340 /* XCRemoteSwiftPackageReference "ZLImageEditor" */, ); productRefGroup = EC0CF1FB254D8BBF00888722 /* Products */; projectDirPath = ""; @@ -1005,34 +1189,50 @@ buildActionMask = 2147483647; files = ( 5359841E2C14B835003EB6ED /* SearchFilesView.swift in Sources */, + 539996992C27130000671340 /* ConstraintRelation.swift in Sources */, 53014FA02C11A8E80071CE39 /* MultiPageScanSession.swift in Sources */, + 539996502C26E86700671340 /* CDOverlayView.m in Sources */, 53014F9A2C11A8E80071CE39 /* CIImage+Utils.swift in Sources */, 53D9D1C42C1AF521004D1C1C /* UIView+Constraints.swift in Sources */, 53CD5F5E2C1505EC0010424B /* UIWindow.swift in Sources */, EC8A9B17254DCC2900F9AF99 /* URL+Extensions.swift in Sources */, + 539996922C27130000671340 /* ConstraintLayoutGuide.swift in Sources */, + 539996A32C27130000671340 /* ConstraintLayoutSupportDSL.swift in Sources */, 53D9D1C52C1AF521004D1C1C /* MyExtention.swift in Sources */, 535983F22C144E87003EB6ED /* Keys.swift in Sources */, + 539996962C27130000671340 /* ConstraintOffsetTarget.swift in Sources */, EC70252C254E066400BE1958 /* SettingsViewController.swift in Sources */, EC0CF21D254D8F3900888722 /* String+Extensions.swift in Sources */, + 539996812C27130000671340 /* LayoutConstraintItem.swift in Sources */, EC702540254E1E7500BE1958 /* WalkthroughViewController.swift in Sources */, EC0CF215254D8DE900888722 /* DocumentsTableViewController.swift in Sources */, 53CD5F542C15022E0010424B /* KNAlertViewController.swift in Sources */, 53014F9D2C11A8E80071CE39 /* Array+Utils.swift in Sources */, 53CD5F612C15A6210010424B /* SettingViewController.swift in Sources */, 53014FAA2C11A8E80071CE39 /* Quadrilateral.swift in Sources */, + 539996832C27130000671340 /* ConstraintMakerPriortizable.swift in Sources */, + 5399969E2C27130000671340 /* Debugging.swift in Sources */, 53EDED982C18387E00DB8DF9 /* TYCyclePagerTransformLayout.m in Sources */, + 5399968E2C27130000671340 /* ConstraintMakerRelatable+Extensions.swift in Sources */, + 539996512C26E86700671340 /* DefaultValues.m in Sources */, 53014FA42C11A8E80071CE39 /* EditScanViewController.swift in Sources */, 53E7D33C2C1B00880025A1D3 /* FSPagerCollectionView.swift in Sources */, EC8A9B1A254DCE3E00F9AF99 /* UIImage+Extensions.swift in Sources */, 53014FB72C11A8E80071CE39 /* CaptureDevice.swift in Sources */, + 5399968D2C27130000671340 /* ConstraintDirectionalInsetTarget.swift in Sources */, 53014F8F2C11A8E80071CE39 /* RectangleFeaturesFunnel.swift in Sources */, 53014F932C11A8E80071CE39 /* PDFCreator.swift in Sources */, 539D1C852C164F85009DB24A /* CustomTabBarView.swift in Sources */, 53E7D33B2C1B00880025A1D3 /* FSPagerViewObjcCompat.m in Sources */, EC702537254E1DE000BE1958 /* UIViewController+Extensions.swift in Sources */, 535983E92C1428D4003EB6ED /* UIColor+Extensions.swift in Sources */, + 539996972C27130000671340 /* ConstraintMakerEditable.swift in Sources */, + 539996A02C27130000671340 /* LayoutConstraint.swift in Sources */, 53014F972C11A8E80071CE39 /* AVCaptureVideoOrientation+Utils.swift in Sources */, 535983EF2C142C9F003EB6ED /* Localization.swift in Sources */, + 539996892C27130000671340 /* ConstraintDSL.swift in Sources */, + 539996952C27130000671340 /* ConstraintConstantTarget.swift in Sources */, + 539996902C27130000671340 /* UILayoutSupport+Extensions.swift in Sources */, 53014F992C11A8E80071CE39 /* CGPoint+Utils.swift in Sources */, 53E7D3392C1B00880025A1D3 /* FSPageViewLayout.swift in Sources */, 53014FA62C11A8E80071CE39 /* Error.swift in Sources */, @@ -1043,42 +1243,61 @@ EC8A9AD5254DB76000F9AF99 /* BaseNavigationViewController.swift in Sources */, 535983EB2C142B16003EB6ED /* UILabel+Extensions.swift in Sources */, EC8A9B10254DC6DD00F9AF99 /* PDFManager.swift in Sources */, + 5399964B2C26E86700671340 /* FlashButton.m in Sources */, + 5399968C2C27130000671340 /* ConstraintInsetTarget.swift in Sources */, ECE9BBAA254E295900D45E43 /* Date+Extensions.swift in Sources */, 53014FA92C11A8E80071CE39 /* QuadrilateralView.swift in Sources */, + 539996802C27130000671340 /* ConstraintMultiplierTarget.swift in Sources */, 53CD5F562C1503150010424B /* BMViewController.swift in Sources */, + 539996822C27130000671340 /* ConstraintDescription.swift in Sources */, EC702546254E1E9E00BE1958 /* WalkthroughModel.swift in Sources */, 53D9D1C22C1AF521004D1C1C /* StickerView.swift in Sources */, + 539996A22C27130000671340 /* ConstraintDirectionalInsets.swift in Sources */, 53E7D3352C1B00880025A1D3 /* FSPagerView.swift in Sources */, 53014F912C11A8E80071CE39 /* ShutterButton.swift in Sources */, 53F21F8B2C1246AF00172BFC /* AllFolderTableViewCell.swift in Sources */, 53014FBD2C11A8E80071CE39 /* CaptureSession+Focus.swift in Sources */, + 5399969C2C27130000671340 /* ConstraintItem.swift in Sources */, 53014F982C11A8E80071CE39 /* URL+Utils.swift in Sources */, EC8A9B00254DBFC700F9AF99 /* UserDefaults+Extensions.swift in Sources */, 53CD5F5C2C1505A20010424B /* Globals.swift in Sources */, EC8A9B03254DC08800F9AF99 /* NSNotification+Extensions.swift in Sources */, + 539996492C26E86700671340 /* CDCameraOverlayView.m in Sources */, 5359841A2C145E55003EB6ED /* DocumentsTableViewCell.swift in Sources */, EC702522254DF13200BE1958 /* PencilKitViewController.swift in Sources */, + 5399968F2C27130000671340 /* ConstraintConfig.swift in Sources */, 53EDED972C18387E00DB8DF9 /* TYCyclePagerView.m in Sources */, 539996342C26D41300671340 /* OCRViewController.swift in Sources */, 53014F902C11A8E80071CE39 /* CaptureSessionManager.swift in Sources */, + 539996912C27130000671340 /* ConstraintView.swift in Sources */, ECA1FAA4254DEB140081F00B /* CustomPDFView.swift in Sources */, 53014FA32C11A8E80071CE39 /* ZoomGestureController.swift in Sources */, 53EDED962C18387E00DB8DF9 /* TYPageControl.m in Sources */, + 5399964C2C26E86700671340 /* CDCameraView.m in Sources */, + 5399969B2C27130000671340 /* ConstraintView+Extensions.swift in Sources */, 53E3A2092C19D17100C9B95E /* PreviewImageViewController.swift in Sources */, 53E7D3362C1B00880025A1D3 /* FSPageViewTransformer.swift in Sources */, EC70252A254E066400BE1958 /* SettingsViewController+Safari.swift in Sources */, + 539996982C27130000671340 /* ConstraintMaker.swift in Sources */, + 5399964F2C26E86700671340 /* SelectableRoundView.m in Sources */, 53E7D3372C1B00880025A1D3 /* FSPagerViewCell.swift in Sources */, 53014F9B2C11A8E80071CE39 /* CGAffineTransform+Utils.swift in Sources */, 53014FBC2C11A8E80071CE39 /* CaptureSession.swift in Sources */, + 539996852C27130000671340 /* ConstraintViewDSL.swift in Sources */, EC702542254E1E7500BE1958 /* ClassicWalkthroughViewController.swift in Sources */, + 539996882C27130000671340 /* ConstraintMakerFinalizable.swift in Sources */, 53EDED9D2C183CDF00DB8DF9 /* BannerView.swift in Sources */, + 5399969A2C27130000671340 /* ConstraintLayoutGuideDSL.swift in Sources */, 53014F922C11A8E80071CE39 /* ScannedItemRenderer.swift in Sources */, EC8A9B14254DC9D300F9AF99 /* LocalFileManager.swift in Sources */, + 5399968A2C27130000671340 /* ConstraintMakerExtendable.swift in Sources */, 53014FBA2C11A8E80071CE39 /* CaptureSession+Flash.swift in Sources */, + 539996572C27124B00671340 /* FontChooserContainerView.swift in Sources */, 53014F952C11A8E80071CE39 /* FocusRectangleView.swift in Sources */, 53014F9E2C11A8E80071CE39 /* UIImage+Orientation.swift in Sources */, 53014FB82C11A8E80071CE39 /* Transformable.swift in Sources */, 53014FA22C11A8E80071CE39 /* ScannedPageViewController.swift in Sources */, + 5399969D2C27130000671340 /* Constraint.swift in Sources */, EC8A9B1D254DCEC600F9AF99 /* File.swift in Sources */, 53E7D33A2C1B00880025A1D3 /* FSPageControl.swift in Sources */, EC8A9B24254DE72F00F9AF99 /* UIView+Extensions.swift in Sources */, @@ -1086,20 +1305,33 @@ 53014FBB2C11A8E80071CE39 /* CaptureSession+Orientation.swift in Sources */, 53014F942C11A8E80071CE39 /* DeviceOrientationHelper.swift in Sources */, EC8A9B27254DE91B00F9AF99 /* DocumentPreviewViewController.swift in Sources */, + 5399964A2C26E86700671340 /* CropperConstantValues.m in Sources */, 53014F9F2C11A8E80071CE39 /* UIImage+Utils.swift in Sources */, 53CD5F582C1504CF0010424B /* UIButton+Extensions.swift in Sources */, 539D1C8B2C16E97F009DB24A /* ShareSheetViewController.swift in Sources */, + 539996A12C27130000671340 /* ConstraintLayoutGuide+Extensions.swift in Sources */, 53014F962C11A8E80071CE39 /* ScannerViewController.swift in Sources */, 53014FA52C11A8E80071CE39 /* EditScanCornerView.swift in Sources */, 53E7D3382C1B00880025A1D3 /* FSPagerViewLayoutAttributes.swift in Sources */, 53014F8E2C11A8E80071CE39 /* ImageScannerController.swift in Sources */, + 539996A42C27130000671340 /* ConstraintMakerRelatable.swift in Sources */, + 539996942C27130000671340 /* Typealiases.swift in Sources */, + 5399964D2C26E86700671340 /* CDImageRectangleDetector.m in Sources */, + 5399964E2C26E86700671340 /* CDZoomView.m in Sources */, EC70252B254E066400BE1958 /* SettingsTableViewCell.swift in Sources */, 535983ED2C142B49003EB6ED /* UIFont+Extensions.swift in Sources */, + 539996582C27124B00671340 /* ImageStickerContainerView.swift in Sources */, + 5399968B2C27130000671340 /* ConstraintPriority.swift in Sources */, + 539996862C27130000671340 /* ConstraintPriorityTarget.swift in Sources */, EC8A9AD0254DB5A400F9AF99 /* AppTabBarController.swift in Sources */, 53CD5F5A2C1505500010424B /* UITextView+Extensions.swift in Sources */, + 539996932C27130000671340 /* ConstraintLayoutSupport.swift in Sources */, + 5399969F2C27130000671340 /* ConstraintRelatableTarget.swift in Sources */, 53F21F912C1248EC00172BFC /* FolderCollectionViewCell.swift in Sources */, + 539996872C27130000671340 /* ConstraintInsets.swift in Sources */, ECD43ED625A7BA9500B5A3F2 /* ThemeManager.swift in Sources */, 53014F9C2C11A8E80071CE39 /* CGRect+Utils.swift in Sources */, + 539996842C27130000671340 /* ConstraintAttributes.swift in Sources */, 53EDEDA32C183FFF00DB8DF9 /* PagerImageCollectionViewCell.swift in Sources */, 53014FA12C11A8E80071CE39 /* MultiPageScanSessionViewController.swift in Sources */, ); @@ -1333,6 +1565,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 539996522C2711BA00671340 /* XCRemoteSwiftPackageReference "ZLImageEditor" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/longitachi/ZLImageEditor.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.0.2; + }; + }; 539D1C952C171344009DB24A /* XCRemoteSwiftPackageReference "LNExtensionExecutor" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/LeoNatan/LNExtensionExecutor.git"; @@ -1344,6 +1584,11 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + 539996532C2711BA00671340 /* ZLImageEditor */ = { + isa = XCSwiftPackageProductDependency; + package = 539996522C2711BA00671340 /* XCRemoteSwiftPackageReference "ZLImageEditor" */; + productName = ZLImageEditor; + }; 539D1C962C171344009DB24A /* LNExtensionExecutor */ = { isa = XCSwiftPackageProductDependency; package = 539D1C952C171344009DB24A /* XCRemoteSwiftPackageReference "LNExtensionExecutor" */; diff --git a/MiniScanner.xcworkspace/xcshareddata/swiftpm/Package.resolved b/MiniScanner.xcworkspace/xcshareddata/swiftpm/Package.resolved index 2a402b605b14368c643e5b8700661997e6c8722c..b5b850f82e0d9479e97627f796b8ca1a205f5ff8 100644 --- a/MiniScanner.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/MiniScanner.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -8,6 +8,15 @@ "revision" : "16b741f659e344f4569c9f9d32ef2298ef0233ff", "version" : "1.2.0" } + }, + { + "identity" : "zlimageeditor", + "kind" : "remoteSourceControl", + "location" : "https://github.com/longitachi/ZLImageEditor.git", + "state" : { + "revision" : "ba2e7ad1993a25a1c2df762b7e16f2426127f41b", + "version" : "2.0.2" + } } ], "version" : 2 diff --git a/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate b/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate index 1164941d313eccc28d57b5d74b9a1ea82370a8e2..c80cf176f960c217ba4cde51172b0c5515748257 100644 Binary files a/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate and b/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/MiniScanner/.DS_Store b/MiniScanner/.DS_Store index 6beef102e5d580989a74bd8ee08a491859ba95d7..6263a47aa40deb900a3e686764896cf143d95611 100644 Binary files a/MiniScanner/.DS_Store and b/MiniScanner/.DS_Store differ diff --git a/MiniScanner/Modules/EditViewController/EditViewController.swift b/MiniScanner/Modules/EditViewController/EditViewController.swift index 431e6b85af4424f567120746a912a3653c570f16..3d0affcc84f0c83355bd018273b314dfcc2cb32f 100644 --- a/MiniScanner/Modules/EditViewController/EditViewController.swift +++ b/MiniScanner/Modules/EditViewController/EditViewController.swift @@ -12,6 +12,9 @@ import NBBottomSheet import QuickLook import AVKit import EPSignature +import AVFoundation +import AVKit +import ZLImageEditor public protocol EditViewControllerDelegate: NSObjectProtocol { func editViewController(_ editViewController: EditViewController, finished session: MultiPageScanSession) @@ -34,7 +37,8 @@ public class EditViewController: UIViewController { private var localFileManager: LocalFileManager? private var fileURL: URL? var options:ImageScannerOptions! - + let config = ZLImageEditorConfiguration.default() + var signatureImage = UIImage() var isAll: Bool = false lazy private var activityIndicator: UIActivityIndicatorView = { @@ -45,9 +49,19 @@ public class EditViewController: UIViewController { return activityIndicator }() + var originalImage = UIImage() + var croppedImage = CIImage() + + var overlayView = CDOverlayView() + var detectedRectangleFeature = CIRectangleFeature() + var sharedDetector = CDImageRectangleDetector() + var magnetEnabled = Bool() + var isCropping: Bool = false + // MARK: - LifeCycle public override func viewDidLoad() { super.viewDidLoad() + if let session = scanSession { banner.set(session: session) banner.delegate = self @@ -60,12 +74,27 @@ public class EditViewController: UIViewController { continueButton.layer.cornerRadius = 10 localFileManager = LocalFileManager() options = ImageScannerOptions() + configImageEditor() + + } + + func configImageEditor() { + ZLImageEditorConfiguration.default() + .imageStickerContainerView(ImageStickerContainerView()) + .fontChooserContainerView(FontChooserContainerView()) + config.tools.append(.draw) + config.tools.append(.clip) + config.tools.append(.textSticker) + config.tools.append(.mosaic) + config.tools.append(.filter) + config.tools.append(.adjust) } @objc func onTouchDoneButton() { - self.banner.donePressed = true - if let items = scanSession?.scannedItems { - let cell = banner.pagerView.cellForItemat(index: self.banner.pagerView.currentIndex) + if !isCropping { + self.banner.donePressed = true + if let items = scanSession?.scannedItems { + let cell = banner.pagerView.cellForItemat(index: self.banner.pagerView.currentIndex) cell?.selectedStickerView1?.showEditing = false cell?.trashButton.isHidden = true @@ -83,8 +112,28 @@ public class EditViewController: UIViewController { self.banner.scanSession = self.scanSession self.banner.pagerView.reloadData(at: banner.pagerView.currentIndex ) updatePageLabel() + self.navigationItem.rightBarButtonItem = nil } } + } else { + isCropping = false + if let editView = self.banner.pagerView.cellForItem(at: self.banner.pagerView.currentIndex) { + editView.trashButton.isHidden = false + editView.previewButton.isHidden = false + } + + if let img = overlayView.cropImage(self.originalImage) { + let scannedItem = ScannedItem(originalImage: img, renderImage: img, quad: nil) + scannedItem.colorOption = self.options.defaultColorRenderOption + scannedItem.rotation = 180 + self.scanSession = self.scanSession?.replaceAndGet(item: scannedItem, at: banner.pagerView.currentIndex) + self.banner.scanSession = self.scanSession + self.banner.pagerView.reloadData(at: banner.pagerView.currentIndex ) + updatePageLabel() + self.navigationItem.rightBarButtonItem = nil + self.overlayView.removeFromSuperview() + } + } } @IBAction func backIndex(_ sender: UIButton) { @@ -207,7 +256,17 @@ public class EditViewController: UIViewController { // MARK: - TABBAR ACTION @IBAction func editButtonTapped(_ sender: UIButton) { - + if let img = scanSession?.scannedItems[banner.pagerView.currentIndex].renderedImage?.retrieveImage() { + ZLEditImageViewController.showEditImageVC(parentVC: self, image: img, editModel: nil) { [ ] resImage, editModel in + let scannedItem = ScannedItem(originalImage: resImage, renderImage: resImage, quad: nil) + scannedItem.colorOption = self.options.defaultColorRenderOption + scannedItem.rotation = 180 + self.scanSession = self.scanSession?.replaceAndGet(item: scannedItem, at: self.banner.pagerView.currentIndex) + self.banner.scanSession = self.scanSession + self.banner.pagerView.reloadData(at: self.banner.pagerView.currentIndex ) + self.updatePageLabel() + } + } } @IBAction func ocrTapped(_ sender: UIButton) { @@ -217,6 +276,27 @@ public class EditViewController: UIViewController { } } + @IBAction func cropTapped(_ sender: UIButton) { + if let origImage = scanSession?.scannedItems[banner.pagerView.currentIndex].renderedImage?.retrieveImage() { + self.originalImage = origImage + } + + DispatchQueue.main.async { + let rect = AVMakeRect(aspectRatio: self.originalImage.size, insideRect: self.banner.bounds) + if let editView = self.banner.pagerView.cellForItem(at: self.banner.pagerView.currentIndex) { + editView.trashButton.isHidden = true + editView.previewButton.isHidden = true + editView.contentView.frame = rect + } + } + isCropping = true + let doneButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.done, target: self, action: #selector(self.onTouchDoneButton)) + self.navigationItem.rightBarButtonItem = doneButton + + self.perform(#selector(setUpCropView), with: self, afterDelay: 0.2) + } + + @IBAction func signatureTapped(_ sender: UIButton) { let signatureVC = EPSignatureViewController(signatureDelegate: self, showsDate: true, showsSaveSignatureOption: true) let nav = UINavigationController(rootViewController: signatureVC) @@ -444,3 +524,73 @@ extension EditViewController: EPSignatureDelegate { } } } + + +extension EditViewController { + @objc func setUpCropView() + { + sharedDetector = CDImageRectangleDetector.shared() + let array = NSArray.init(array: (sharedDetector.highAccuracyRectangleDetector()?.features(in: croppedImage))!) + if array.count > 0{ + detectedRectangleFeature = sharedDetector.biggestRectangle(inRectangles: (array as! [Any])) + croppedImage = sharedDetector.drawHighlightOverlay(forPoints: croppedImage, topLeft: detectedRectangleFeature.topLeft, topRight: detectedRectangleFeature.topRight, bottomLeft: detectedRectangleFeature.bottomLeft, bottomRight: detectedRectangleFeature.bottomRight) + banner.pagerView.isUserInteractionEnabled = true + self.magnetActivated() + }else{ + banner.pagerView.isUserInteractionEnabled = true + self.magnetDeActivated() + } + } + + func magnetActivated() + { + if let imageView = banner.pagerView.cellForItem(at: banner.pagerView.currentIndex)?.contentView { + overlayView = CDOverlayView.init(frame: imageView.bounds) + overlayView.translatesAutoresizingMaskIntoConstraints = false + imageView.addSubview(overlayView) + + let absoluteHeight: CGFloat = originalImage.size.height / imageView.frame.size.height + let absoluteWidth: CGFloat = originalImage.size.width / imageView.frame.size.width + + overlayView.absoluteHeight = absoluteHeight + overlayView.absoluteWidth = absoluteWidth + + let detectedTopLeftPoint = CGPoint(x: detectedRectangleFeature.topLeft.x / CGFloat(absoluteWidth), y: imageView.frame.size.height - detectedRectangleFeature.topLeft.y / CGFloat(absoluteHeight)) + let detectedTopRightPoint = CGPoint(x: detectedRectangleFeature.topRight.x / CGFloat(absoluteWidth), y: imageView.frame.size.height - detectedRectangleFeature.topRight.y / CGFloat(absoluteHeight)) + let detectedBottomLeftPoint = CGPoint(x: detectedRectangleFeature.bottomLeft.x / CGFloat(absoluteWidth), y: imageView.frame.size.height - detectedRectangleFeature.bottomLeft.y / CGFloat(absoluteHeight)) + let detectedBottomRightPoint = CGPoint(x: detectedRectangleFeature.bottomRight.x / CGFloat(absoluteWidth), y: imageView.frame.size.height - detectedRectangleFeature.bottomRight.y / CGFloat(absoluteHeight)) + + overlayView.topLeftPath = overlayView.correct(detectedTopLeftPoint) + overlayView.topRightPath = overlayView.correct(detectedTopRightPoint) + overlayView.bottomLeftPath = overlayView.correct(detectedBottomLeftPoint) + overlayView.bottomRightPath = overlayView.correct(detectedBottomRightPoint) + + overlayView.initializeSubView() + } + } + func magnetDeActivated(){ + if let imageView = banner.pagerView.cellForItem(at: banner.pagerView.currentIndex)?.contentView { + + overlayView = CDOverlayView.init(frame: imageView.bounds) + overlayView.translatesAutoresizingMaskIntoConstraints = false + imageView.addSubview(overlayView) + + overlayView.initializeSubView() + + let margin: CGFloat = 60.0 + let absoluteHeight: CGFloat = originalImage.size.height / imageView.frame.size.height + let absoluteWidth: CGFloat = originalImage.size.width / imageView.frame.size.width + + overlayView.absoluteHeight = absoluteHeight + overlayView.absoluteWidth = absoluteWidth + + overlayView.topLeftPath = CGPoint(x: CGFloat(margin), y: CGFloat(margin)) + overlayView.topRightPath = CGPoint(x: CGFloat(imageView.frame.width - margin), y: CGFloat(margin)) + overlayView.bottomLeftPath = CGPoint(x: CGFloat(margin), y: CGFloat(imageView.frame.height - margin)) + overlayView.bottomRightPath = CGPoint(x: CGFloat(imageView.frame.width - margin), y: CGFloat(imageView.frame.height - margin)) + + overlayView.initializeSubView() + } + } + +} diff --git a/MiniScanner/Modules/EditViewController/EditViewController.xib b/MiniScanner/Modules/EditViewController/EditViewController.xib index 6109f3c10bb702ef9d9b2b035848d34aaa138308..417be6149ac2191c36d2334dec296a5c78072fae 100644 --- a/MiniScanner/Modules/EditViewController/EditViewController.xib +++ b/MiniScanner/Modules/EditViewController/EditViewController.xib @@ -339,6 +339,9 @@ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aAF-0j-Zva"> <rect key="frame" x="0.0" y="0.0" width="82" height="90"/> <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> + <connections> + <action selector="cropTapped:" destination="-1" eventType="touchUpInside" id="h0T-hj-rV0"/> + </connections> </button> </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> diff --git a/MiniScanner/Supporting Files/.DS_Store b/MiniScanner/Supporting Files/.DS_Store index c2fa1916ae96cee75a48220af50e8511e972e506..78a7ab646fb79374390768259e53bbf0dc892357 100644 Binary files a/MiniScanner/Supporting Files/.DS_Store and b/MiniScanner/Supporting Files/.DS_Store differ diff --git a/MiniScanner/Supporting Files/CDOverlay/CDCameraOverlayView.h b/MiniScanner/Supporting Files/CDOverlay/CDCameraOverlayView.h new file mode 100755 index 0000000000000000000000000000000000000000..773e4767ef2082dad1518f1250a6838139e6fc8a --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/CDCameraOverlayView.h @@ -0,0 +1,24 @@ +// +// CDCameraOverlayView.h +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import <UIKit/UIKit.h> + +@interface CDCameraOverlayView : UIView{ + + CGPoint _topLeftPoint; + CGPoint _topRightPoint; + CGPoint _bottomLeftPoint; + CGPoint _bottomRightPoint; + +} + +- (void)drawHighLightOverlayWithImage:(CIImage *)image topLeft:(CGPoint)topLeft topRight:(CGPoint)topRight bottomLeft:(CGPoint)bottomLeft bottomRight:(CGPoint)bottomRight; + +-(void)hideHightLightOverlay; + +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/CDCameraOverlayView.m b/MiniScanner/Supporting Files/CDOverlay/CDCameraOverlayView.m new file mode 100755 index 0000000000000000000000000000000000000000..6250ddb431b59c71afa0759be37ed113b9d768d2 --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/CDCameraOverlayView.m @@ -0,0 +1,83 @@ +// +// CDCameraOverlayView.m +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + + +#import "CDCameraOverlayView.h" +#import "CropperConstantValues.h" + +@implementation CDCameraOverlayView + +-(id)initWithFrame:(CGRect)frame{ + + self = [super initWithFrame:frame]; + if (self) { + + _topLeftPoint = CGPointZero; + _topRightPoint = CGPointZero; + + _bottomLeftPoint = CGPointZero; + _bottomRightPoint = CGPointZero; + + self.backgroundColor = [UIColor clearColor]; + + } + return self; +} +- (void)drawRect:(CGRect)rect { + // Drawing code + [super drawRect:rect]; + + CGContextRef c = UIGraphicsGetCurrentContext(); + CGContextSetShouldAntialias(c, YES); + + + + CGMutablePathRef path = CGPathCreateMutable(); + + CGPathMoveToPoint(path, nil, _topLeftPoint.x, _topLeftPoint.y); + CGPathAddLineToPoint(path, nil, _topRightPoint.x, _topRightPoint.y); + CGPathAddLineToPoint(path, nil, _bottomRightPoint.x, _bottomRightPoint.y); + CGPathAddLineToPoint(path, nil, _bottomLeftPoint.x, _bottomLeftPoint.y); + CGPathAddLineToPoint(path, nil, _topLeftPoint.x, _topLeftPoint.y); + + CGPathCloseSubpath(path); + CGContextAddPath(c, path); + UIColor *overlayColor = [[CropperConstantValues themeColor] colorWithAlphaComponent:0.3]; + CGContextSetFillColorWithColor(c, overlayColor.CGColor); + CGContextDrawPath(c, kCGPathFill); + CGPathRelease(path); + + CGContextStrokePath(c); + +} + +- (void)drawHighLightOverlayWithImage:(CIImage *)image topLeft:(CGPoint)topLeft topRight:(CGPoint)topRight bottomLeft:(CGPoint)bottomLeft bottomRight:(CGPoint)bottomRight{ + + CGFloat absHeight = image.extent.size.height / self.frame.size.height; + CGFloat absWidth = image.extent.size.width / self.frame.size.width; + + _topLeftPoint = CGPointMake(topLeft.x/absWidth, self.frame.size.height - topLeft.y/absHeight); + _topRightPoint = CGPointMake(topRight.x/absWidth,self.frame.size.height- topRight.y/absHeight); + _bottomLeftPoint = CGPointMake(bottomLeft.x/absWidth,self.frame.size.height- bottomLeft.y/absHeight); + _bottomRightPoint = CGPointMake(bottomRight.x/absWidth, self.frame.size.height - bottomRight.y/absHeight); + + + [self setNeedsDisplay]; +} + +-(void)hideHightLightOverlay{ + + _topLeftPoint = CGPointZero; + _topRightPoint = CGPointZero; + + _bottomLeftPoint = CGPointZero; + _bottomRightPoint = CGPointZero; + + [self setNeedsDisplay]; +} +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/CDCameraView.h b/MiniScanner/Supporting Files/CDOverlay/CDCameraView.h new file mode 100755 index 0000000000000000000000000000000000000000..e2ec9b9f67b3ab09b6720f5038c527531ded0808 --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/CDCameraView.h @@ -0,0 +1,41 @@ +// +// CDCameraView.h +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import <UIKit/UIKit.h> +#import "CropperConstantValues.h" + +#import "CDImageRectangleDetector.h" +#import "CDCameraOverlayView.h" + +typedef NS_ENUM(NSInteger,CDCameraViewType) +{ + CDCameraViewTypeGray, + CDCameraViewTypeColorful, + CDCameraViewTypeSepiaTone +}; + +@interface CDCameraView : UIView{ + + CDCameraOverlayView* _cameraOverlayView; +} + +- (void)initializeCameraScreen; + +- (void)start; +- (void)stop; + +@property (nonatomic,assign,getter=isBorderDetectionEnabled) BOOL enableBorderDetection; +@property (nonatomic,assign) CDCameraViewType cameraViewType; + +- (void)focusAtPoint:(CGPoint)point completionHandler:(void(^)())completionHandler; + +-(void)setCaptureFlashType:(BOOL )isOn; + +- (void)captureImageWithCompletionHander:(void(^)(id data))completionHandler; + +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/CDCameraView.m b/MiniScanner/Supporting Files/CDOverlay/CDCameraView.m new file mode 100755 index 0000000000000000000000000000000000000000..c517a3b963f2698ded44c1a0924537528befea0a --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/CDCameraView.m @@ -0,0 +1,384 @@ +// +// CDCameraView.m +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import "CDCameraView.h" + +#import <AVFoundation/AVFoundation.h> +#import <CoreMedia/CoreMedia.h> +#import <CoreVideo/CoreVideo.h> +#import <CoreImage/CoreImage.h> +#import <ImageIO/ImageIO.h> +#import <GLKit/GLKit.h> + +#define kDetectorDelay 0.35 + +@interface CDCameraView () <AVCaptureVideoDataOutputSampleBufferDelegate> + +@property (nonatomic,strong) AVCaptureSession *captureSession; +@property (nonatomic,strong) AVCaptureDevice *captureDevice; +@property (nonatomic, strong) AVCaptureStillImageOutput* stillImageOutput; + +@property (nonatomic,strong) EAGLContext *glContext; + +@property (nonatomic, assign) BOOL forceStop; + +@end + + +@implementation CDCameraView +{ + CIContext *_coreImageContext; + GLuint _renderBuffer; + GLKView *_glkView; + + BOOL _isStopped; + + CGFloat _imageDedectionConfidence; + NSTimer *_borderDetectTimeKeeper; + BOOL _borderDetectFrame; + CIRectangleFeature *_borderDetectLastRectangleFeature; + CDImageRectangleDetector* _detector; + + BOOL _isCapturing; +} + +- (void)awakeFromNib +{ + [super awakeFromNib]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didEnteredBackgroundMode) name:UIApplicationWillResignActiveNotification object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(becomeActiveMode) name:UIApplicationDidBecomeActiveNotification object:nil]; +} + + +- (void)createGLKView +{ + if (self.glContext) return; + + self.glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; + GLKView *view = [[GLKView alloc] initWithFrame:self.bounds]; + view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + view.translatesAutoresizingMaskIntoConstraints = YES; + view.context = self.glContext; + view.contentScaleFactor = 1.0f; + view.drawableDepthFormat = GLKViewDrawableDepthFormat24; + [self insertSubview:view atIndex:0]; + _glkView = view; + glGenRenderbuffers(1, &_renderBuffer); + glBindRenderbuffer(GL_RENDERBUFFER, _renderBuffer); + _coreImageContext = [CIContext contextWithEAGLContext:self.glContext]; + [EAGLContext setCurrentContext:self.glContext]; +} + +- (void)initializeCameraScreen +{ + [self createGLKView]; + + NSArray *possibleDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; + AVCaptureDevice *device = [possibleDevices firstObject]; + if (!device) return; + + + _imageDedectionConfidence = 0.0; + + AVCaptureSession *session = [[AVCaptureSession alloc] init]; + self.captureSession = session; + [session beginConfiguration]; + self.captureDevice = device; + + + NSError *error = nil; + AVCaptureDeviceInput* input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; + + + if (input) { + + session.sessionPreset = AVCaptureSessionPresetPhoto; + [session addInput:input]; + AVCaptureVideoDataOutput *dataOutput = [[AVCaptureVideoDataOutput alloc] init]; + [dataOutput setAlwaysDiscardsLateVideoFrames:YES]; + [dataOutput setVideoSettings:@{(id)kCVPixelBufferPixelFormatTypeKey:@(kCVPixelFormatType_32BGRA)}]; + [dataOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()]; + [session addOutput:dataOutput]; + + self.stillImageOutput = [[AVCaptureStillImageOutput alloc] init]; + [session addOutput:self.stillImageOutput]; + + _cameraOverlayView = [[CDCameraOverlayView alloc] initWithFrame:self.bounds]; + [self addSubview:_cameraOverlayView]; + + + AVCaptureConnection *connection = [dataOutput.connections firstObject]; + [connection setVideoOrientation:AVCaptureVideoOrientationPortrait]; + + if (device.isFlashAvailable) + { + [device lockForConfiguration:nil]; + [device setFlashMode:AVCaptureFlashModeOff]; + [device unlockForConfiguration]; + + if ([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) + { + [device lockForConfiguration:nil]; + [device setFocusMode:AVCaptureFocusModeContinuousAutoFocus]; + [device unlockForConfiguration]; + } + } + + + _detector = [CDImageRectangleDetector sharedDetector]; + + [session commitConfiguration]; + + }else{ + + NSLog(@"I havent camera"); + } +} + +- (void)setCameraViewType:(CDCameraViewType)cameraViewType +{ + UIBlurEffect * effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; + UIVisualEffectView *blurredBackground =[[UIVisualEffectView alloc] initWithEffect:effect]; + blurredBackground.frame = self.bounds; + [self insertSubview:blurredBackground aboveSubview:_glkView]; + + _cameraViewType = cameraViewType; + + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^ + { + [blurredBackground removeFromSuperview]; + }); +} + +-(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection +{ + if (self.forceStop) return; + if (_isStopped || _isCapturing || !CMSampleBufferIsValid(sampleBuffer)) return; + + CVPixelBufferRef pixelBuffer = (CVPixelBufferRef)CMSampleBufferGetImageBuffer(sampleBuffer); + + CIImage *image = [CIImage imageWithCVPixelBuffer:pixelBuffer]; + + if (self.isBorderDetectionEnabled) + { + if (_borderDetectFrame) + { + _borderDetectLastRectangleFeature = [_detector biggestRectangleInRectangles:[[_detector highAccuracyRectangleDetector] featuresInImage:image]]; + _borderDetectFrame = NO; + } + + if (_borderDetectLastRectangleFeature) + { + + _imageDedectionConfidence += .5; + +// image = [_detector drawHighlightOverlayForPoints:image topLeft:_borderDetectLastRectangleFeature.topLeft topRight:_borderDetectLastRectangleFeature.topRight bottomLeft:_borderDetectLastRectangleFeature.bottomLeft bottomRight:_borderDetectLastRectangleFeature.bottomRight]; + + [_cameraOverlayView drawHighLightOverlayWithImage:image + topLeft:_borderDetectLastRectangleFeature.topLeft + topRight:_borderDetectLastRectangleFeature.topRight + bottomLeft:_borderDetectLastRectangleFeature.bottomLeft + bottomRight:_borderDetectLastRectangleFeature.bottomRight]; + } + else + { + [_cameraOverlayView hideHightLightOverlay]; + _imageDedectionConfidence = 0.0f; + } + } + + if (self.glContext && _coreImageContext) + { + [_coreImageContext drawImage:image inRect:self.bounds fromRect:image.extent]; + [self.glContext presentRenderbuffer:GL_RENDERBUFFER]; + + [_glkView setNeedsDisplay]; + } +} + +- (void)enableBorderDetectFrame +{ + _borderDetectFrame = YES; +} + + +- (void)start +{ + _isStopped = NO; + + [self.captureSession startRunning]; + + _borderDetectTimeKeeper = [NSTimer scheduledTimerWithTimeInterval:kDetectorDelay target:self selector:@selector(enableBorderDetectFrame) userInfo:nil repeats:YES]; + + [self hideGLKView:NO completion:nil]; +} + +- (void)stop +{ + _isStopped = YES; + + [self.captureSession stopRunning]; + + [_borderDetectTimeKeeper invalidate]; + + [self hideGLKView:YES completion:nil]; +} + +-(void)setCaptureFlashType:(BOOL )isOn{ + + AVCaptureDevice *device = self.captureDevice; + if ([device hasFlash]) + { + [device lockForConfiguration:nil]; + + if (isOn) { + + [device setFlashMode:AVCaptureFlashModeOn]; + }else { + + [device setFlashMode:AVCaptureFlashModeOff]; + } + [device unlockForConfiguration]; + } +} + +- (void)focusAtPoint:(CGPoint)point completionHandler:(void(^)())completionHandler +{ + NSLog(@"Focus at point :%@",NSStringFromCGPoint(point)); + AVCaptureDevice *device = self.captureDevice; + CGPoint pointOfInterest = CGPointZero; + CGSize frameSize = self.bounds.size; + pointOfInterest = CGPointMake(point.y / frameSize.height, 1.f - (point.x / frameSize.width)); + + if ([device isFocusPointOfInterestSupported] && [device isFocusModeSupported:AVCaptureFocusModeAutoFocus]) + { + NSError *error; + if ([device lockForConfiguration:&error]) + { + if ([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) + { + [device setFocusMode:AVCaptureFocusModeContinuousAutoFocus]; + [device setFocusPointOfInterest:pointOfInterest]; + } + + if([device isExposurePointOfInterestSupported] && [device isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure]) + { + [device setExposurePointOfInterest:pointOfInterest]; + [device setExposureMode:AVCaptureExposureModeContinuousAutoExposure]; + completionHandler(); + } + + [device unlockForConfiguration]; + } + } + else + { + completionHandler(); + } +} + +- (void)captureImageWithCompletionHander:(void (^)(id))completionHandler +{ + [_cameraOverlayView hideHightLightOverlay]; + + if (_isCapturing) return; + + __weak typeof(self) weakSelf = self; + + [weakSelf hideGLKView:YES completion:^ + { + + [weakSelf hideGLKView:NO completion:^ + { + [weakSelf hideGLKView:YES completion:nil]; + }]; + }]; + + _isCapturing = YES; + + AVCaptureConnection *videoConnection = nil; + for (AVCaptureConnection *connection in self.stillImageOutput.connections) + { + for (AVCaptureInputPort *port in [connection inputPorts]) + { + if ([[port mediaType] isEqual:AVMediaTypeVideo] ) + { + videoConnection = connection; + break; + } + } + if (videoConnection) break; + } + + [self.stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error) + { + NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer]; + + if (weakSelf.cameraViewType == CDCameraViewTypeGray || weakSelf.isBorderDetectionEnabled) + { + CIImage *enhancedImage = [CIImage imageWithData:imageData]; + + UIGraphicsBeginImageContext(CGSizeMake(enhancedImage.extent.size.height, enhancedImage.extent.size.width)); + [[UIImage imageWithCIImage:enhancedImage scale:1.0 orientation:UIImageOrientationRight] drawInRect:CGRectMake(0,0, enhancedImage.extent.size.height, enhancedImage.extent.size.width)]; + UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + [weakSelf hideGLKView:NO completion:nil]; + completionHandler(image); + } + else + { + [weakSelf hideGLKView:NO completion:nil]; + completionHandler(imageData); + } + + _isCapturing = NO; + }]; +} + +- (void)hideGLKView:(BOOL)hidden completion:(void(^)())completion +{ + [UIView animateWithDuration:0.5 animations:^ + { + _glkView.alpha = (hidden) ? 0.0 : 1.0; + } + completion:^(BOOL finished) + { + if (!completion) return; + completion(); + }]; +} + +#pragma mark +#pragma mark notification handling , removing + +- (void)didEnteredBackgroundMode +{ + self.forceStop = YES; +} + +- (void)becomeActiveMode +{ + self.forceStop = NO; +} + +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + + + + + + + + +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/CDImageRectangleDetector.h b/MiniScanner/Supporting Files/CDOverlay/CDImageRectangleDetector.h new file mode 100755 index 0000000000000000000000000000000000000000..73cc0d4d3c4c8b385b80ff0b1bc15140ff4fef9a --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/CDImageRectangleDetector.h @@ -0,0 +1,39 @@ +// +// CDImageRectangleDetector.h +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import <Foundation/Foundation.h> +#import <UIKit/UIKit.h> +typedef enum { + + ImageFilterTypeColorful, + ImageFilterTypeGrayScale, + ImageFilterTypeBlackAndWhite, + ImageFilterTypeMono1, + ImageFilterTypeMono2, + ImageFilterTypeMono3, + ImageFilterTypeMono4, + ImageFilterTypeDefault + +} ImageFilterType; + +@interface CDImageRectangleDetector : NSObject + ++(CDImageRectangleDetector *)sharedDetector; + + +- (CIDetector *)highAccuracyRectangleDetector; +- (CIRectangleFeature *)biggestRectangleInRectangles:(NSArray *)rectangles; +- (CIImage *)drawHighlightOverlayForPoints:(CIImage *)image topLeft:(CGPoint)topLeft topRight:(CGPoint)topRight bottomLeft:(CGPoint)bottomLeft bottomRight:(CGPoint)bottomRight; + +-(UIImage *)imageFilter:(UIImage *) image type:(ImageFilterType)type; + +//rotate +- (UIImage *)rotatedImageWithDegree:(double)degree image:(UIImage*)image; + + +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/CDImageRectangleDetector.m b/MiniScanner/Supporting Files/CDOverlay/CDImageRectangleDetector.m new file mode 100755 index 0000000000000000000000000000000000000000..5c70082f477fc0579f47becdbf811e40bbd09731 --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/CDImageRectangleDetector.m @@ -0,0 +1,180 @@ +// +// CDImageRectangleDetector.m +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + + +#import "CDImageRectangleDetector.h" + +@implementation CDImageRectangleDetector + + +-(id)init{ + + self = [super init]; + if (self) { + + + } + + return self; +} + ++(CDImageRectangleDetector *)sharedDetector{ + + static CDImageRectangleDetector *sharedInstance = nil; + + if (sharedInstance == nil) { + sharedInstance = [[self alloc] init]; + } + + return sharedInstance; +} + +- (CIDetector *)highAccuracyRectangleDetector +{ + static CIDetector *detector = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^ + { + detector = [CIDetector detectorOfType:CIDetectorTypeRectangle context:nil options:@{CIDetectorAccuracy : CIDetectorAccuracyHigh}]; + }); + return detector; +} + + +- (CIRectangleFeature *)biggestRectangleInRectangles:(NSArray *)rectangles +{ + if (![rectangles count]) return nil; + + float halfPerimiterValue = 0; + + CIRectangleFeature *biggestRectangle = [rectangles firstObject]; + + for (CIRectangleFeature *rect in rectangles) + { + CGPoint p1 = rect.topLeft; + CGPoint p2 = rect.topRight; + CGFloat width = hypotf(p1.x - p2.x, p1.y - p2.y); + + CGPoint p3 = rect.topLeft; + CGPoint p4 = rect.bottomLeft; + CGFloat height = hypotf(p3.x - p4.x, p3.y - p4.y); + + CGFloat currentHalfPerimiterValue = height + width; + + if (halfPerimiterValue < currentHalfPerimiterValue) + { + halfPerimiterValue = currentHalfPerimiterValue; + biggestRectangle = rect; + } + } + + return biggestRectangle; +} + +- (CIImage *)drawHighlightOverlayForPoints:(CIImage *)image topLeft:(CGPoint)topLeft topRight:(CGPoint)topRight bottomLeft:(CGPoint)bottomLeft bottomRight:(CGPoint)bottomRight +{ + + CIImage* overlay = [CIImage imageWithColor:[CIColor colorWithRed:74.0/255.0 green:144.0/255.0 blue:226.0/255.0 alpha:0.6]]; + overlay = [overlay imageByCroppingToRect:image.extent]; + overlay = [overlay imageByApplyingFilter:@"CIPerspectiveTransformWithExtent" withInputParameters:@{@"inputExtent":[CIVector vectorWithCGRect:image.extent], + @"inputTopLeft":[CIVector vectorWithCGPoint:topLeft], + @"inputTopRight":[CIVector vectorWithCGPoint:topRight], + @"inputBottomLeft":[CIVector vectorWithCGPoint:bottomLeft], + @"inputBottomRight":[CIVector vectorWithCGPoint:bottomRight]}]; + + return [overlay imageByCompositingOverImage:image]; +} + +-(UIImage *)imageFilter:(UIImage *) image type:(ImageFilterType)type{ + + switch (type) { + case ImageFilterTypeGrayScale: + + return [self filteredImageWithImage:image brithtness:0.0 contrast:1.0 saturaction:0.0]; + + break; + + case ImageFilterTypeBlackAndWhite: + + return [self filteredImageWithImage:image brithtness:0.0 contrast:2.0 saturaction:0.0]; + + break; + case ImageFilterTypeMono4: + return [self filteredImageWithImage:image brithtness:0.5 contrast:1.5 saturaction:0.0]; + break; + case ImageFilterTypeMono1: + return [self filteredImageWithImage:image brithtness:0.6 contrast:3.5 saturaction:0.0]; + break; + case ImageFilterTypeMono2: + return [self filteredImageWithImage:image brithtness:0.5 contrast:3.0 saturaction:0.0]; + break; + case ImageFilterTypeMono3: + return [self filteredImageWithImage:image brithtness:0.2 contrast:1.5 saturaction:0.5]; + break; + case ImageFilterTypeDefault: + return image; + break; + default: + return [self filteredImageWithImage:image brithtness:0.0 contrast:3.0 saturaction:1.0]; + + break; + } + +} + +-(UIImage *)filteredImageWithImage:(UIImage *)image brithtness:(float)britntness contrast:(float)contrast saturaction:(float)saturaction{ + + CIImage *beginImage = [CIImage imageWithCGImage:image.CGImage]; + + CIImage *blackAndWhite = [CIFilter filterWithName:@"CIColorControls" keysAndValues:kCIInputImageKey, beginImage, + @"inputBrightness", [NSNumber numberWithFloat:britntness], + @"inputContrast", [NSNumber numberWithFloat:contrast], + @"inputSaturation", [NSNumber numberWithFloat:saturaction], nil].outputImage; + + CIImage *output = [CIFilter filterWithName:@"CIExposureAdjust" keysAndValues:kCIInputImageKey, blackAndWhite, nil].outputImage; + + CIContext *context = [CIContext contextWithOptions:nil]; + CGImageRef cgiimage = [context createCGImage:output fromRect:output.extent]; + //UIImage *newImage = [UIImage imageWithCGImage:cgiimage]; + UIImage *newImage = [UIImage imageWithCGImage:cgiimage scale:image.scale orientation:image.imageOrientation]; + CGImageRelease(cgiimage); + + return newImage; +} + +- (UIImage *)rotatedImageWithDegree:(double)degree image:(UIImage *)image{ + + // calculate the size of the rotated view's containing box for our drawing space + UIView *rotatedViewBox = [[UIView alloc] initWithFrame:CGRectMake(0,0,image.size.width, image.size.height)]; + CGAffineTransform t = CGAffineTransformMakeRotation(degree * M_PI / 180.0); + rotatedViewBox.transform = t; + CGSize rotatedSize = rotatedViewBox.frame.size; + // Create the bitmap context + UIGraphicsBeginImageContext(rotatedSize); + CGContextRef bitmap = UIGraphicsGetCurrentContext(); + + // Move the origin to the middle of the image so we will rotate and scale around the center. + CGContextTranslateCTM(bitmap, rotatedSize.width/2, rotatedSize.height/2); + + // // Rotate the image context + CGContextRotateCTM(bitmap, (degree * M_PI/ 180.0)); + + // Now, draw the rotated/scaled image into the context + CGContextScaleCTM(bitmap, 1.0, -1.0); + CGContextDrawImage(bitmap, CGRectMake(-image.size.width / 2, -image.size.height / 2, image.size.width, image.size.height), [image CGImage]); + + UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + return newImage; +} + + + + + +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/CDOverlayView.h b/MiniScanner/Supporting Files/CDOverlay/CDOverlayView.h new file mode 100755 index 0000000000000000000000000000000000000000..21fd027eed95a2ccb07b6e8c0297c630576ce1bd --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/CDOverlayView.h @@ -0,0 +1,39 @@ +// +// OverlayView.h +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + + +#import <UIKit/UIKit.h> +#import "SelectableRoundView.h" +#import "CDZoomView.h" + +@interface CDOverlayView : UIView<SelectabeRoundDelegate>{ + + CDZoomView* _zoomView; + + SelectableRoundView* _topLeftCornerView; + SelectableRoundView* _topRightCornerView; + SelectableRoundView* _bottomLeftCornerView; + SelectableRoundView* _bottomRightCornerView; + +} + +@property(nonatomic) CGPoint topLeftPath; +@property(nonatomic) CGPoint topRightPath; +@property(nonatomic) CGPoint bottomLeftPath; +@property(nonatomic) CGPoint bottomRightPath; + +@property(nonatomic) CGFloat absoluteWidth; +@property(nonatomic) CGFloat absoluteHeight; + +-(void)initializeSubView; + +-(UIImage *)cropImage:(UIImage *)image; + +-(CGPoint)correctPoint:(CGPoint )point; + +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/CDOverlayView.m b/MiniScanner/Supporting Files/CDOverlay/CDOverlayView.m new file mode 100755 index 0000000000000000000000000000000000000000..b732d6c70f4c01060e900c1761edb1a9447ca940 --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/CDOverlayView.m @@ -0,0 +1,299 @@ +// +// OverlayView.h +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + + +#import "CDOverlayView.h" +#import "CropperConstantValues.h" + +#define cornerHeight 30.0f + +@implementation CDOverlayView + +@synthesize topLeftPath, topRightPath, bottomLeftPath, bottomRightPath; +@synthesize absoluteHeight = _absoluteHeight; +@synthesize absoluteWidth = _absoluteWidth; + +-(id)initWithFrame:(CGRect)frame{ + + self = [super initWithFrame:frame]; + if (self) { + + self.backgroundColor = [UIColor clearColor]; + } + return self; +} + +-(void)initializeSubView{ + + if (!_topLeftCornerView) { + + _topLeftCornerView = [[SelectableRoundView alloc] initWithFrame:CGRectZero]; + _topLeftCornerView.delegate = self; + [self addSubview:_topLeftCornerView]; + + _topRightCornerView = [[SelectableRoundView alloc] initWithFrame:CGRectZero]; + _topRightCornerView.delegate = self; + [self addSubview:_topRightCornerView]; + + _bottomLeftCornerView = [[SelectableRoundView alloc] initWithFrame:CGRectZero]; + _bottomLeftCornerView.delegate = self; + [self addSubview:_bottomLeftCornerView]; + + _bottomRightCornerView = [[SelectableRoundView alloc] initWithFrame:CGRectZero]; + _bottomRightCornerView.delegate = self; + [self addSubview:_bottomRightCornerView]; + + + _zoomView = [[CDZoomView alloc] init]; + [self addSubview:_zoomView]; + [_zoomView zoomViewHide:YES]; + + } + + + [UIView animateWithDuration:0.3 animations:^{ + + + }]; + [self setNeedsDisplay]; + + [UIView transitionWithView:self + duration:0.3 + options:UIViewAnimationOptionCurveEaseInOut + animations:^{ + + [_topLeftCornerView setFrame:CGRectMake(topLeftPath.x - cornerHeight/2.0, topLeftPath.y - cornerHeight/2.0, cornerHeight, cornerHeight)]; + [_topRightCornerView setFrame:CGRectMake(topRightPath.x - cornerHeight/2.0, topRightPath.y - cornerHeight/2.0, cornerHeight, cornerHeight)]; + [_bottomLeftCornerView setFrame:CGRectMake(bottomLeftPath.x - cornerHeight/2.0, bottomLeftPath.y - cornerHeight/2.0, cornerHeight, cornerHeight)]; + [_bottomRightCornerView setFrame:CGRectMake(bottomRightPath.x - cornerHeight/2.0, bottomRightPath.y - cornerHeight/2.0, cornerHeight, cornerHeight)]; + + // Change the view's state + } + completion:^(BOOL finished) { + // Completion block + }]; +} + +-(UIImage *)cropImage:(UIImage *)image{ + + CGFloat overlayHeight = self.frame.size.height; + CIImage* rawImage = [[CIImage alloc] initWithImage:image]; + + NSMutableDictionary *rectangleCoordinates = [NSMutableDictionary new]; + rectangleCoordinates[@"inputTopLeft"] = [CIVector vectorWithCGPoint:CGPointMake(topLeftPath.x * _absoluteWidth, (overlayHeight - topLeftPath.y) * _absoluteHeight)]; + rectangleCoordinates[@"inputTopRight"] = [CIVector vectorWithCGPoint:CGPointMake(topRightPath.x * _absoluteWidth, (overlayHeight - topRightPath.y) * _absoluteHeight)]; + rectangleCoordinates[@"inputBottomLeft"] = [CIVector vectorWithCGPoint:CGPointMake(bottomLeftPath.x * _absoluteWidth, (overlayHeight - bottomLeftPath.y) * _absoluteHeight)]; + rectangleCoordinates[@"inputBottomRight"] = [CIVector vectorWithCGPoint:CGPointMake(bottomRightPath.x * _absoluteWidth, (overlayHeight - bottomRightPath.y) * _absoluteHeight)]; + rawImage = [rawImage imageByApplyingFilter:@"CIPerspectiveCorrection" withInputParameters:rectangleCoordinates]; + + CIContext *context = [CIContext contextWithOptions:nil]; + CGImageRef cgImage = [context createCGImage:rawImage fromRect:[rawImage extent]]; + + return [UIImage imageWithCGImage:cgImage]; +} + + +-(void)cornerPointDidChangingAt:(CGPoint)point corner:(SelectableRoundView *)cornerView{ + + CGFloat orignY = point.y; + + if (point.y < 30.0) { + + orignY = 30.0f; + }else if (point.y > self.frame.size.height - 30.0f){ + + orignY = self.frame.size.height - 30.0f; + } + + topLeftPath = _topLeftCornerView.center; + topRightPath = _topRightCornerView.center; + bottomLeftPath = _bottomLeftCornerView.center; + bottomRightPath = _bottomRightCornerView.center; + + [self setNeedsDisplay]; + + CGPoint newCenter = CGPointMake(point.x, orignY); + [_zoomView zoomViewHide:NO]; + [_zoomView setZoomCenter:newCenter]; +} +-(BOOL)canSwipeCornerView:(SelectableRoundView *)cornerView point:(CGPoint)point{ + + topLeftPath = _topLeftCornerView.center; + topRightPath = _topRightCornerView.center; + bottomLeftPath = _bottomLeftCornerView.center; + bottomRightPath = _bottomRightCornerView.center; + + NSLog(@"\n\n\nView size: %@",NSStringFromCGSize(self.frame.size)); + NSLog(@"can pan top left %@",NSStringFromCGPoint(topLeftPath)); + NSLog(@"can pan top right %@",NSStringFromCGPoint(topRightPath)); + NSLog(@"can pan bottom left %@",NSStringFromCGPoint(bottomLeftPath)); + NSLog(@"can pan bottom right %@\n\n",NSStringFromCGPoint(bottomRightPath)); + + + if (cornerView == _topLeftCornerView) { + + topLeftPath = point; + }else if (cornerView == _topRightCornerView){ + + topRightPath = point; + }else if (cornerView == _bottomLeftCornerView){ + + bottomLeftPath = point; + }else{ + + bottomRightPath =point; + } + CGPoint _vertices[4]; + + _vertices[0] = topLeftPath; + _vertices[1] = topRightPath; + _vertices[2] = bottomRightPath; + _vertices[3] = bottomLeftPath; + + + BOOL sign=false; + int n = 4; + for(int i=0;i<n;i++) + { + double dx1 = _vertices[(i+2)%n].x - _vertices[(i+1)%n].x; + double dy1 = _vertices[(i+2)%n].y-_vertices[(i+1)%n].y; + double dx2 = _vertices[i].x-_vertices[(i+1)%n].x; + double dy2 = _vertices[i].y-_vertices[(i+1)%n].y; + double zcrossproduct = dx1*dy2 - dy1*dx2; + if (i==0) + sign=zcrossproduct>0; + else + { + if (sign!=(zcrossproduct>0)) + + return NO; + } + } + return YES; +} + +-(void)cornerPointDidEndedChangeAt:(CGPoint)point corner:(SelectableRoundView *)cornerView{ + + if (cornerView == _topLeftCornerView) { + + //last dragged topLeftCornerView + topLeftPath = [self correctPoint:topLeftPath]; + [_topLeftCornerView setCenter:topLeftPath]; + + }else if (cornerView == _topRightCornerView){ + + //last dragged topRightCornerView + topRightPath = [self correctPoint:topRightPath]; + [_topRightCornerView setCenter:topRightPath]; + }else if (cornerView == _bottomLeftCornerView){ + + //last dragged bottomLeftCornerView + bottomLeftPath = [self correctPoint:bottomLeftPath]; + [_bottomLeftCornerView setCenter:bottomLeftPath]; + + }else{ + + //last dragged bottomRightCornerView + bottomRightPath = [self correctPoint:bottomRightPath]; + [_bottomRightCornerView setCenter:bottomRightPath]; + } + [self setNeedsDisplay]; + +} + +-(CGPoint)correctPoint:(CGPoint )point{ + + CGPoint thePoint = point; + + if (point.x < 0.0 || point.y < 0.0) { + + if (point.x < 0.0) { + + thePoint.x = 0.0; + } + if (point.y < 0.0) { + + thePoint.y = 0.0; + } + }else if (point.x < self.frame.size.width || point.y < self.frame.size.height){ + + if (point.x > self.frame.size.width) { + + thePoint.x = self.frame.size.width; + } + if (point.y > self.frame.size.height) { + + thePoint.y = self.frame.size.height; + } + + } + return thePoint; +} + +-(BOOL)isPathCanDrag:(CGPoint)point{ + + if (0.0 < point.x < self.frame.size.width && 0.0 < point.y < self.frame.size.height) { + + return YES; + }else{ + + return NO; + } +} + + +-(void)cornerPointDidChanged{ + + [_zoomView zoomViewHide:YES]; +} + +- (void)drawRect:(CGRect)rect +{ + [super drawRect:rect]; + + CGContextRef c = UIGraphicsGetCurrentContext(); + CGContextSetShouldAntialias(c, YES); + + + CGContextSetStrokeColorWithColor(c, [CropperConstantValues themeColor].CGColor); + CGContextSetLineWidth(c, 1.0); + float lineMargin = 0.0f; + + + CGContextMoveToPoint(c,topLeftPath.x + lineMargin, topLeftPath.y + lineMargin); + CGContextAddLineToPoint(c,topRightPath.x - lineMargin, topRightPath.y + lineMargin); + CGContextAddLineToPoint(c, bottomRightPath.x - lineMargin, bottomRightPath.y - lineMargin); + CGContextAddLineToPoint(c,bottomLeftPath.x +lineMargin , bottomLeftPath.y - lineMargin); + CGContextAddLineToPoint(c,topLeftPath.x + lineMargin, topLeftPath.y + lineMargin); + CGContextStrokePath(c); + + + CGMutablePathRef path = CGPathCreateMutable(); + + CGPathMoveToPoint(path, nil, rect.origin.x, rect.origin.y); + CGPathAddLineToPoint(path, nil, rect.origin.x + rect.size.width, rect.origin.y); + CGPathAddLineToPoint(path, nil, rect.origin.x + rect.size.width, rect.origin.y + rect.size.height); + CGPathAddLineToPoint(path, nil, rect.origin.x, rect.origin.y + rect.size.height); + CGPathAddLineToPoint(path, nil, rect.origin.x, bottomLeftPath.y); + CGPathAddLineToPoint(path, nil, bottomLeftPath.x, bottomLeftPath.y); + CGPathAddLineToPoint(path, nil, bottomRightPath.x, bottomRightPath.y); + CGPathAddLineToPoint(path, nil, topRightPath.x, topRightPath.y); + CGPathAddLineToPoint(path, nil, topLeftPath.x, topLeftPath.y); + CGPathAddLineToPoint(path, nil, bottomLeftPath.x, bottomLeftPath.y); + CGPathAddLineToPoint(path, nil, rect.origin.x, bottomLeftPath.y); + CGPathCloseSubpath(path); + CGContextAddPath(c, path); + UIColor *overlayColor = [UIColor colorWithWhite:0.0 alpha:0.4]; + CGContextSetFillColorWithColor(c, overlayColor.CGColor); + CGContextDrawPath(c, kCGPathFill); + CGPathRelease(path); + + CGContextStrokePath(c); + +} +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/CDZoomView.h b/MiniScanner/Supporting Files/CDOverlay/CDZoomView.h new file mode 100755 index 0000000000000000000000000000000000000000..4a42faa4543b4ad092f23eeda5cd2feda491275f --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/CDZoomView.h @@ -0,0 +1,24 @@ +// +// CDZoomView.h +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import <UIKit/UIKit.h> + +@interface CDZoomView : UIView{ + + CGPoint _currentCenter; + CGPoint _cornerCenter; +} + +-(void)setZoomScale:(CGFloat)scale; + +-(void)setZoomCenter:(CGPoint)point; +-(void)zoomViewHide:(BOOL)hide; + +-(void)setDragingEnabled:(BOOL)enabled; + +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/CDZoomView.m b/MiniScanner/Supporting Files/CDOverlay/CDZoomView.m new file mode 100755 index 0000000000000000000000000000000000000000..442ad5570a0e84d7cfcc41c120ee37da9d9ae355 --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/CDZoomView.m @@ -0,0 +1,166 @@ +// +// CDZoomView.m +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import "CDZoomView.h" + +#define kSelectorWidth 60.0f +#define kHideAnimationDuraction 0.15f + +@interface CDZoomView () +{ + float oldX, oldY; + BOOL dragging; +} +@property (nonatomic, strong) UIView *parentView; +@property (nonatomic, assign) CGFloat zoomScale; +@end + +@implementation CDZoomView + +- (id)init +{ + self = [super initWithFrame:CGRectMake(0.0, 0.0, 120.0, 120.0)]; + if (self) { + // Initialization code + + [self setBackgroundColor:[UIColor clearColor]]; + [self setClipsToBounds:YES]; + + _zoomScale = 2.0; + [self setDragingEnabled:NO]; + + UIPanGestureRecognizer* pgr = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; + [self addGestureRecognizer:pgr]; + + [self setZoomScale:3.0]; + [self setDragingEnabled:YES]; + [self.layer setBorderColor:[UIColor grayColor].CGColor]; + [self.layer setBorderWidth:3.0]; + [self.layer setCornerRadius:60]; + + } + return self; +} + +- (void)willMoveToSuperview:(UIView *)newSuperview +{ + _parentView = newSuperview; +} + + +- (void)setDragingEnabled:(BOOL)enabled +{ + [self setUserInteractionEnabled:enabled]; +} + +- (void)drawRect:(CGRect)rect +{ + + // Set the corrext area we want to zoom in to + CGContextRef context = UIGraphicsGetCurrentContext(); + CGContextTranslateCTM(context, (self.frame.size.width / 2), (self.frame.size.height / 2)); + CGContextScaleCTM(context, _zoomScale, _zoomScale); + CGContextTranslateCTM(context, -_cornerCenter.x, -_cornerCenter.y); + + [self setHidden:YES]; + + [_parentView.layer.superlayer renderInContext:context]; + [self setHidden:NO]; +} + +#pragma mark - Private + + +-(void)setZoomCenter:(CGPoint)point{ + + float margin = self.frame.size.width/2.0f + 20.0f; + + if (point.y < 200.0f) { + + if (point.x < 140.0) { + + [self setViewCenter:CGPointMake(_parentView.frame.size.width - margin, margin)]; + + }else if (point.x < _parentView.frame.size.width - 140.0){ + + [self setViewCenter:CGPointMake(margin, margin)]; + + }else{ + + + [self setViewCenter:CGPointMake(_parentView.frame.size.width/2.0, margin)]; + + } + + }else{ + + [self setViewCenter:CGPointMake(_parentView.frame.size.width/2.0, margin)]; + + } + + _cornerCenter = point; + [self setNeedsDisplay]; +} + +-(void)zoomViewHide:(BOOL)hide{ + + if (hide && !self.isHidden) { + + [UIView animateWithDuration:kHideAnimationDuraction animations:^{ + + self.alpha = 0.0f; + } completion:^(BOOL finished) { + + self.hidden = hide; + }]; + + + }else if (!hide && self.isHidden){ + + [UIView animateWithDuration:kHideAnimationDuraction animations:^{ + + self.alpha = 1.0f; + } completion:^(BOOL finished) { + + self.hidden = hide; + }]; + } +} +-(void)setViewCenter:(CGPoint)center{ + + if (_currentCenter.x != center.x) { + + [UIView animateWithDuration:0.3 animations:^{ + self.center = center; + + } completion:^(BOOL finished) { + + _currentCenter = center; + }]; + + } +} +- (void)handlePan:(UIPanGestureRecognizer*)pgr; +{ + // Here we handle the dragging of the zoom view + + if (pgr.state == UIGestureRecognizerStateChanged) + { + CGPoint center = pgr.view.center; + CGPoint translation = [pgr translationInView:pgr.view]; + center = CGPointMake(center.x + translation.x, + center.y + translation.y); + pgr.view.center = center; + + [pgr setTranslation:CGPointZero inView:pgr.view]; + [self setNeedsDisplay]; + + } +} +@end + diff --git a/MiniScanner/Supporting Files/CDOverlay/CropperConstantValues.h b/MiniScanner/Supporting Files/CDOverlay/CropperConstantValues.h new file mode 100755 index 0000000000000000000000000000000000000000..259dad3a836846dd8a2512dcc46c3bd29d77232d --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/CropperConstantValues.h @@ -0,0 +1,23 @@ +// +// CropperConstantValues.h +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import <Foundation/Foundation.h> +#import <UIKit/UIKit.h> + + +@interface CropperConstantValues : NSObject + ++(UIColor *)themeColor; ++(UIColor *)standartBackgroundColor; ++(UIColor *)doneButtonColor; + ++(CGFloat)pictureSelectorHeaderViewHeight; ++(CGFloat)pictureSelectorFooterViewHeight; ++(CGFloat)processFooterViewHeight; + +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/CropperConstantValues.m b/MiniScanner/Supporting Files/CDOverlay/CropperConstantValues.m new file mode 100755 index 0000000000000000000000000000000000000000..938eebd6055c05d95f6411ba3675765878ea0283 --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/CropperConstantValues.m @@ -0,0 +1,48 @@ +// +// CropperConstantValues.m +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import "CropperConstantValues.h" + +@implementation CropperConstantValues + + ++(UIColor *)themeColor{ + + return [UIColor colorWithRed:43.0/255.0 green:106.0/255.0 blue:221.0/255.0 alpha:1.0f]; +} + ++(UIColor *)standartBackgroundColor{ + + return [UIColor blackColor]; +} + ++(UIColor *)doneButtonColor{ + + return [UIColor colorWithRed:255.0/255.0 green:194.0/255.0 blue:24.0/255.0 alpha:1.0f]; +} ++(CGFloat)pictureSelectorHeaderViewHeight{ + + return 64.0f; +} + ++(CGFloat)pictureSelectorFooterViewHeight{ + + return 74.0f; +} + ++(CGFloat)processFooterViewHeight{ + + return 49.0f; +} + ++(BOOL)canRectangleDetect{ + + if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) return YES; + else return NO; +} +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/DefaultValues.h b/MiniScanner/Supporting Files/CDOverlay/DefaultValues.h new file mode 100755 index 0000000000000000000000000000000000000000..ff7d66e99faea60089bed530f1eb604297d1fbbb --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/DefaultValues.h @@ -0,0 +1,18 @@ +// +// DefaultValues.h +// Document Scanner +// +// Created by CoDesign on 8/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import <Foundation/Foundation.h> + +@interface DefaultValues : NSObject + ++(NSString *)languageToRecognize; ++(NSArray *)adsenseTestDevices; ++(BOOL)isAdmobActive; + + +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/DefaultValues.m b/MiniScanner/Supporting Files/CDOverlay/DefaultValues.m new file mode 100755 index 0000000000000000000000000000000000000000..1e1a3186890ea446b06346806eb9b6f85d44a0cb --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/DefaultValues.m @@ -0,0 +1,26 @@ +// +// DefaultValues.m +// Document Scanner +// +// Created by CoDesign on 8/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import "DefaultValues.h" + + +@implementation DefaultValues + ++(NSString *)languageToRecognize{ + + return @"eng"; +// return @"jpn+kor+ita+eng+por+rus+chi"; +// return @"chi_sim+jpn+kor+ita+eng+por+rus"; +} + + ++(BOOL)isAdmobActive{ + + return NO; +} +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/FlashButton.h b/MiniScanner/Supporting Files/CDOverlay/FlashButton.h new file mode 100755 index 0000000000000000000000000000000000000000..da598a1ff704614047e8c08aa49d4433b65ecf83 --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/FlashButton.h @@ -0,0 +1,23 @@ +// +// FlashButton.h +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import <UIKit/UIKit.h> + +@interface FlashButton : UIButton{ + + UIImageView* _flashIconView; + UILabel* _flashTypeLabel; + + BOOL _flashIsON; +} + +-(void)changeFlashType:(BOOL)isOn; + +-(BOOL)flashTypeIsON; + +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/FlashButton.m b/MiniScanner/Supporting Files/CDOverlay/FlashButton.m new file mode 100755 index 0000000000000000000000000000000000000000..88389c554c2cc6a93bdb571ff6d289bf68b83f81 --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/FlashButton.m @@ -0,0 +1,57 @@ +// +// FlashButton.m +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import "FlashButton.h" + +@implementation FlashButton + + +-(id)initWithFrame:(CGRect)frame{ + + self = [super initWithFrame:frame]; + if (self) { + + self.backgroundColor = [UIColor clearColor]; + + _flashIconView = [[UIImageView alloc] initWithFrame:CGRectMake(22.0, 16.0, 16.0, 24.0)]; + [self addSubview:_flashIconView]; + + _flashTypeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 43.0, 60.0, 12.0f)]; + _flashTypeLabel.textAlignment = NSTextAlignmentCenter; + _flashTypeLabel.font = [UIFont systemFontOfSize:10]; + _flashTypeLabel.textColor = [UIColor whiteColor]; + [self addSubview:_flashTypeLabel]; + + [self changeFlashType:NO]; + } + + return self; +} + +-(void)changeFlashType:(BOOL)isOn{ + + if (isOn) { + + [_flashIconView setImage:[UIImage imageNamed:@"flash_on"]]; + [_flashTypeLabel setText:@"FLASH ON"]; + }else{ + + [_flashIconView setImage:[UIImage imageNamed:@"flash_off_icon"]]; + [_flashTypeLabel setText:@"FLASH OFF"]; + } + + _flashIsON = isOn; +} + + +-(BOOL)flashTypeIsON{ + + return _flashIsON; +} + +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/SelectableRoundView.h b/MiniScanner/Supporting Files/CDOverlay/SelectableRoundView.h new file mode 100755 index 0000000000000000000000000000000000000000..bac4f26ed86ed74da7f7e926385903abf73a4fca --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/SelectableRoundView.h @@ -0,0 +1,30 @@ +// +// SelectableRoundView.h +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import <UIKit/UIKit.h> +@class SelectableRoundView; + +@protocol SelectabeRoundDelegate <NSObject> + +-(void)cornerPointDidChangingAt:(CGPoint)point corner:(SelectableRoundView *)cornerView; +-(void)cornerPointDidEndedChangeAt:(CGPoint)point corner:(SelectableRoundView *)cornerView; + +-(void)cornerPointDidChanged; + +-(BOOL)canSwipeCornerView:(SelectableRoundView *)cornerView point:(CGPoint)point; + +@end +@interface SelectableRoundView : UIView{ + + UIImageView* _pointerView; +} + + +@property(nonatomic, weak) id<SelectabeRoundDelegate> delegate; + +@end diff --git a/MiniScanner/Supporting Files/CDOverlay/SelectableRoundView.m b/MiniScanner/Supporting Files/CDOverlay/SelectableRoundView.m new file mode 100755 index 0000000000000000000000000000000000000000..f5b554610ed9e02fca1825f4b6216f3c14516d27 --- /dev/null +++ b/MiniScanner/Supporting Files/CDOverlay/SelectableRoundView.m @@ -0,0 +1,76 @@ +// +// SelectableRoundView.m +// Document Scanner +// +// Created by CoDesign on 7/23/15. +// Copyright (c) 2015 codesign2015. All rights reserved. +// + +#import "SelectableRoundView.h" +#import "CropperConstantValues.h" + +@implementation SelectableRoundView + +@synthesize delegate = _delegate; + +-(id)initWithFrame:(CGRect)frame{ + + self = [super initWithFrame:frame]; + + if (self) { + + self.backgroundColor = [[CropperConstantValues themeColor] colorWithAlphaComponent:0.3]; + self.clipsToBounds = YES; + self.layer.cornerRadius = 15.f; + self.layer.borderColor = [CropperConstantValues themeColor].CGColor; + self.layer.borderWidth = 1.0f; + + _pointerView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pointer"]]; + _pointerView.center = self.center; + [self addSubview:_pointerView]; + + UIPanGestureRecognizer* pgr = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; + [self addGestureRecognizer:pgr]; + + } + return self; +} + +- (void)handlePan:(UIPanGestureRecognizer*)pgr; +{ + // Here we handle the dragging of the zoom view + + if (pgr.state == UIGestureRecognizerStateChanged) + { + [self setBackgroundColor:[UIColor clearColor]]; + self.layer.borderColor = [UIColor clearColor].CGColor; + _pointerView.hidden = NO; + + CGPoint center = pgr.view.center; + CGPoint translation = [pgr translationInView:pgr.view]; + center = CGPointMake(center.x + translation.x, + center.y + translation.y); + + + if ([self.delegate canSwipeCornerView:self point:center]) { + + + pgr.view.center = center; + [pgr setTranslation:CGPointZero inView:pgr.view]; + [self setNeedsDisplay]; + + [self.delegate cornerPointDidChangingAt:center corner:self]; + } + + }else{ + + [self.delegate cornerPointDidEndedChangeAt:pgr.view.center corner:self]; + + self.backgroundColor = [[CropperConstantValues themeColor] colorWithAlphaComponent:0.3]; + self.layer.borderColor = [CropperConstantValues themeColor].CGColor; + _pointerView.hidden = YES; + [self.delegate cornerPointDidChanged]; + } +} + +@end diff --git a/MiniScanner/Supporting Files/FontChooserContainerView.swift b/MiniScanner/Supporting Files/FontChooserContainerView.swift new file mode 100644 index 0000000000000000000000000000000000000000..9dafde4453519c43077ee30d07b3533f0790e4e9 --- /dev/null +++ b/MiniScanner/Supporting Files/FontChooserContainerView.swift @@ -0,0 +1,257 @@ +// +// FontChooserContainerView.swift +// PDFScanner +// +// Created by George Makhoul on 29/05/2024. +// + +import UIKit +import ZLImageEditor + +class FontChooserContainerView: UIView, ZLTextFontChooserDelegate { + static let baseViewH: CGFloat = 400 + + var baseView: UIView! + + var collectionView: UICollectionView! + + var selectFontBlock: ((UIFont) -> Void)? + + var hideBlock: (() -> Void)? + + private var fontsRegistered: Bool = false + + private var fonts: [String] { + return [ + "AmericanTypewriter", + "Avenir-Heavy", + "ChalkboardSE-Regular", + "ArialMT", + "BanglaSangamMN", + "Liberator", + "Muncie", + "Abraham Lincoln", + "Airship 27", + "Arvil", + "Bender", + "Blanch", + "Cubano", + "Franchise", + "Geared Slab", + "Governor", + "Haymaker", + "Homestead", + "Maven Pro Light", + "Mensch", + "Sullivan", + "Tommaso", + "Valencia", + "Vevey" + ] + } + + override init(frame: CGRect) { + super.init(frame: frame) + self.setupUI() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func layoutSubviews() { + super.layoutSubviews() + + let path = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: self.frame.width, height: FontChooserContainerView.baseViewH), byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize(width: 8, height: 8)) + self.baseView.layer.mask = nil + let maskLayer = CAShapeLayer() + maskLayer.path = path.cgPath + self.baseView.layer.mask = maskLayer + } + + private func importFonts() { + if !fontsRegistered { + importFonts(with: "ttf") + importFonts(with: "otf") + fontsRegistered.toggle() + } + } + + private func importFonts(with fileExtension: String) { + let paths = Bundle(for: FontChooserContainerView.self).paths(forResourcesOfType: fileExtension, inDirectory: nil) + for fontPath in paths { + let data: Data? = FileManager.default.contents(atPath: fontPath) + var error: Unmanaged<CFError>? + let provider = CGDataProvider(data: data! as CFData) + let font = CGFont(provider!) + + if (!CTFontManagerRegisterGraphicsFont(font!, &error)) { + print("Failed to register font, error: \(String(describing: error))") + return + } + } + } + + + func setupUI() { + importFonts() + self.baseView = UIView() + self.addSubview(self.baseView) + self.baseView.snp.makeConstraints { (make) in + make.left.right.equalTo(self) + make.bottom.equalTo(self.snp.bottom).offset(FontChooserContainerView.baseViewH) + make.height.equalTo(FontChooserContainerView.baseViewH) + } + + let visualView = UIVisualEffectView(effect: UIBlurEffect(style: .dark)) + self.baseView.addSubview(visualView) + visualView.snp.makeConstraints { (make) in + make.edges.equalTo(self.baseView) + } + + let toolView = UIView() + toolView.backgroundColor = UIColor(white: 0.4, alpha: 0.4) + self.baseView.addSubview(toolView) + toolView.snp.makeConstraints { (make) in + make.top.left.right.equalTo(self.baseView) + make.height.equalTo(50) + } + + let hideBtn = UIButton(type: .custom) + hideBtn.setImage(UIImage(named: "close"), for: .normal) + hideBtn.backgroundColor = .clear + hideBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14) + hideBtn.addTarget(self, action: #selector(hideBtnClick), for: .touchUpInside) + toolView.addSubview(hideBtn) + hideBtn.snp.makeConstraints { (make) in + make.centerY.equalTo(toolView) + make.right.equalTo(toolView).offset(-20) + make.size.equalTo(CGSize(width: 40, height: 40)) + } + + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .vertical + layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10) + layout.minimumLineSpacing = 5 + layout.minimumInteritemSpacing = 5 + self.collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) + self.collectionView.backgroundColor = .clear + self.collectionView.delegate = self + self.collectionView.dataSource = self + self.baseView.addSubview(self.collectionView) + self.collectionView.snp.makeConstraints { (make) in + make.top.equalTo(toolView.snp.bottom) + make.left.right.bottom.equalTo(self.baseView) + } + + self.collectionView.register(FontCell.self, forCellWithReuseIdentifier: NSStringFromClass(FontCell.classForCoder())) + + let tap = UITapGestureRecognizer(target: self, action: #selector(hideBtnClick)) + tap.delegate = self + self.addGestureRecognizer(tap) + } + + @objc func hideBtnClick() { + self.hide() + } + + func show(in view: UIView) { + if self.superview !== view { + self.removeFromSuperview() + + view.addSubview(self) + self.snp.makeConstraints { (make) in + make.edges.equalTo(view) + } + view.layoutIfNeeded() + } + + self.isHidden = false + UIView.animate(withDuration: 0.25) { + self.baseView.snp.updateConstraints { (make) in + make.bottom.equalTo(self.snp.bottom) + } + view.layoutIfNeeded() + } + } + + func hide() { + self.hideBlock?() + + UIView.animate(withDuration: 0.25) { + self.baseView.snp.updateConstraints { (make) in + make.bottom.equalTo(self.snp.bottom).offset(FontChooserContainerView.baseViewH) + } + self.superview?.layoutIfNeeded() + } completion: { (_) in + self.isHidden = true + } + + } + +} + + +extension FontChooserContainerView: UIGestureRecognizerDelegate { + + public override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { + let location = gestureRecognizer.location(in: self) + return !self.baseView.frame.contains(location) + } + +} + + +extension FontChooserContainerView: UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let column: CGFloat = 2 + let spacing: CGFloat = 20 + 5 * (column - 1) + let w = (collectionView.frame.width - spacing) / column + return CGSize(width: w, height: 30) + } + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return fonts.count + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: NSStringFromClass(FontCell.classForCoder()), for: indexPath) as! FontCell + + let font = UIFont(name: fonts[indexPath.row], size: 20) + cell.label.font = font + cell.label.text = fonts[indexPath.row] + + return cell + } + + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + guard let font = UIFont(name: fonts[indexPath.row], size: 20) else { + return + } + self.selectFontBlock?(font) + self.hide() + } +} + + +class FontCell: UICollectionViewCell { + + var label: UILabel! + + override init(frame: CGRect) { + super.init(frame: frame) + + self.label = UILabel() + self.label.textAlignment = .center + self.label.textColor = .white + self.contentView.addSubview(self.label) + self.label.snp.makeConstraints { (make) in + make.center.equalTo(self.contentView) + } + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/MiniScanner/Supporting Files/Fonts/.DS_Store b/MiniScanner/Supporting Files/Fonts/.DS_Store index 4b7c1a1adca3a52e54ffdd27da7d1c1f0aa10d84..c9e574b9b733d09356cdcd1695fd52bf2109b611 100644 Binary files a/MiniScanner/Supporting Files/Fonts/.DS_Store and b/MiniScanner/Supporting Files/Fonts/.DS_Store differ diff --git a/MiniScanner/Supporting Files/Fonts1/AbrahamLincoln.ttf b/MiniScanner/Supporting Files/Fonts1/AbrahamLincoln.ttf new file mode 100755 index 0000000000000000000000000000000000000000..3e3f21cbcc32af2f88cca77f92fce247749934bc Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/AbrahamLincoln.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/Airship 27-Regular.ttf b/MiniScanner/Supporting Files/Fonts1/Airship 27-Regular.ttf new file mode 100755 index 0000000000000000000000000000000000000000..0c0232318ed4784f1c93f54cd30707efe52f4e75 Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/Airship 27-Regular.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/Arvil_Sans.ttf b/MiniScanner/Supporting Files/Fonts1/Arvil_Sans.ttf new file mode 100755 index 0000000000000000000000000000000000000000..4790d6c9912cabc1fa98eeb691c0e283fa99b7de Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/Arvil_Sans.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/BLANCH_CONDENSED.otf b/MiniScanner/Supporting Files/Fonts1/BLANCH_CONDENSED.otf new file mode 100755 index 0000000000000000000000000000000000000000..5bd1a5b3b3816b0c01677f0e712387629d3b4d6c Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/BLANCH_CONDENSED.otf differ diff --git a/MiniScanner/Supporting Files/Fonts1/Bender-Inline.otf b/MiniScanner/Supporting Files/Fonts1/Bender-Inline.otf new file mode 100755 index 0000000000000000000000000000000000000000..cbda5c4f06b7eda35deaa5d3a3075a7cfe47ef2c Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/Bender-Inline.otf differ diff --git a/MiniScanner/Supporting Files/Fonts1/Franchise-Bold.ttf b/MiniScanner/Supporting Files/Fonts1/Franchise-Bold.ttf new file mode 100755 index 0000000000000000000000000000000000000000..75d0b33b6778ecacbb57cc3961992d97d7baae63 Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/Franchise-Bold.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/GearedSlab.ttf b/MiniScanner/Supporting Files/Fonts1/GearedSlab.ttf new file mode 100755 index 0000000000000000000000000000000000000000..d7a41e3e6a62370df863fb0287226c230afe9f15 Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/GearedSlab.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/Haymaker.ttf b/MiniScanner/Supporting Files/Fonts1/Haymaker.ttf new file mode 100755 index 0000000000000000000000000000000000000000..84c1681038cd29ac0ae35ae3add48e02991235df Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/Haymaker.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/Homestead-Regular.ttf b/MiniScanner/Supporting Files/Fonts1/Homestead-Regular.ttf new file mode 100755 index 0000000000000000000000000000000000000000..a9acc09be47edd12029728fe27f6e2248e40c300 Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/Homestead-Regular.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/Liberator.ttf b/MiniScanner/Supporting Files/Fonts1/Liberator.ttf new file mode 100755 index 0000000000000000000000000000000000000000..8197788c0307237d01a3fb37bca69915d7dd6de4 Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/Liberator.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/MavenProLight-200.otf b/MiniScanner/Supporting Files/Fonts1/MavenProLight-200.otf new file mode 100755 index 0000000000000000000000000000000000000000..9df40f4126157005b2b40125a1e166b0db72768f Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/MavenProLight-200.otf differ diff --git a/MiniScanner/Supporting Files/Fonts1/Muncie.ttf b/MiniScanner/Supporting Files/Fonts1/Muncie.ttf new file mode 100755 index 0000000000000000000000000000000000000000..66b2957753698be61edafe822f64a3a5f6c62f49 Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/Muncie.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/Sullivan-Regular.otf b/MiniScanner/Supporting Files/Fonts1/Sullivan-Regular.otf new file mode 100755 index 0000000000000000000000000000000000000000..fae44877f5b7d5cbcd2efed2b7552cd7d9060273 Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/Sullivan-Regular.otf differ diff --git a/MiniScanner/Supporting Files/Fonts1/Tommaso.ttf b/MiniScanner/Supporting Files/Fonts1/Tommaso.ttf new file mode 100755 index 0000000000000000000000000000000000000000..fa3d6e337c9769f1f5743427fea3523d9995e745 Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/Tommaso.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/ValenciaRegular.otf b/MiniScanner/Supporting Files/Fonts1/ValenciaRegular.otf new file mode 100755 index 0000000000000000000000000000000000000000..eb46a1400e51330835d0841b58bcf2eeccd1acc3 Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/ValenciaRegular.otf differ diff --git a/MiniScanner/Supporting Files/Fonts1/cubano-regular-webfont.ttf b/MiniScanner/Supporting Files/Fonts1/cubano-regular-webfont.ttf new file mode 100755 index 0000000000000000000000000000000000000000..4e138f6f89f04686a9c6f7ee2c18251683aa788b Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/cubano-regular-webfont.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/governor.ttf b/MiniScanner/Supporting Files/Fonts1/governor.ttf new file mode 100755 index 0000000000000000000000000000000000000000..6aa36625199c209f0502a2dab3c31b979ca82bcb Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/governor.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/mensch.ttf b/MiniScanner/Supporting Files/Fonts1/mensch.ttf new file mode 100755 index 0000000000000000000000000000000000000000..ed75a2e7947ebf84584791f65c083c21fe015044 Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/mensch.ttf differ diff --git a/MiniScanner/Supporting Files/Fonts1/vevey.ttf b/MiniScanner/Supporting Files/Fonts1/vevey.ttf new file mode 100755 index 0000000000000000000000000000000000000000..67ccd8f861d42cb206a570f4520185823f986371 Binary files /dev/null and b/MiniScanner/Supporting Files/Fonts1/vevey.ttf differ diff --git a/MiniScanner/Supporting Files/ImageStickerContainerView.swift b/MiniScanner/Supporting Files/ImageStickerContainerView.swift new file mode 100644 index 0000000000000000000000000000000000000000..8df375b55238f29210d6eb17c1156bf507c0daa2 --- /dev/null +++ b/MiniScanner/Supporting Files/ImageStickerContainerView.swift @@ -0,0 +1,208 @@ +// +// ImageStickerContainerView.swift +// PDFScanner +// +// Created by George Makhoul on 29/05/2024. +// + +import UIKit +import ZLImageEditor + +class ImageStickerContainerView: UIView, ZLImageStickerContainerDelegate { + + static let baseViewH: CGFloat = 400 + + var baseView: UIView! + + var collectionView: UICollectionView! + + var selectImageBlock: ((UIImage) -> Void)? + + var hideBlock: (() -> Void)? + + let datas = { + (1...18).map { (v) -> String in + "imageSticker" + String(v) + } + }() + + override init(frame: CGRect) { + super.init(frame: frame) + self.setupUI() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func layoutSubviews() { + super.layoutSubviews() + + let path = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: self.frame.width, height: ImageStickerContainerView.baseViewH), byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize(width: 8, height: 8)) + self.baseView.layer.mask = nil + let maskLayer = CAShapeLayer() + maskLayer.path = path.cgPath + self.baseView.layer.mask = maskLayer + } + + func setupUI() { + self.baseView = UIView() + self.addSubview(self.baseView) + self.baseView.snp.makeConstraints { (make) in + make.left.right.equalTo(self) + make.bottom.equalTo(self.snp.bottom).offset(ImageStickerContainerView.baseViewH) + make.height.equalTo(ImageStickerContainerView.baseViewH) + } + + let visualView = UIVisualEffectView(effect: UIBlurEffect(style: .dark)) + self.baseView.addSubview(visualView) + visualView.snp.makeConstraints { (make) in + make.edges.equalTo(self.baseView) + } + + let toolView = UIView() + toolView.backgroundColor = UIColor(white: 0.4, alpha: 0.4) + self.baseView.addSubview(toolView) + toolView.snp.makeConstraints { (make) in + make.top.left.right.equalTo(self.baseView) + make.height.equalTo(50) + } + + let hideBtn = UIButton(type: .custom) + hideBtn.setImage(UIImage(named: "close"), for: .normal) + hideBtn.backgroundColor = .clear + hideBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14) + hideBtn.addTarget(self, action: #selector(hideBtnClick), for: .touchUpInside) + toolView.addSubview(hideBtn) + hideBtn.snp.makeConstraints { (make) in + make.centerY.equalTo(toolView) + make.right.equalTo(toolView).offset(-20) + make.size.equalTo(CGSize(width: 40, height: 40)) + } + + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .vertical + layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10) + layout.minimumLineSpacing = 5 + layout.minimumInteritemSpacing = 5 + self.collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) + self.collectionView.backgroundColor = .clear + self.collectionView.delegate = self + self.collectionView.dataSource = self + self.baseView.addSubview(self.collectionView) + self.collectionView.snp.makeConstraints { (make) in + make.top.equalTo(toolView.snp.bottom) + make.left.right.bottom.equalTo(self.baseView) + } + + self.collectionView.register(ImageStickerCell.self, forCellWithReuseIdentifier: NSStringFromClass(ImageStickerCell.classForCoder())) + + let tap = UITapGestureRecognizer(target: self, action: #selector(hideBtnClick)) + tap.delegate = self + self.addGestureRecognizer(tap) + } + + @objc func hideBtnClick() { + self.hide() + } + + func show(in view: UIView) { + if self.superview !== view { + self.removeFromSuperview() + + view.addSubview(self) + self.snp.makeConstraints { (make) in + make.edges.equalTo(view) + } + view.layoutIfNeeded() + } + + self.isHidden = false + UIView.animate(withDuration: 0.25) { + self.baseView.snp.updateConstraints { (make) in + make.bottom.equalTo(self.snp.bottom) + } + view.layoutIfNeeded() + } + } + + func hide() { + self.hideBlock?() + + UIView.animate(withDuration: 0.25) { + self.baseView.snp.updateConstraints { (make) in + make.bottom.equalTo(self.snp.bottom).offset(ImageStickerContainerView.baseViewH) + } + self.superview?.layoutIfNeeded() + } completion: { (_) in + self.isHidden = true + } + + } + +} + + +extension ImageStickerContainerView: UIGestureRecognizerDelegate { + + public override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { + let location = gestureRecognizer.location(in: self) + return !self.baseView.frame.contains(location) + } + +} + + +extension ImageStickerContainerView: UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let column: CGFloat = 4 + let spacing: CGFloat = 20 + 5 * (column - 1) + let w = (collectionView.frame.width - spacing) / column + return CGSize(width: w, height: w) + } + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + self.datas.count + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: NSStringFromClass(ImageStickerCell.classForCoder()), for: indexPath) as! ImageStickerCell + + cell.imageView.image = UIImage(named: self.datas[indexPath.row]) + + return cell + } + + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + guard let image = UIImage(named: self.datas[indexPath.row]) else { + return + } + self.selectImageBlock?(image) + self.hide() + } + +} + + +class ImageStickerCell: UICollectionViewCell { + + var imageView: UIImageView! + + override init(frame: CGRect) { + super.init(frame: frame) + + self.imageView = UIImageView() + self.imageView.contentMode = .scaleAspectFit + self.contentView.addSubview(self.imageView) + self.imageView.snp.makeConstraints { (make) in + make.edges.equalTo(self.contentView) + } + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} + diff --git a/MiniScanner/Supporting Files/MiniScanner_Bridging_Header.h b/MiniScanner/Supporting Files/MiniScanner_Bridging_Header.h index 448531c48caa660ed79db03a7fe93b3b7e6ed52b..50d3b71c4af6150ba30a4ac46c030ed1c3a5a3a2 100644 --- a/MiniScanner/Supporting Files/MiniScanner_Bridging_Header.h +++ b/MiniScanner/Supporting Files/MiniScanner_Bridging_Header.h @@ -11,5 +11,7 @@ #import "TYCyclePagerView.h" #import "TYPageControl.h" +#import "CDOverlayView.h" +#import "CDCameraView.h" #endif /* MiniScanner_Bridging_Header_h */ diff --git a/MiniScanner/Supporting Files/SnapKit/Constraint.swift b/MiniScanner/Supporting Files/SnapKit/Constraint.swift new file mode 100644 index 0000000000000000000000000000000000000000..37409b3b13943083e720f8b672417c8403820844 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/Constraint.swift @@ -0,0 +1,341 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + +public final class Constraint { + + internal let sourceLocation: (String, UInt) + internal let label: String? + + private let from: ConstraintItem + private let to: ConstraintItem + private let relation: ConstraintRelation + private let multiplier: ConstraintMultiplierTarget + private var constant: ConstraintConstantTarget { + didSet { + self.updateConstantAndPriorityIfNeeded() + } + } + private var priority: ConstraintPriorityTarget { + didSet { + self.updateConstantAndPriorityIfNeeded() + } + } + public var layoutConstraints: [LayoutConstraint] + + public var isActive: Bool { + set { + if newValue { + activate() + } + else { + deactivate() + } + } + + get { + for layoutConstraint in self.layoutConstraints { + if layoutConstraint.isActive { + return true + } + } + return false + } + } + + // MARK: Initialization + + internal init(from: ConstraintItem, + to: ConstraintItem, + relation: ConstraintRelation, + sourceLocation: (String, UInt), + label: String?, + multiplier: ConstraintMultiplierTarget, + constant: ConstraintConstantTarget, + priority: ConstraintPriorityTarget) { + self.from = from + self.to = to + self.relation = relation + self.sourceLocation = sourceLocation + self.label = label + self.multiplier = multiplier + self.constant = constant + self.priority = priority + self.layoutConstraints = [] + + // get attributes + let layoutFromAttributes = self.from.attributes.layoutAttributes + let layoutToAttributes = self.to.attributes.layoutAttributes + + // get layout from + let layoutFrom = self.from.layoutConstraintItem! + + // get relation + let layoutRelation = self.relation.layoutRelation + + for layoutFromAttribute in layoutFromAttributes { + // get layout to attribute + let layoutToAttribute: LayoutAttribute + #if os(iOS) || os(tvOS) + if layoutToAttributes.count > 0 { + if self.from.attributes == .edges && self.to.attributes == .margins { + switch layoutFromAttribute { + case .left: + layoutToAttribute = .leftMargin + case .right: + layoutToAttribute = .rightMargin + case .top: + layoutToAttribute = .topMargin + case .bottom: + layoutToAttribute = .bottomMargin + default: + fatalError() + } + } else if self.from.attributes == .margins && self.to.attributes == .edges { + switch layoutFromAttribute { + case .leftMargin: + layoutToAttribute = .left + case .rightMargin: + layoutToAttribute = .right + case .topMargin: + layoutToAttribute = .top + case .bottomMargin: + layoutToAttribute = .bottom + default: + fatalError() + } + } else if self.from.attributes == .directionalEdges && self.to.attributes == .directionalMargins { + switch layoutFromAttribute { + case .leading: + layoutToAttribute = .leadingMargin + case .trailing: + layoutToAttribute = .trailingMargin + case .top: + layoutToAttribute = .topMargin + case .bottom: + layoutToAttribute = .bottomMargin + default: + fatalError() + } + } else if self.from.attributes == .directionalMargins && self.to.attributes == .directionalEdges { + switch layoutFromAttribute { + case .leadingMargin: + layoutToAttribute = .leading + case .trailingMargin: + layoutToAttribute = .trailing + case .topMargin: + layoutToAttribute = .top + case .bottomMargin: + layoutToAttribute = .bottom + default: + fatalError() + } + } else if self.from.attributes == self.to.attributes { + layoutToAttribute = layoutFromAttribute + } else { + layoutToAttribute = layoutToAttributes[0] + } + } else { + if self.to.target == nil && (layoutFromAttribute == .centerX || layoutFromAttribute == .centerY) { + layoutToAttribute = layoutFromAttribute == .centerX ? .left : .top + } else { + layoutToAttribute = layoutFromAttribute + } + } + #else + if self.from.attributes == self.to.attributes { + layoutToAttribute = layoutFromAttribute + } else if layoutToAttributes.count > 0 { + layoutToAttribute = layoutToAttributes[0] + } else { + layoutToAttribute = layoutFromAttribute + } + #endif + + // get layout constant + let layoutConstant: CGFloat = self.constant.constraintConstantTargetValueFor(layoutAttribute: layoutToAttribute) + + // get layout to + var layoutTo: AnyObject? = self.to.target + + // use superview if possible + if layoutTo == nil && layoutToAttribute != .width && layoutToAttribute != .height { + layoutTo = layoutFrom.superview + } + + // create layout constraint + let layoutConstraint = LayoutConstraint( + item: layoutFrom, + attribute: layoutFromAttribute, + relatedBy: layoutRelation, + toItem: layoutTo, + attribute: layoutToAttribute, + multiplier: self.multiplier.constraintMultiplierTargetValue, + constant: layoutConstant + ) + + // set label + layoutConstraint.label = self.label + + // set priority + layoutConstraint.priority = LayoutPriority(rawValue: self.priority.constraintPriorityTargetValue) + + // set constraint + layoutConstraint.constraint = self + + // append + self.layoutConstraints.append(layoutConstraint) + } + } + + // MARK: Public + + @available(*, deprecated, renamed:"activate()") + public func install() { + self.activate() + } + + @available(*, deprecated, renamed:"deactivate()") + public func uninstall() { + self.deactivate() + } + + public func activate() { + self.activateIfNeeded() + } + + public func deactivate() { + self.deactivateIfNeeded() + } + + @discardableResult + public func update(offset: ConstraintOffsetTarget) -> Constraint { + self.constant = offset.constraintOffsetTargetValue + return self + } + + @discardableResult + public func update(inset: ConstraintInsetTarget) -> Constraint { + self.constant = inset.constraintInsetTargetValue + return self + } + + #if os(iOS) || os(tvOS) + @discardableResult + @available(iOS 11.0, tvOS 11.0, *) + public func update(inset: ConstraintDirectionalInsetTarget) -> Constraint { + self.constant = inset.constraintDirectionalInsetTargetValue + return self + } + #endif + + @discardableResult + public func update(priority: ConstraintPriorityTarget) -> Constraint { + self.priority = priority.constraintPriorityTargetValue + return self + } + + @discardableResult + public func update(priority: ConstraintPriority) -> Constraint { + self.priority = priority.value + return self + } + + @available(*, deprecated, renamed:"update(offset:)") + public func updateOffset(amount: ConstraintOffsetTarget) -> Void { self.update(offset: amount) } + + @available(*, deprecated, renamed:"update(inset:)") + public func updateInsets(amount: ConstraintInsetTarget) -> Void { self.update(inset: amount) } + + @available(*, deprecated, renamed:"update(priority:)") + public func updatePriority(amount: ConstraintPriorityTarget) -> Void { self.update(priority: amount) } + + @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.") + public func updatePriorityRequired() -> Void {} + + @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.") + public func updatePriorityHigh() -> Void { fatalError("Must be implemented by Concrete subclass.") } + + @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.") + public func updatePriorityMedium() -> Void { fatalError("Must be implemented by Concrete subclass.") } + + @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.") + public func updatePriorityLow() -> Void { fatalError("Must be implemented by Concrete subclass.") } + + // MARK: Internal + + internal func updateConstantAndPriorityIfNeeded() { + for layoutConstraint in self.layoutConstraints { + let attribute = (layoutConstraint.secondAttribute == .notAnAttribute) ? layoutConstraint.firstAttribute : layoutConstraint.secondAttribute + layoutConstraint.constant = self.constant.constraintConstantTargetValueFor(layoutAttribute: attribute) + + let requiredPriority = ConstraintPriority.required.value + if (layoutConstraint.priority.rawValue < requiredPriority), (self.priority.constraintPriorityTargetValue != requiredPriority) { + layoutConstraint.priority = LayoutPriority(rawValue: self.priority.constraintPriorityTargetValue) + } + } + } + + internal func activateIfNeeded(updatingExisting: Bool = false) { + guard let item = self.from.layoutConstraintItem else { + print("WARNING: SnapKit failed to get from item from constraint. Activate will be a no-op.") + return + } + let layoutConstraints = self.layoutConstraints + + if updatingExisting { + var existingLayoutConstraints: [LayoutConstraint] = [] + for constraint in item.constraints { + existingLayoutConstraints += constraint.layoutConstraints + } + + for layoutConstraint in layoutConstraints { + let existingLayoutConstraint = existingLayoutConstraints.first { $0 == layoutConstraint } + guard let updateLayoutConstraint = existingLayoutConstraint else { + fatalError("Updated constraint could not find existing matching constraint to update: \(layoutConstraint)") + } + + let updateLayoutAttribute = (updateLayoutConstraint.secondAttribute == .notAnAttribute) ? updateLayoutConstraint.firstAttribute : updateLayoutConstraint.secondAttribute + updateLayoutConstraint.constant = self.constant.constraintConstantTargetValueFor(layoutAttribute: updateLayoutAttribute) + } + } else { + NSLayoutConstraint.activate(layoutConstraints) + item.add(constraints: [self]) + } + } + + internal func deactivateIfNeeded() { + guard let item = self.from.layoutConstraintItem else { + print("WARNING: SnapKit failed to get from item from constraint. Deactivate will be a no-op.") + return + } + let layoutConstraints = self.layoutConstraints + NSLayoutConstraint.deactivate(layoutConstraints) + item.remove(constraints: [self]) + } +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintAttributes.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintAttributes.swift new file mode 100644 index 0000000000000000000000000000000000000000..408308b82ed8edb8da4b567545f49d53c422ea6b --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintAttributes.swift @@ -0,0 +1,203 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +internal struct ConstraintAttributes : OptionSet, ExpressibleByIntegerLiteral { + + typealias IntegerLiteralType = UInt + + internal init(rawValue: UInt) { + self.rawValue = rawValue + } + internal init(_ rawValue: UInt) { + self.init(rawValue: rawValue) + } + internal init(nilLiteral: ()) { + self.rawValue = 0 + } + internal init(integerLiteral rawValue: IntegerLiteralType) { + self.init(rawValue: rawValue) + } + + internal private(set) var rawValue: UInt + internal static var allZeros: ConstraintAttributes { return 0 } + internal static func convertFromNilLiteral() -> ConstraintAttributes { return 0 } + internal var boolValue: Bool { return self.rawValue != 0 } + + internal func toRaw() -> UInt { return self.rawValue } + internal static func fromRaw(_ raw: UInt) -> ConstraintAttributes? { return self.init(raw) } + internal static func fromMask(_ raw: UInt) -> ConstraintAttributes { return self.init(raw) } + + // normal + + internal static let none: ConstraintAttributes = 0 + internal static let left: ConstraintAttributes = ConstraintAttributes(UInt(1) << 0) + internal static let top: ConstraintAttributes = ConstraintAttributes(UInt(1) << 1) + internal static let right: ConstraintAttributes = ConstraintAttributes(UInt(1) << 2) + internal static let bottom: ConstraintAttributes = ConstraintAttributes(UInt(1) << 3) + internal static let leading: ConstraintAttributes = ConstraintAttributes(UInt(1) << 4) + internal static let trailing: ConstraintAttributes = ConstraintAttributes(UInt(1) << 5) + internal static let width: ConstraintAttributes = ConstraintAttributes(UInt(1) << 6) + internal static let height: ConstraintAttributes = ConstraintAttributes(UInt(1) << 7) + internal static let centerX: ConstraintAttributes = ConstraintAttributes(UInt(1) << 8) + internal static let centerY: ConstraintAttributes = ConstraintAttributes(UInt(1) << 9) + internal static let lastBaseline: ConstraintAttributes = ConstraintAttributes(UInt(1) << 10) + + @available(iOS 8.0, OSX 10.11, *) + internal static let firstBaseline: ConstraintAttributes = ConstraintAttributes(UInt(1) << 11) + + @available(iOS 8.0, *) + internal static let leftMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 12) + + @available(iOS 8.0, *) + internal static let rightMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 13) + + @available(iOS 8.0, *) + internal static let topMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 14) + + @available(iOS 8.0, *) + internal static let bottomMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 15) + + @available(iOS 8.0, *) + internal static let leadingMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 16) + + @available(iOS 8.0, *) + internal static let trailingMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 17) + + @available(iOS 8.0, *) + internal static let centerXWithinMargins: ConstraintAttributes = ConstraintAttributes(UInt(1) << 18) + + @available(iOS 8.0, *) + internal static let centerYWithinMargins: ConstraintAttributes = ConstraintAttributes(UInt(1) << 19) + + // aggregates + + internal static let edges: ConstraintAttributes = [.horizontalEdges, .verticalEdges] + internal static let horizontalEdges: ConstraintAttributes = [.left, .right] + internal static let verticalEdges: ConstraintAttributes = [.top, .bottom] + internal static let directionalEdges: ConstraintAttributes = [.directionalHorizontalEdges, .directionalVerticalEdges] + internal static let directionalHorizontalEdges: ConstraintAttributes = [.leading, .trailing] + internal static let directionalVerticalEdges: ConstraintAttributes = [.top, .bottom] + internal static let size: ConstraintAttributes = [.width, .height] + internal static let center: ConstraintAttributes = [.centerX, .centerY] + + @available(iOS 8.0, *) + internal static let margins: ConstraintAttributes = [.leftMargin, .topMargin, .rightMargin, .bottomMargin] + + @available(iOS 8.0, *) + internal static let directionalMargins: ConstraintAttributes = [.leadingMargin, .topMargin, .trailingMargin, .bottomMargin] + + @available(iOS 8.0, *) + internal static let centerWithinMargins: ConstraintAttributes = [.centerXWithinMargins, .centerYWithinMargins] + + internal var layoutAttributes:[LayoutAttribute] { + var attrs = [LayoutAttribute]() + if (self.contains(ConstraintAttributes.left)) { + attrs.append(.left) + } + if (self.contains(ConstraintAttributes.top)) { + attrs.append(.top) + } + if (self.contains(ConstraintAttributes.right)) { + attrs.append(.right) + } + if (self.contains(ConstraintAttributes.bottom)) { + attrs.append(.bottom) + } + if (self.contains(ConstraintAttributes.leading)) { + attrs.append(.leading) + } + if (self.contains(ConstraintAttributes.trailing)) { + attrs.append(.trailing) + } + if (self.contains(ConstraintAttributes.width)) { + attrs.append(.width) + } + if (self.contains(ConstraintAttributes.height)) { + attrs.append(.height) + } + if (self.contains(ConstraintAttributes.centerX)) { + attrs.append(.centerX) + } + if (self.contains(ConstraintAttributes.centerY)) { + attrs.append(.centerY) + } + if (self.contains(ConstraintAttributes.lastBaseline)) { + attrs.append(.lastBaseline) + } + + #if os(iOS) || os(tvOS) + if (self.contains(ConstraintAttributes.firstBaseline)) { + attrs.append(.firstBaseline) + } + if (self.contains(ConstraintAttributes.leftMargin)) { + attrs.append(.leftMargin) + } + if (self.contains(ConstraintAttributes.rightMargin)) { + attrs.append(.rightMargin) + } + if (self.contains(ConstraintAttributes.topMargin)) { + attrs.append(.topMargin) + } + if (self.contains(ConstraintAttributes.bottomMargin)) { + attrs.append(.bottomMargin) + } + if (self.contains(ConstraintAttributes.leadingMargin)) { + attrs.append(.leadingMargin) + } + if (self.contains(ConstraintAttributes.trailingMargin)) { + attrs.append(.trailingMargin) + } + if (self.contains(ConstraintAttributes.centerXWithinMargins)) { + attrs.append(.centerXWithinMargins) + } + if (self.contains(ConstraintAttributes.centerYWithinMargins)) { + attrs.append(.centerYWithinMargins) + } + #endif + + return attrs + } +} + +internal func + (left: ConstraintAttributes, right: ConstraintAttributes) -> ConstraintAttributes { + return left.union(right) +} + +internal func +=(left: inout ConstraintAttributes, right: ConstraintAttributes) { + left.formUnion(right) +} + +internal func -=(left: inout ConstraintAttributes, right: ConstraintAttributes) { + left.subtract(right) +} + +internal func ==(left: ConstraintAttributes, right: ConstraintAttributes) -> Bool { + return left.rawValue == right.rawValue +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintConfig.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintConfig.swift new file mode 100644 index 0000000000000000000000000000000000000000..2746b7d26a4fa5d57012b0fd0e7debebb07af67a --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintConfig.swift @@ -0,0 +1,37 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit + public typealias ConstraintInterfaceLayoutDirection = UIUserInterfaceLayoutDirection +#else + import AppKit + public typealias ConstraintInterfaceLayoutDirection = NSUserInterfaceLayoutDirection +#endif + + +public struct ConstraintConfig { + + public static var interfaceLayoutDirection: ConstraintInterfaceLayoutDirection = .leftToRight + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintConstantTarget.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintConstantTarget.swift new file mode 100644 index 0000000000000000000000000000000000000000..7f549078960ce08bbf45416e8f2f706536f838ce --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintConstantTarget.swift @@ -0,0 +1,213 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintConstantTarget { +} + +extension CGPoint: ConstraintConstantTarget { +} + +extension CGSize: ConstraintConstantTarget { +} + +extension ConstraintInsets: ConstraintConstantTarget { +} + +#if os(iOS) || os(tvOS) +@available(iOS 11.0, tvOS 11.0, *) +extension ConstraintDirectionalInsets: ConstraintConstantTarget { +} +#endif + +extension ConstraintConstantTarget { + + internal func constraintConstantTargetValueFor(layoutAttribute: LayoutAttribute) -> CGFloat { + if let value = self as? CGFloat { + return value + } + + if let value = self as? Float { + return CGFloat(value) + } + + if let value = self as? Double { + return CGFloat(value) + } + + if let value = self as? Int { + return CGFloat(value) + } + + if let value = self as? UInt { + return CGFloat(value) + } + + if let value = self as? CGSize { + if layoutAttribute == .width { + return value.width + } else if layoutAttribute == .height { + return value.height + } else { + return 0.0 + } + } + + if let value = self as? CGPoint { + #if os(iOS) || os(tvOS) + switch layoutAttribute { + case .left, .right, .leading, .trailing, .centerX, .leftMargin, .rightMargin, .leadingMargin, .trailingMargin, .centerXWithinMargins: + return value.x + case .top, .bottom, .centerY, .topMargin, .bottomMargin, .centerYWithinMargins, .lastBaseline, .firstBaseline: + return value.y + case .width, .height, .notAnAttribute: + return 0.0 + #if swift(>=5.0) + @unknown default: + return 0.0 + #endif + } + #else + switch layoutAttribute { + case .left, .right, .leading, .trailing, .centerX: + return value.x + case .top, .bottom, .centerY, .lastBaseline, .firstBaseline: + return value.y + case .width, .height, .notAnAttribute: + return 0.0 + #if swift(>=5.0) + @unknown default: + return 0.0 + #endif + } + #endif + } + + if let value = self as? ConstraintInsets { + #if os(iOS) || os(tvOS) + switch layoutAttribute { + case .left, .leftMargin: + return value.left + case .top, .topMargin, .firstBaseline: + return value.top + case .right, .rightMargin: + return -value.right + case .bottom, .bottomMargin, .lastBaseline: + return -value.bottom + case .leading, .leadingMargin: + return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : value.right + case .trailing, .trailingMargin: + return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.right : -value.left + case .centerX, .centerXWithinMargins: + return (value.left - value.right) / 2 + case .centerY, .centerYWithinMargins: + return (value.top - value.bottom) / 2 + case .width: + return -(value.left + value.right) + case .height: + return -(value.top + value.bottom) + case .notAnAttribute: + return 0.0 + #if swift(>=5.0) + @unknown default: + return 0.0 + #endif + } + #else + switch layoutAttribute { + case .left: + return value.left + case .top, .firstBaseline: + return value.top + case .right: + return -value.right + case .bottom, .lastBaseline: + return -value.bottom + case .leading: + return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : value.right + case .trailing: + return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.right : -value.left + case .centerX: + return (value.left - value.right) / 2 + case .centerY: + return (value.top - value.bottom) / 2 + case .width: + return -(value.left + value.right) + case .height: + return -(value.top + value.bottom) + case .notAnAttribute: + return 0.0 + #if swift(>=5.0) + @unknown default: + return 0.0 + #endif + } + #endif + } + + #if os(iOS) || os(tvOS) + if #available(iOS 11.0, tvOS 11.0, *), let value = self as? ConstraintDirectionalInsets { + switch layoutAttribute { + case .left, .leftMargin: + return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.leading : value.trailing + case .top, .topMargin, .firstBaseline: + return value.top + case .right, .rightMargin: + return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.trailing : -value.leading + case .bottom, .bottomMargin, .lastBaseline: + return -value.bottom + case .leading, .leadingMargin: + return value.leading + case .trailing, .trailingMargin: + return -value.trailing + case .centerX, .centerXWithinMargins: + return (value.leading - value.trailing) / 2 + case .centerY, .centerYWithinMargins: + return (value.top - value.bottom) / 2 + case .width: + return -(value.leading + value.trailing) + case .height: + return -(value.top + value.bottom) + case .notAnAttribute: + return 0.0 + #if swift(>=5.0) + @unknown default: + return 0.0 + #else + default: + return 0.0 + #endif + } + } + #endif + + return 0.0 + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintDSL.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintDSL.swift new file mode 100644 index 0000000000000000000000000000000000000000..20f153da91755d112ed44849de45e17d9d0045e8 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintDSL.swift @@ -0,0 +1,209 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintDSL { + + var target: AnyObject? { get } + + func setLabel(_ value: String?) + func label() -> String? + +} +extension ConstraintDSL { + + public func setLabel(_ value: String?) { + objc_setAssociatedObject(self.target as Any, &labelKey, value, .OBJC_ASSOCIATION_COPY_NONATOMIC) + } + public func label() -> String? { + return objc_getAssociatedObject(self.target as Any, &labelKey) as? String + } + +} +private var labelKey: UInt8 = 0 + + +public protocol ConstraintBasicAttributesDSL : ConstraintDSL { +} +extension ConstraintBasicAttributesDSL { + + // MARK: Basics + + public var left: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.left) + } + + public var top: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.top) + } + + public var right: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.right) + } + + public var bottom: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.bottom) + } + + public var leading: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.leading) + } + + public var trailing: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.trailing) + } + + public var width: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.width) + } + + public var height: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.height) + } + + public var centerX: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerX) + } + + public var centerY: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerY) + } + + public var edges: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.edges) + } + + public var directionalEdges: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalEdges) + } + + public var horizontalEdges: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.horizontalEdges) + } + + public var verticalEdges: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.verticalEdges) + } + + public var directionalHorizontalEdges: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalHorizontalEdges) + } + + public var directionalVerticalEdges: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalVerticalEdges) + } + + public var size: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.size) + } + + public var center: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.center) + } + +} + +public protocol ConstraintAttributesDSL : ConstraintBasicAttributesDSL { +} +extension ConstraintAttributesDSL { + + // MARK: Baselines + @available(*, deprecated, renamed:"lastBaseline") + public var baseline: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.lastBaseline) + } + + @available(iOS 8.0, OSX 10.11, *) + public var lastBaseline: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.lastBaseline) + } + + @available(iOS 8.0, OSX 10.11, *) + public var firstBaseline: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.firstBaseline) + } + + // MARK: Margins + + @available(iOS 8.0, *) + public var leftMargin: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.leftMargin) + } + + @available(iOS 8.0, *) + public var topMargin: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.topMargin) + } + + @available(iOS 8.0, *) + public var rightMargin: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.rightMargin) + } + + @available(iOS 8.0, *) + public var bottomMargin: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.bottomMargin) + } + + @available(iOS 8.0, *) + public var leadingMargin: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.leadingMargin) + } + + @available(iOS 8.0, *) + public var trailingMargin: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.trailingMargin) + } + + @available(iOS 8.0, *) + public var centerXWithinMargins: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerXWithinMargins) + } + + @available(iOS 8.0, *) + public var centerYWithinMargins: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerYWithinMargins) + } + + @available(iOS 8.0, *) + public var margins: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.margins) + } + + @available(iOS 8.0, *) + public var directionalMargins: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalMargins) + } + + @available(iOS 8.0, *) + public var centerWithinMargins: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerWithinMargins) + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintDescription.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintDescription.swift new file mode 100644 index 0000000000000000000000000000000000000000..3521f9f9e977651b3649d07d1bc27d4c30de4aa5 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintDescription.swift @@ -0,0 +1,69 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class ConstraintDescription { + + internal let item: LayoutConstraintItem + internal var attributes: ConstraintAttributes + internal var relation: ConstraintRelation? = nil + internal var sourceLocation: (String, UInt)? = nil + internal var label: String? = nil + internal var related: ConstraintItem? = nil + internal var multiplier: ConstraintMultiplierTarget = 1.0 + internal var constant: ConstraintConstantTarget = 0.0 + internal var priority: ConstraintPriorityTarget = 1000.0 + internal lazy var constraint: Constraint? = { + guard let relation = self.relation, + let related = self.related, + let sourceLocation = self.sourceLocation else { + return nil + } + let from = ConstraintItem(target: self.item, attributes: self.attributes) + + return Constraint( + from: from, + to: related, + relation: relation, + sourceLocation: sourceLocation, + label: self.label, + multiplier: self.multiplier, + constant: self.constant, + priority: self.priority + ) + }() + + // MARK: Initialization + + internal init(item: LayoutConstraintItem, attributes: ConstraintAttributes) { + self.item = item + self.attributes = attributes + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintDirectionalInsetTarget.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintDirectionalInsetTarget.swift new file mode 100644 index 0000000000000000000000000000000000000000..955aec35ba428ebeb19607322da936391f08864a --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintDirectionalInsetTarget.swift @@ -0,0 +1,49 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) +import UIKit +#else +import AppKit +#endif + +#if os(iOS) || os(tvOS) +public protocol ConstraintDirectionalInsetTarget: ConstraintConstantTarget { +} + +@available(iOS 11.0, tvOS 11.0, *) +extension ConstraintDirectionalInsets: ConstraintDirectionalInsetTarget { +} + +extension ConstraintDirectionalInsetTarget { + + @available(iOS 11.0, tvOS 11.0, *) + internal var constraintDirectionalInsetTargetValue: ConstraintDirectionalInsets { + if let amount = self as? ConstraintDirectionalInsets { + return amount + } else { + return ConstraintDirectionalInsets(top: 0, leading: 0, bottom: 0, trailing: 0) + } + } +} +#endif diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintDirectionalInsets.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintDirectionalInsets.swift new file mode 100644 index 0000000000000000000000000000000000000000..ada8ed5b14b57ee0e962e7e3cb5f0ea168da0dd2 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintDirectionalInsets.swift @@ -0,0 +1,34 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +#if os(iOS) || os(tvOS) + @available(iOS 11.0, tvOS 11.0, *) + public typealias ConstraintDirectionalInsets = NSDirectionalEdgeInsets +#endif diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintInsetTarget.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintInsetTarget.swift new file mode 100644 index 0000000000000000000000000000000000000000..ba8a0f3eb45512da7a06d13e9270093ccb99f7be --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintInsetTarget.swift @@ -0,0 +1,72 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintInsetTarget: ConstraintConstantTarget { +} + +extension Int: ConstraintInsetTarget { +} + +extension UInt: ConstraintInsetTarget { +} + +extension Float: ConstraintInsetTarget { +} + +extension Double: ConstraintInsetTarget { +} + +extension CGFloat: ConstraintInsetTarget { +} + +extension ConstraintInsets: ConstraintInsetTarget { +} + +extension ConstraintInsetTarget { + + internal var constraintInsetTargetValue: ConstraintInsets { + if let amount = self as? ConstraintInsets { + return amount + } else if let amount = self as? Float { + return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount)) + } else if let amount = self as? Double { + return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount)) + } else if let amount = self as? CGFloat { + return ConstraintInsets(top: amount, left: amount, bottom: amount, right: amount) + } else if let amount = self as? Int { + return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount)) + } else if let amount = self as? UInt { + return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount)) + } else { + return ConstraintInsets(top: 0, left: 0, bottom: 0, right: 0) + } + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintInsets.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintInsets.swift new file mode 100644 index 0000000000000000000000000000000000000000..738ca0555104b7ade609a72700d8aca2bf23d0af --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintInsets.swift @@ -0,0 +1,35 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +#if os(iOS) || os(tvOS) + public typealias ConstraintInsets = UIEdgeInsets +#else + public typealias ConstraintInsets = NSEdgeInsets +#endif diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintItem.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintItem.swift new file mode 100644 index 0000000000000000000000000000000000000000..a342c1d95e91b9d2d7b83cb0021929e9e3d01c6f --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintItem.swift @@ -0,0 +1,61 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public final class ConstraintItem { + + internal weak var target: AnyObject? + internal let attributes: ConstraintAttributes + + internal init(target: AnyObject?, attributes: ConstraintAttributes) { + self.target = target + self.attributes = attributes + } + + internal var layoutConstraintItem: LayoutConstraintItem? { + return self.target as? LayoutConstraintItem + } + +} + +public func ==(lhs: ConstraintItem, rhs: ConstraintItem) -> Bool { + // pointer equality + guard lhs !== rhs else { + return true + } + + // must both have valid targets and identical attributes + guard let target1 = lhs.target, + let target2 = rhs.target, + target1 === target2 && lhs.attributes == rhs.attributes else { + return false + } + + return true +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutGuide+Extensions.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutGuide+Extensions.swift new file mode 100644 index 0000000000000000000000000000000000000000..d429e0ccaa47131f6338201f458d1f6246021114 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutGuide+Extensions.swift @@ -0,0 +1,36 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#endif + + +@available(iOS 9.0, OSX 10.11, *) +public extension ConstraintLayoutGuide { + + var snp: ConstraintLayoutGuideDSL { + return ConstraintLayoutGuideDSL(guide: self) + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutGuide.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutGuide.swift new file mode 100644 index 0000000000000000000000000000000000000000..e3e50c895443c5ebe065615a3c92b335e308180c --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutGuide.swift @@ -0,0 +1,37 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +#if os(iOS) || os(tvOS) + @available(iOS 9.0, *) + public typealias ConstraintLayoutGuide = UILayoutGuide +#else + @available(OSX 10.11, *) + public typealias ConstraintLayoutGuide = NSLayoutGuide +#endif diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutGuideDSL.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutGuideDSL.swift new file mode 100644 index 0000000000000000000000000000000000000000..0007819c263d983e5d4c008921dda8c35758d129 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutGuideDSL.swift @@ -0,0 +1,66 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +@available(iOS 9.0, OSX 10.11, *) +public struct ConstraintLayoutGuideDSL: ConstraintAttributesDSL { + + @discardableResult + public func prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { + return ConstraintMaker.prepareConstraints(item: self.guide, closure: closure) + } + + public func makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + ConstraintMaker.makeConstraints(item: self.guide, closure: closure) + } + + public func remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + ConstraintMaker.remakeConstraints(item: self.guide, closure: closure) + } + + public func updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + ConstraintMaker.updateConstraints(item: self.guide, closure: closure) + } + + public func removeConstraints() { + ConstraintMaker.removeConstraints(item: self.guide) + } + + public var target: AnyObject? { + return self.guide + } + + internal let guide: ConstraintLayoutGuide + + internal init(guide: ConstraintLayoutGuide) { + self.guide = guide + + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutSupport.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutSupport.swift new file mode 100644 index 0000000000000000000000000000000000000000..e92e9fbc9bd50229cf85c67898428d1574609e0d --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutSupport.swift @@ -0,0 +1,36 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +#if os(iOS) || os(tvOS) + @available(iOS 8.0, *) + public typealias ConstraintLayoutSupport = UILayoutSupport +#else + public class ConstraintLayoutSupport {} +#endif diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutSupportDSL.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutSupportDSL.swift new file mode 100644 index 0000000000000000000000000000000000000000..5d6ae899ac2589b00933377e621acf67c2e88229 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintLayoutSupportDSL.swift @@ -0,0 +1,56 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +@available(iOS 8.0, *) +public struct ConstraintLayoutSupportDSL: ConstraintDSL { + + public var target: AnyObject? { + return self.support + } + + internal let support: ConstraintLayoutSupport + + internal init(support: ConstraintLayoutSupport) { + self.support = support + + } + + public var top: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.top) + } + + public var bottom: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.bottom) + } + + public var height: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.height) + } +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintMaker.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintMaker.swift new file mode 100644 index 0000000000000000000000000000000000000000..7e48b694ad47b4f282bf9c76339227a9d041f46c --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintMaker.swift @@ -0,0 +1,224 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + +public class ConstraintMaker { + + public var left: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.left) + } + + public var top: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.top) + } + + public var bottom: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.bottom) + } + + public var right: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.right) + } + + public var leading: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.leading) + } + + public var trailing: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.trailing) + } + + public var width: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.width) + } + + public var height: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.height) + } + + public var centerX: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.centerX) + } + + public var centerY: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.centerY) + } + + @available(*, deprecated, renamed:"lastBaseline") + public var baseline: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.lastBaseline) + } + + public var lastBaseline: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.lastBaseline) + } + + @available(iOS 8.0, OSX 10.11, *) + public var firstBaseline: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.firstBaseline) + } + + @available(iOS 8.0, *) + public var leftMargin: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.leftMargin) + } + + @available(iOS 8.0, *) + public var rightMargin: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.rightMargin) + } + + @available(iOS 8.0, *) + public var topMargin: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.topMargin) + } + + @available(iOS 8.0, *) + public var bottomMargin: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.bottomMargin) + } + + @available(iOS 8.0, *) + public var leadingMargin: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.leadingMargin) + } + + @available(iOS 8.0, *) + public var trailingMargin: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.trailingMargin) + } + + @available(iOS 8.0, *) + public var centerXWithinMargins: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.centerXWithinMargins) + } + + @available(iOS 8.0, *) + public var centerYWithinMargins: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.centerYWithinMargins) + } + + public var edges: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.edges) + } + public var horizontalEdges: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.horizontalEdges) + } + public var verticalEdges: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.verticalEdges) + } + public var directionalEdges: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.directionalEdges) + } + public var directionalHorizontalEdges: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.directionalHorizontalEdges) + } + public var directionalVerticalEdges: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.directionalVerticalEdges) + } + public var size: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.size) + } + public var center: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.center) + } + + @available(iOS 8.0, *) + public var margins: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.margins) + } + + @available(iOS 8.0, *) + public var directionalMargins: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.directionalMargins) + } + + @available(iOS 8.0, *) + public var centerWithinMargins: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.centerWithinMargins) + } + + private let item: LayoutConstraintItem + private var descriptions = [ConstraintDescription]() + + internal init(item: LayoutConstraintItem) { + self.item = item + self.item.prepare() + } + + internal func makeExtendableWithAttributes(_ attributes: ConstraintAttributes) -> ConstraintMakerExtendable { + let description = ConstraintDescription(item: self.item, attributes: attributes) + self.descriptions.append(description) + return ConstraintMakerExtendable(description) + } + + internal static func prepareConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { + let maker = ConstraintMaker(item: item) + closure(maker) + var constraints: [Constraint] = [] + for description in maker.descriptions { + guard let constraint = description.constraint else { + continue + } + constraints.append(constraint) + } + return constraints + } + + internal static func makeConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) { + let constraints = prepareConstraints(item: item, closure: closure) + for constraint in constraints { + constraint.activateIfNeeded(updatingExisting: false) + } + } + + internal static func remakeConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) { + self.removeConstraints(item: item) + self.makeConstraints(item: item, closure: closure) + } + + internal static func updateConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) { + guard item.constraints.count > 0 else { + self.makeConstraints(item: item, closure: closure) + return + } + + let constraints = prepareConstraints(item: item, closure: closure) + for constraint in constraints { + constraint.activateIfNeeded(updatingExisting: true) + } + } + + internal static func removeConstraints(item: LayoutConstraintItem) { + let constraints = item.constraints + for constraint in constraints { + constraint.deactivateIfNeeded() + } + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintMakerEditable.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintMakerEditable.swift new file mode 100644 index 0000000000000000000000000000000000000000..f768a177f3b8a28a570f5e37decc303b1d995008 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintMakerEditable.swift @@ -0,0 +1,64 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class ConstraintMakerEditable: ConstraintMakerPriortizable { + + @discardableResult + public func multipliedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable { + self.description.multiplier = amount + return self + } + + @discardableResult + public func dividedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable { + return self.multipliedBy(1.0 / amount.constraintMultiplierTargetValue) + } + + @discardableResult + public func offset(_ amount: ConstraintOffsetTarget) -> ConstraintMakerEditable { + self.description.constant = amount.constraintOffsetTargetValue + return self + } + + @discardableResult + public func inset(_ amount: ConstraintInsetTarget) -> ConstraintMakerEditable { + self.description.constant = amount.constraintInsetTargetValue + return self + } + + #if os(iOS) || os(tvOS) + @discardableResult + @available(iOS 11.0, tvOS 11.0, *) + public func inset(_ amount: ConstraintDirectionalInsetTarget) -> ConstraintMakerEditable { + self.description.constant = amount.constraintDirectionalInsetTargetValue + return self + } + #endif +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintMakerExtendable.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintMakerExtendable.swift new file mode 100644 index 0000000000000000000000000000000000000000..d8346493665dba00c84d1acaa1d0efe3603edc3a --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintMakerExtendable.swift @@ -0,0 +1,195 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class ConstraintMakerExtendable: ConstraintMakerRelatable { + + public var left: ConstraintMakerExtendable { + self.description.attributes += .left + return self + } + + public var top: ConstraintMakerExtendable { + self.description.attributes += .top + return self + } + + public var bottom: ConstraintMakerExtendable { + self.description.attributes += .bottom + return self + } + + public var right: ConstraintMakerExtendable { + self.description.attributes += .right + return self + } + + public var leading: ConstraintMakerExtendable { + self.description.attributes += .leading + return self + } + + public var trailing: ConstraintMakerExtendable { + self.description.attributes += .trailing + return self + } + + public var width: ConstraintMakerExtendable { + self.description.attributes += .width + return self + } + + public var height: ConstraintMakerExtendable { + self.description.attributes += .height + return self + } + + public var centerX: ConstraintMakerExtendable { + self.description.attributes += .centerX + return self + } + + public var centerY: ConstraintMakerExtendable { + self.description.attributes += .centerY + return self + } + + @available(*, deprecated, renamed:"lastBaseline") + public var baseline: ConstraintMakerExtendable { + self.description.attributes += .lastBaseline + return self + } + + public var lastBaseline: ConstraintMakerExtendable { + self.description.attributes += .lastBaseline + return self + } + + @available(iOS 8.0, OSX 10.11, *) + public var firstBaseline: ConstraintMakerExtendable { + self.description.attributes += .firstBaseline + return self + } + + @available(iOS 8.0, *) + public var leftMargin: ConstraintMakerExtendable { + self.description.attributes += .leftMargin + return self + } + + @available(iOS 8.0, *) + public var rightMargin: ConstraintMakerExtendable { + self.description.attributes += .rightMargin + return self + } + + @available(iOS 8.0, *) + public var topMargin: ConstraintMakerExtendable { + self.description.attributes += .topMargin + return self + } + + @available(iOS 8.0, *) + public var bottomMargin: ConstraintMakerExtendable { + self.description.attributes += .bottomMargin + return self + } + + @available(iOS 8.0, *) + public var leadingMargin: ConstraintMakerExtendable { + self.description.attributes += .leadingMargin + return self + } + + @available(iOS 8.0, *) + public var trailingMargin: ConstraintMakerExtendable { + self.description.attributes += .trailingMargin + return self + } + + @available(iOS 8.0, *) + public var centerXWithinMargins: ConstraintMakerExtendable { + self.description.attributes += .centerXWithinMargins + return self + } + + @available(iOS 8.0, *) + public var centerYWithinMargins: ConstraintMakerExtendable { + self.description.attributes += .centerYWithinMargins + return self + } + + public var edges: ConstraintMakerExtendable { + self.description.attributes += .edges + return self + } + public var horizontalEdges: ConstraintMakerExtendable { + self.description.attributes += .horizontalEdges + return self + } + public var verticalEdges: ConstraintMakerExtendable { + self.description.attributes += .verticalEdges + return self + } + public var directionalEdges: ConstraintMakerExtendable { + self.description.attributes += .directionalEdges + return self + } + public var directionalHorizontalEdges: ConstraintMakerExtendable { + self.description.attributes += .directionalHorizontalEdges + return self + } + public var directionalVerticalEdges: ConstraintMakerExtendable { + self.description.attributes += .directionalVerticalEdges + return self + } + public var size: ConstraintMakerExtendable { + self.description.attributes += .size + return self + } + + @available(iOS 8.0, *) + public var margins: ConstraintMakerExtendable { + self.description.attributes += .margins + return self + } + + @available(iOS 8.0, *) + public var directionalMargins: ConstraintMakerExtendable { + self.description.attributes += .directionalMargins + return self + } + + @available(iOS 8.0, *) + public var centerWithinMargins: ConstraintMakerExtendable { + self.description.attributes += .centerWithinMargins + return self + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintMakerFinalizable.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintMakerFinalizable.swift new file mode 100644 index 0000000000000000000000000000000000000000..4e1379e286341eacb07e6c96036cd4e2b1652bef --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintMakerFinalizable.swift @@ -0,0 +1,49 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class ConstraintMakerFinalizable { + + internal let description: ConstraintDescription + + internal init(_ description: ConstraintDescription) { + self.description = description + } + + @discardableResult + public func labeled(_ label: String) -> ConstraintMakerFinalizable { + self.description.label = label + return self + } + + public var constraint: Constraint { + return self.description.constraint! + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintMakerPriortizable.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintMakerPriortizable.swift new file mode 100644 index 0000000000000000000000000000000000000000..e0d452d1fef00c1244a7240d66e37b5ec0c8458d --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintMakerPriortizable.swift @@ -0,0 +1,68 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class ConstraintMakerPriortizable: ConstraintMakerFinalizable { + + @discardableResult + public func priority(_ amount: ConstraintPriority) -> ConstraintMakerFinalizable { + self.description.priority = amount.value + return self + } + + @discardableResult + public func priority(_ amount: ConstraintPriorityTarget) -> ConstraintMakerFinalizable { + self.description.priority = amount + return self + } + + @available(*, deprecated, message:"Use priority(.required) instead.") + @discardableResult + public func priorityRequired() -> ConstraintMakerFinalizable { + return self.priority(.required) + } + + @available(*, deprecated, message:"Use priority(.high) instead.") + @discardableResult + public func priorityHigh() -> ConstraintMakerFinalizable { + return self.priority(.high) + } + + @available(*, deprecated, message:"Use priority(.medium) instead.") + @discardableResult + public func priorityMedium() -> ConstraintMakerFinalizable { + return self.priority(.medium) + } + + @available(*, deprecated, message:"Use priority(.low) instead.") + @discardableResult + public func priorityLow() -> ConstraintMakerFinalizable { + return self.priority(.low) + } +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintMakerRelatable+Extensions.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintMakerRelatable+Extensions.swift new file mode 100644 index 0000000000000000000000000000000000000000..63100d7cb79cf514a4882084b77cd9590f233572 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintMakerRelatable+Extensions.swift @@ -0,0 +1,57 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +extension ConstraintMakerRelatable { + + @discardableResult + public func equalToSuperview<T: ConstraintRelatableTarget>(_ closure: (ConstraintView) -> T, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable { + guard let other = self.description.item.superview else { + fatalError("Expected superview but found nil when attempting make constraint `equalToSuperview`.") + } + return self.relatedTo(closure(other), relation: .equal, file: file, line: line) + } + + @discardableResult + public func lessThanOrEqualToSuperview<T: ConstraintRelatableTarget>(_ closure: (ConstraintView) -> T, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable { + guard let other = self.description.item.superview else { + fatalError("Expected superview but found nil when attempting make constraint `lessThanOrEqualToSuperview`.") + } + return self.relatedTo(closure(other), relation: .lessThanOrEqual, file: file, line: line) + } + + @discardableResult + public func greaterThanOrEqualTo<T: ConstraintRelatableTarget>(_ closure: (ConstraintView) -> T, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable { + guard let other = self.description.item.superview else { + fatalError("Expected superview but found nil when attempting make constraint `greaterThanOrEqualToSuperview`.") + } + return self.relatedTo(closure(other), relation: .greaterThanOrEqual, file: file, line: line) + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintMakerRelatable.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintMakerRelatable.swift new file mode 100644 index 0000000000000000000000000000000000000000..78895323fa54cd399b15d21cd93a107398ca5925 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintMakerRelatable.swift @@ -0,0 +1,115 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class ConstraintMakerRelatable { + + internal let description: ConstraintDescription + + internal init(_ description: ConstraintDescription) { + self.description = description + } + + internal func relatedTo(_ other: ConstraintRelatableTarget, relation: ConstraintRelation, file: String, line: UInt) -> ConstraintMakerEditable { + let related: ConstraintItem + let constant: ConstraintConstantTarget + + if let other = other as? ConstraintItem { + guard other.attributes == ConstraintAttributes.none || + other.attributes.layoutAttributes.count <= 1 || + other.attributes.layoutAttributes == self.description.attributes.layoutAttributes || + other.attributes == .edges && self.description.attributes == .margins || + other.attributes == .margins && self.description.attributes == .edges || + other.attributes == .directionalEdges && self.description.attributes == .directionalMargins || + other.attributes == .directionalMargins && self.description.attributes == .directionalEdges else { + fatalError("Cannot constraint to multiple non identical attributes. (\(file), \(line))"); + } + + related = other + constant = 0.0 + } else if let other = other as? ConstraintView { + related = ConstraintItem(target: other, attributes: ConstraintAttributes.none) + constant = 0.0 + } else if let other = other as? ConstraintConstantTarget { + related = ConstraintItem(target: nil, attributes: ConstraintAttributes.none) + constant = other + } else if #available(iOS 9.0, OSX 10.11, *), let other = other as? ConstraintLayoutGuide { + related = ConstraintItem(target: other, attributes: ConstraintAttributes.none) + constant = 0.0 + } else { + fatalError("Invalid constraint. (\(file), \(line))") + } + + let editable = ConstraintMakerEditable(self.description) + editable.description.sourceLocation = (file, line) + editable.description.relation = relation + editable.description.related = related + editable.description.constant = constant + return editable + } + + @discardableResult + public func equalTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable { + return self.relatedTo(other, relation: .equal, file: file, line: line) + } + + @discardableResult + public func equalToSuperview(_ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable { + guard let other = self.description.item.superview else { + fatalError("Expected superview but found nil when attempting make constraint `equalToSuperview`.") + } + return self.relatedTo(other, relation: .equal, file: file, line: line) + } + + @discardableResult + public func lessThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable { + return self.relatedTo(other, relation: .lessThanOrEqual, file: file, line: line) + } + + @discardableResult + public func lessThanOrEqualToSuperview(_ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable { + guard let other = self.description.item.superview else { + fatalError("Expected superview but found nil when attempting make constraint `lessThanOrEqualToSuperview`.") + } + return self.relatedTo(other, relation: .lessThanOrEqual, file: file, line: line) + } + + @discardableResult + public func greaterThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable { + return self.relatedTo(other, relation: .greaterThanOrEqual, file: file, line: line) + } + + @discardableResult + public func greaterThanOrEqualToSuperview(_ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable { + guard let other = self.description.item.superview else { + fatalError("Expected superview but found nil when attempting make constraint `greaterThanOrEqualToSuperview`.") + } + return self.relatedTo(other, relation: .greaterThanOrEqual, file: file, line: line) + } +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintMultiplierTarget.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintMultiplierTarget.swift new file mode 100644 index 0000000000000000000000000000000000000000..6fecd33e66f1090bc0fd2f542790a87201fe180c --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintMultiplierTarget.swift @@ -0,0 +1,75 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintMultiplierTarget { + + var constraintMultiplierTargetValue: CGFloat { get } + +} + +extension Int: ConstraintMultiplierTarget { + + public var constraintMultiplierTargetValue: CGFloat { + return CGFloat(self) + } + +} + +extension UInt: ConstraintMultiplierTarget { + + public var constraintMultiplierTargetValue: CGFloat { + return CGFloat(self) + } + +} + +extension Float: ConstraintMultiplierTarget { + + public var constraintMultiplierTargetValue: CGFloat { + return CGFloat(self) + } + +} + +extension Double: ConstraintMultiplierTarget { + + public var constraintMultiplierTargetValue: CGFloat { + return CGFloat(self) + } + +} + +extension CGFloat: ConstraintMultiplierTarget { + + public var constraintMultiplierTargetValue: CGFloat { + return self + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintOffsetTarget.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintOffsetTarget.swift new file mode 100644 index 0000000000000000000000000000000000000000..bd9e0a1e32400b62620aff96eb0cd0c86f0c0f96 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintOffsetTarget.swift @@ -0,0 +1,69 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintOffsetTarget: ConstraintConstantTarget { +} + +extension Int: ConstraintOffsetTarget { +} + +extension UInt: ConstraintOffsetTarget { +} + +extension Float: ConstraintOffsetTarget { +} + +extension Double: ConstraintOffsetTarget { +} + +extension CGFloat: ConstraintOffsetTarget { +} + +extension ConstraintOffsetTarget { + + internal var constraintOffsetTargetValue: CGFloat { + let offset: CGFloat + if let amount = self as? Float { + offset = CGFloat(amount) + } else if let amount = self as? Double { + offset = CGFloat(amount) + } else if let amount = self as? CGFloat { + offset = CGFloat(amount) + } else if let amount = self as? Int { + offset = CGFloat(amount) + } else if let amount = self as? UInt { + offset = CGFloat(amount) + } else { + offset = 0.0 + } + return offset + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintPriority.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintPriority.swift new file mode 100644 index 0000000000000000000000000000000000000000..f9dab16222a1a6d82fce296d5aca6ace25f796a1 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintPriority.swift @@ -0,0 +1,77 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + +public struct ConstraintPriority : ExpressibleByFloatLiteral, Equatable, Strideable { + public typealias FloatLiteralType = Float + + public let value: Float + + public init(floatLiteral value: Float) { + self.value = value + } + + public init(_ value: Float) { + self.value = value + } + + public static var required: ConstraintPriority { + return 1000.0 + } + + public static var high: ConstraintPriority { + return 750.0 + } + + public static var medium: ConstraintPriority { + #if os(OSX) + return 501.0 + #else + return 500.0 + #endif + + } + + public static var low: ConstraintPriority { + return 250.0 + } + + public static func ==(lhs: ConstraintPriority, rhs: ConstraintPriority) -> Bool { + return lhs.value == rhs.value + } + + // MARK: Strideable + + public func advanced(by n: FloatLiteralType) -> ConstraintPriority { + return ConstraintPriority(floatLiteral: value + n) + } + + public func distance(to other: ConstraintPriority) -> FloatLiteralType { + return other.value - value + } +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintPriorityTarget.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintPriorityTarget.swift new file mode 100644 index 0000000000000000000000000000000000000000..064f750b9e1b37e24c3d621daa40fab1ba89a178 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintPriorityTarget.swift @@ -0,0 +1,85 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintPriorityTarget { + + var constraintPriorityTargetValue: Float { get } + +} + +extension Int: ConstraintPriorityTarget { + + public var constraintPriorityTargetValue: Float { + return Float(self) + } + +} + +extension UInt: ConstraintPriorityTarget { + + public var constraintPriorityTargetValue: Float { + return Float(self) + } + +} + +extension Float: ConstraintPriorityTarget { + + public var constraintPriorityTargetValue: Float { + return self + } + +} + +extension Double: ConstraintPriorityTarget { + + public var constraintPriorityTargetValue: Float { + return Float(self) + } + +} + +extension CGFloat: ConstraintPriorityTarget { + + public var constraintPriorityTargetValue: Float { + return Float(self) + } + +} + +#if os(iOS) || os(tvOS) +extension UILayoutPriority: ConstraintPriorityTarget { + + public var constraintPriorityTargetValue: Float { + return self.rawValue + } + +} +#endif diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintRelatableTarget.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintRelatableTarget.swift new file mode 100644 index 0000000000000000000000000000000000000000..d517a61ec0dc154ba8c0fb0cc7dd078f93d506c0 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintRelatableTarget.swift @@ -0,0 +1,72 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintRelatableTarget { +} + +extension Int: ConstraintRelatableTarget { +} + +extension UInt: ConstraintRelatableTarget { +} + +extension Float: ConstraintRelatableTarget { +} + +extension Double: ConstraintRelatableTarget { +} + +extension CGFloat: ConstraintRelatableTarget { +} + +extension CGSize: ConstraintRelatableTarget { +} + +extension CGPoint: ConstraintRelatableTarget { +} + +extension ConstraintInsets: ConstraintRelatableTarget { +} + +#if os(iOS) || os(tvOS) +@available(iOS 11.0, tvOS 11.0, *) +extension ConstraintDirectionalInsets: ConstraintRelatableTarget { +} +#endif + +extension ConstraintItem: ConstraintRelatableTarget { +} + +extension ConstraintView: ConstraintRelatableTarget { +} + +@available(iOS 9.0, OSX 10.11, *) +extension ConstraintLayoutGuide: ConstraintRelatableTarget { +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintRelation.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintRelation.swift new file mode 100644 index 0000000000000000000000000000000000000000..446aaf769df955ed03e1873fd8f8a79023a8e3b4 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintRelation.swift @@ -0,0 +1,48 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +internal enum ConstraintRelation : Int { + case equal = 1 + case lessThanOrEqual + case greaterThanOrEqual + + internal var layoutRelation: LayoutRelation { + get { + switch(self) { + case .equal: + return .equal + case .lessThanOrEqual: + return .lessThanOrEqual + case .greaterThanOrEqual: + return .greaterThanOrEqual + } + } + } +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintView+Extensions.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintView+Extensions.swift new file mode 100644 index 0000000000000000000000000000000000000000..e0f71c1a6261b5ca2a8354b03e3ba040076f0973 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintView+Extensions.swift @@ -0,0 +1,152 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public extension ConstraintView { + + @available(*, deprecated, renamed:"snp.left") + var snp_left: ConstraintItem { return self.snp.left } + + @available(*, deprecated, renamed:"snp.top") + var snp_top: ConstraintItem { return self.snp.top } + + @available(*, deprecated, renamed:"snp.right") + var snp_right: ConstraintItem { return self.snp.right } + + @available(*, deprecated, renamed:"snp.bottom") + var snp_bottom: ConstraintItem { return self.snp.bottom } + + @available(*, deprecated, renamed:"snp.leading") + var snp_leading: ConstraintItem { return self.snp.leading } + + @available(*, deprecated, renamed:"snp.trailing") + var snp_trailing: ConstraintItem { return self.snp.trailing } + + @available(*, deprecated, renamed:"snp.width") + var snp_width: ConstraintItem { return self.snp.width } + + @available(*, deprecated, renamed:"snp.height") + var snp_height: ConstraintItem { return self.snp.height } + + @available(*, deprecated, renamed:"snp.centerX") + var snp_centerX: ConstraintItem { return self.snp.centerX } + + @available(*, deprecated, renamed:"snp.centerY") + var snp_centerY: ConstraintItem { return self.snp.centerY } + + @available(*, deprecated, renamed:"snp.baseline") + var snp_baseline: ConstraintItem { return self.snp.baseline } + + @available(*, deprecated, renamed:"snp.lastBaseline") + @available(iOS 8.0, OSX 10.11, *) + var snp_lastBaseline: ConstraintItem { return self.snp.lastBaseline } + + @available(iOS, deprecated, renamed:"snp.firstBaseline") + @available(iOS 8.0, OSX 10.11, *) + var snp_firstBaseline: ConstraintItem { return self.snp.firstBaseline } + + @available(iOS, deprecated, renamed:"snp.leftMargin") + @available(iOS 8.0, *) + var snp_leftMargin: ConstraintItem { return self.snp.leftMargin } + + @available(iOS, deprecated, renamed:"snp.topMargin") + @available(iOS 8.0, *) + var snp_topMargin: ConstraintItem { return self.snp.topMargin } + + @available(iOS, deprecated, renamed:"snp.rightMargin") + @available(iOS 8.0, *) + var snp_rightMargin: ConstraintItem { return self.snp.rightMargin } + + @available(iOS, deprecated, renamed:"snp.bottomMargin") + @available(iOS 8.0, *) + var snp_bottomMargin: ConstraintItem { return self.snp.bottomMargin } + + @available(iOS, deprecated, renamed:"snp.leadingMargin") + @available(iOS 8.0, *) + var snp_leadingMargin: ConstraintItem { return self.snp.leadingMargin } + + @available(iOS, deprecated, renamed:"snp.trailingMargin") + @available(iOS 8.0, *) + var snp_trailingMargin: ConstraintItem { return self.snp.trailingMargin } + + @available(iOS, deprecated, renamed:"snp.centerXWithinMargins") + @available(iOS 8.0, *) + var snp_centerXWithinMargins: ConstraintItem { return self.snp.centerXWithinMargins } + + @available(iOS, deprecated, renamed:"snp.centerYWithinMargins") + @available(iOS 8.0, *) + var snp_centerYWithinMargins: ConstraintItem { return self.snp.centerYWithinMargins } + + @available(*, deprecated, renamed:"snp.edges") + var snp_edges: ConstraintItem { return self.snp.edges } + + @available(*, deprecated, renamed:"snp.size") + var snp_size: ConstraintItem { return self.snp.size } + + @available(*, deprecated, renamed:"snp.center") + var snp_center: ConstraintItem { return self.snp.center } + + @available(iOS, deprecated, renamed:"snp.margins") + @available(iOS 8.0, *) + var snp_margins: ConstraintItem { return self.snp.margins } + + @available(iOS, deprecated, renamed:"snp.centerWithinMargins") + @available(iOS 8.0, *) + var snp_centerWithinMargins: ConstraintItem { return self.snp.centerWithinMargins } + + @available(*, deprecated, renamed:"snp.prepareConstraints(_:)") + func snp_prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { + return self.snp.prepareConstraints(closure) + } + + @available(*, deprecated, renamed:"snp.makeConstraints(_:)") + func snp_makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + self.snp.makeConstraints(closure) + } + + @available(*, deprecated, renamed:"snp.remakeConstraints(_:)") + func snp_remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + self.snp.remakeConstraints(closure) + } + + @available(*, deprecated, renamed:"snp.updateConstraints(_:)") + func snp_updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + self.snp.updateConstraints(closure) + } + + @available(*, deprecated, renamed:"snp.removeConstraints()") + func snp_removeConstraints() { + self.snp.removeConstraints() + } + + var snp: ConstraintViewDSL { + return ConstraintViewDSL(view: self) + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintView.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintView.swift new file mode 100644 index 0000000000000000000000000000000000000000..6ff8a76e3d1c71068568046e215849642d72a0aa --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintView.swift @@ -0,0 +1,35 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +#if os(iOS) || os(tvOS) + public typealias ConstraintView = UIView +#else + public typealias ConstraintView = NSView +#endif diff --git a/MiniScanner/Supporting Files/SnapKit/ConstraintViewDSL.swift b/MiniScanner/Supporting Files/SnapKit/ConstraintViewDSL.swift new file mode 100644 index 0000000000000000000000000000000000000000..a0187f973964b98087880a1f512c0a057bdbd42b --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/ConstraintViewDSL.swift @@ -0,0 +1,101 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public struct ConstraintViewDSL: ConstraintAttributesDSL { + + @discardableResult + public func prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { + return ConstraintMaker.prepareConstraints(item: self.view, closure: closure) + } + + public func makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + ConstraintMaker.makeConstraints(item: self.view, closure: closure) + } + + public func remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + ConstraintMaker.remakeConstraints(item: self.view, closure: closure) + } + + public func updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + ConstraintMaker.updateConstraints(item: self.view, closure: closure) + } + + public func removeConstraints() { + ConstraintMaker.removeConstraints(item: self.view) + } + + public var contentHuggingHorizontalPriority: Float { + get { + return self.view.contentHuggingPriority(for: .horizontal).rawValue + } + nonmutating set { + self.view.setContentHuggingPriority(LayoutPriority(rawValue: newValue), for: .horizontal) + } + } + + public var contentHuggingVerticalPriority: Float { + get { + return self.view.contentHuggingPriority(for: .vertical).rawValue + } + nonmutating set { + self.view.setContentHuggingPriority(LayoutPriority(rawValue: newValue), for: .vertical) + } + } + + public var contentCompressionResistanceHorizontalPriority: Float { + get { + return self.view.contentCompressionResistancePriority(for: .horizontal).rawValue + } + nonmutating set { + self.view.setContentCompressionResistancePriority(LayoutPriority(rawValue: newValue), for: .horizontal) + } + } + + public var contentCompressionResistanceVerticalPriority: Float { + get { + return self.view.contentCompressionResistancePriority(for: .vertical).rawValue + } + nonmutating set { + self.view.setContentCompressionResistancePriority(LayoutPriority(rawValue: newValue), for: .vertical) + } + } + + public var target: AnyObject? { + return self.view + } + + internal let view: ConstraintView + + internal init(view: ConstraintView) { + self.view = view + + } + +} diff --git a/MiniScanner/Supporting Files/SnapKit/Debugging.swift b/MiniScanner/Supporting Files/SnapKit/Debugging.swift new file mode 100644 index 0000000000000000000000000000000000000000..a78579ab6e3f5f3da86cc0af9329cb3addb2b86f --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/Debugging.swift @@ -0,0 +1,169 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + +public extension LayoutConstraint { + + override var description: String { + var description = "<" + + description += descriptionForObject(self) + + if let firstItem = conditionalOptional(from: self.firstItem) { + description += " \(descriptionForObject(firstItem))" + } + + if self.firstAttribute != .notAnAttribute { + description += ".\(descriptionForAttribute(self.firstAttribute))" + } + + description += " \(descriptionForRelation(self.relation))" + + if let secondItem = self.secondItem { + description += " \(descriptionForObject(secondItem))" + } + + if self.secondAttribute != .notAnAttribute { + description += ".\(descriptionForAttribute(self.secondAttribute))" + } + + if self.multiplier != 1.0 { + description += " * \(self.multiplier)" + } + + if self.secondAttribute == .notAnAttribute { + description += " \(self.constant)" + } else { + if self.constant > 0.0 { + description += " + \(self.constant)" + } else if self.constant < 0.0 { + description += " - \(abs(self.constant))" + } + } + + if self.priority.rawValue != 1000.0 { + description += " ^\(self.priority)" + } + + description += ">" + + return description + } + +} + +private func descriptionForRelation(_ relation: LayoutRelation) -> String { + switch relation { + case .equal: return "==" + case .greaterThanOrEqual: return ">=" + case .lessThanOrEqual: return "<=" + #if swift(>=5.0) + @unknown default: return "unknown" + #endif + } +} + +private func descriptionForAttribute(_ attribute: LayoutAttribute) -> String { + #if os(iOS) || os(tvOS) + switch attribute { + case .notAnAttribute: return "notAnAttribute" + case .top: return "top" + case .left: return "left" + case .bottom: return "bottom" + case .right: return "right" + case .leading: return "leading" + case .trailing: return "trailing" + case .width: return "width" + case .height: return "height" + case .centerX: return "centerX" + case .centerY: return "centerY" + case .lastBaseline: return "lastBaseline" + case .firstBaseline: return "firstBaseline" + case .topMargin: return "topMargin" + case .leftMargin: return "leftMargin" + case .bottomMargin: return "bottomMargin" + case .rightMargin: return "rightMargin" + case .leadingMargin: return "leadingMargin" + case .trailingMargin: return "trailingMargin" + case .centerXWithinMargins: return "centerXWithinMargins" + case .centerYWithinMargins: return "centerYWithinMargins" + #if swift(>=5.0) + @unknown default: return "unknown" + #endif + } + #else + switch attribute { + case .notAnAttribute: return "notAnAttribute" + case .top: return "top" + case .left: return "left" + case .bottom: return "bottom" + case .right: return "right" + case .leading: return "leading" + case .trailing: return "trailing" + case .width: return "width" + case .height: return "height" + case .centerX: return "centerX" + case .centerY: return "centerY" + case .lastBaseline: return "lastBaseline" + case .firstBaseline: return "firstBaseline" + #if swift(>=5.0) + @unknown default: return "unknown" + #endif + } + #endif +} + +private func conditionalOptional<T>(from object: Optional<T>) -> Optional<T> { + return object +} + +private func conditionalOptional<T>(from object: T) -> Optional<T> { + return Optional.some(object) +} + +private func descriptionForObject(_ object: AnyObject) -> String { + let pointerDescription = String(format: "%p", UInt(bitPattern: ObjectIdentifier(object))) + var desc = "" + + desc += type(of: object).description() + + if let object = object as? ConstraintView { + desc += ":\(object.snp.label() ?? pointerDescription)" + } else if let object = object as? LayoutConstraint { + desc += ":\(object.label ?? pointerDescription)" + } else { + desc += ":\(pointerDescription)" + } + + if let object = object as? LayoutConstraint, let file = object.constraint?.sourceLocation.0, let line = object.constraint?.sourceLocation.1 { + desc += "@\((file as NSString).lastPathComponent)#\(line)" + } + + desc += "" + return desc +} diff --git a/MiniScanner/Supporting Files/SnapKit/LayoutConstraint.swift b/MiniScanner/Supporting Files/SnapKit/LayoutConstraint.swift new file mode 100644 index 0000000000000000000000000000000000000000..5425ea8ee785629fa3da5c3582809c9cc959e0e2 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/LayoutConstraint.swift @@ -0,0 +1,61 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class LayoutConstraint : NSLayoutConstraint { + + public var label: String? { + get { + return self.identifier + } + set { + self.identifier = newValue + } + } + + internal weak var constraint: Constraint? = nil + +} + +internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool { + // If firstItem or secondItem on either constraint has a dangling pointer + // this comparison can cause a crash. The solution for this is to ensure + // your layout code hold strong references to things like Views, LayoutGuides + // and LayoutAnchors as SnapKit will not keep strong references to any of these. + guard lhs.firstAttribute == rhs.firstAttribute && + lhs.secondAttribute == rhs.secondAttribute && + lhs.relation == rhs.relation && + lhs.priority == rhs.priority && + lhs.multiplier == rhs.multiplier && + lhs.secondItem === rhs.secondItem && + lhs.firstItem === rhs.firstItem else { + return false + } + return true +} diff --git a/MiniScanner/Supporting Files/SnapKit/LayoutConstraintItem.swift b/MiniScanner/Supporting Files/SnapKit/LayoutConstraintItem.swift new file mode 100644 index 0000000000000000000000000000000000000000..a59de6bf4f37bfd4673e5a18447931b5fd850d37 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/LayoutConstraintItem.swift @@ -0,0 +1,93 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol LayoutConstraintItem: class { +} + +@available(iOS 9.0, OSX 10.11, *) +extension ConstraintLayoutGuide : LayoutConstraintItem { +} + +extension ConstraintView : LayoutConstraintItem { +} + + +extension LayoutConstraintItem { + + internal func prepare() { + if let view = self as? ConstraintView { + view.translatesAutoresizingMaskIntoConstraints = false + } + } + + internal var superview: ConstraintView? { + if let view = self as? ConstraintView { + return view.superview + } + + if #available(iOS 9.0, OSX 10.11, *), let guide = self as? ConstraintLayoutGuide { + return guide.owningView + } + + return nil + } + internal var constraints: [Constraint] { + return self.constraintsSet.allObjects as! [Constraint] + } + + internal func add(constraints: [Constraint]) { + let constraintsSet = self.constraintsSet + for constraint in constraints { + constraintsSet.add(constraint) + } + } + + internal func remove(constraints: [Constraint]) { + let constraintsSet = self.constraintsSet + for constraint in constraints { + constraintsSet.remove(constraint) + } + } + + private var constraintsSet: NSMutableSet { + let constraintsSet: NSMutableSet + + if let existing = objc_getAssociatedObject(self, &constraintsKey) as? NSMutableSet { + constraintsSet = existing + } else { + constraintsSet = NSMutableSet() + objc_setAssociatedObject(self, &constraintsKey, constraintsSet, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + return constraintsSet + + } + +} +private var constraintsKey: UInt8 = 0 diff --git a/MiniScanner/Supporting Files/SnapKit/SnapKit.h b/MiniScanner/Supporting Files/SnapKit/SnapKit.h new file mode 100644 index 0000000000000000000000000000000000000000..12075c88e3be1bb069a2b0a6209d45ba3af4fcbd --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/SnapKit.h @@ -0,0 +1,27 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import <Foundation/Foundation.h> + +FOUNDATION_EXPORT double SnapKitVersionNumber; +FOUNDATION_EXPORT const unsigned char SnapKitVersionString[]; \ No newline at end of file diff --git a/MiniScanner/Supporting Files/SnapKit/Typealiases.swift b/MiniScanner/Supporting Files/SnapKit/Typealiases.swift new file mode 100644 index 0000000000000000000000000000000000000000..ded96ccd0be5fea4aee83c041e2fbc66a0616444 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/Typealiases.swift @@ -0,0 +1,42 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +#if os(iOS) || os(tvOS) + import UIKit +#if swift(>=4.2) + typealias LayoutRelation = NSLayoutConstraint.Relation + typealias LayoutAttribute = NSLayoutConstraint.Attribute +#else + typealias LayoutRelation = NSLayoutRelation + typealias LayoutAttribute = NSLayoutAttribute +#endif + typealias LayoutPriority = UILayoutPriority +#else + import AppKit + typealias LayoutRelation = NSLayoutConstraint.Relation + typealias LayoutAttribute = NSLayoutConstraint.Attribute + typealias LayoutPriority = NSLayoutConstraint.Priority +#endif + diff --git a/MiniScanner/Supporting Files/SnapKit/UILayoutSupport+Extensions.swift b/MiniScanner/Supporting Files/SnapKit/UILayoutSupport+Extensions.swift new file mode 100644 index 0000000000000000000000000000000000000000..8e7644cf1bd2053b5a770e77fb381afa3552d927 --- /dev/null +++ b/MiniScanner/Supporting Files/SnapKit/UILayoutSupport+Extensions.swift @@ -0,0 +1,36 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#endif + + +@available(iOS 8.0, *) +public extension ConstraintLayoutSupport { + + var snp: ConstraintLayoutSupportDSL { + return ConstraintLayoutSupportDSL(support: self) + } + +}