Skip to content

Commit

Permalink
Update PixelEditViewController
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii committed Mar 7, 2021
1 parent 6aebfcd commit fb9b1db
Show file tree
Hide file tree
Showing 18 changed files with 406 additions and 288 deletions.
15 changes: 15 additions & 0 deletions Assets.xcassets/L1000069.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "L1000069.jpeg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "original"
}
}
Binary file added Assets.xcassets/L1000069.imageset/L1000069.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Assets.xcassets/L1000316.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "L1000316.jpeg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "original"
}
}
Binary file added Assets.xcassets/L1000316.imageset/L1000316.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Assets.xcassets/L1002725.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "L1002725.jpeg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "original"
}
}
Binary file added Assets.xcassets/L1002725.imageset/L1002725.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 34 additions & 24 deletions Pixel.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ target "PixelEditor" do
pod "Verge", git: "[email protected]:VergeGroup/Verge.git", branch: "main"
end

target "Demo" do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod "MosaiqueAssetsPicker", :git => "[email protected]:eure/AssetsPicker.git"
pod "Reveal-SDK"
pod "Verge", git: "[email protected]:VergeGroup/Verge.git", branch: "main"
pod "TransitionPatch"
end
abstract_target 'Demo_Apps' do

target "SwiftUIDemo" do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod "Reveal-SDK"
pod "Verge", git: "[email protected]:VergeGroup/Verge.git", branch: "main"
pod "TransitionPatch"
pod "SwiftGen"

target "Demo" do
pod "MosaiqueAssetsPicker", :git => "[email protected]:eure/AssetsPicker.git"
end

target "SwiftUIDemo" do
use_frameworks!
end

end

6 changes: 5 additions & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
PODS:
- MosaiqueAssetsPicker (1.2.0)
- Reveal-SDK (28)
- SwiftGen (6.4.0)
- TransitionPatch (1.0.2)
- Verge (8.8.0):
- Verge/Store (= 8.8.0)
Expand All @@ -11,12 +12,14 @@ PODS:
DEPENDENCIES:
- "MosaiqueAssetsPicker (from `[email protected]:eure/AssetsPicker.git`)"
- Reveal-SDK
- SwiftGen
- TransitionPatch
- "Verge (from `[email protected]:VergeGroup/Verge.git`, branch `main`)"

SPEC REPOS:
trunk:
- Reveal-SDK
- SwiftGen
- TransitionPatch

EXTERNAL SOURCES:
Expand All @@ -37,9 +40,10 @@ CHECKOUT OPTIONS:
SPEC CHECKSUMS:
MosaiqueAssetsPicker: e3d2be37a1a7d91d60f2904347f556fc1811e4d7
Reveal-SDK: 1a2a678648fc4d277bad71c86d15530424324288
SwiftGen: 67860cc7c3cfc2ed25b9b74cfd55495fc89f9108
TransitionPatch: c02b48b1429255b14ef82b7e411034e0958b9681
Verge: 8c03af6abae2835c42e7bba71551593295087219

PODFILE CHECKSUM: 9d82cadbdfcf718c9b15ea20168dbadfe273492a
PODFILE CHECKSUM: 186d0e5dec0e4cacc3a0f0e421b8e5c59ea2d991

COCOAPODS: 1.10.1
46 changes: 46 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
class String
def red
"\e[31m#{self}\e[0m"
end

def green
"\e[32m#{self}\e[0m"
end

def blue
"\e[34m#{self}\e[0m"
end

def bold
"\e[1m#{self}\e[22m"
end
end

WORKDIR = File.dirname(__FILE__)
SWIFTGEN = File.join(WORKDIR, "Pods/SwiftGen/bin/swiftgen")

desc "generate"
namespace :gen do
desc "asset"
task :asset do
sh "#{SWIFTGEN}"
end
end

private

def verbose(s)
puts s
end

def info(s)
puts s.bold.red
end

def success(s)
puts s.bold.green
end

def fail(s)
abort s.bold.red
end
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Foundation
import PixelEngine

extension CropView {
public final class _InteractiveCropGuideView: UIView, UIGestureRecognizerDelegate {
final class _InteractiveCropGuideView: PixelEditorCodeBasedView, UIGestureRecognizerDelegate {
var willChange: () -> Void = {}
var didChange: () -> Void = {}

Expand All @@ -50,10 +50,17 @@ extension CropView {
private(set) var lockedAspectRatio: PixelAspectRatio?

private let minimumSize = CGSize(width: 120, height: 120)

private let insetOfGuideFlexibility: UIEdgeInsets

init(containerView: CropView, imageView: UIView) {
init(
containerView: CropView,
imageView: UIView,
insetOfGuideFlexibility: UIEdgeInsets
) {
self.containerView = containerView
self.imageView = imageView
self.insetOfGuideFlexibility = insetOfGuideFlexibility

super.init(frame: .zero)

Expand Down Expand Up @@ -215,18 +222,13 @@ extension CropView {
}
}

@available(*, unavailable)
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Functions

/**
Displays a view as an overlay.
e.g. grid view
*/
public func setCropInsideOverlay(_ newOverlay: CropInsideOverlayBase?) {
func setCropInsideOverlay(_ newOverlay: CropInsideOverlayBase?) {
cropInsideOverlay?.removeFromSuperview()

if let overlay = newOverlay {
Expand All @@ -236,21 +238,29 @@ extension CropView {
}
}

func setCropOutsideOverlay(_ view: CropOutsideOverlayBase) {
func setCropOutsideOverlay(_ view: CropOutsideOverlayBase?) {
defer {
setNeedsLayout()
layoutIfNeeded()
}

guard let view = view else {
cropOutsideOverlay = nil
return
}

assert(view.superview != nil)
assert(view.superview is CropView)

cropOutsideOverlay = view

setNeedsLayout()
layoutIfNeeded()

}

func setLockedAspectRatio(_ aspectRatio: PixelAspectRatio?) {
lockedAspectRatio = aspectRatio
}

override public func layoutSubviews() {
override func layoutSubviews() {
super.layoutSubviews()

cropInsideOverlay?.frame = bounds
Expand All @@ -267,7 +277,7 @@ extension CropView {
}
}

override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let view = super.hitTest(point, with: event)

if view == self {
Expand All @@ -290,7 +300,7 @@ extension CropView {
@inline(__always)
private func updateMaximumRect() {
maximumRect = imageView.convert(imageView.bounds, to: containerView)
.intersection(containerView.bounds.insetBy(dx: 20, dy: 20))
.intersection(containerView.bounds.inset(by: insetOfGuideFlexibility))
}

private func onGestureTrackingStarted() {
Expand Down
Loading

0 comments on commit fb9b1db

Please sign in to comment.