Skip to content

Commit

Permalink
Converted to Swift 3 #4
Browse files Browse the repository at this point in the history
  • Loading branch information
mozharovsky committed Nov 26, 2016
1 parent 8485698 commit e761a6c
Show file tree
Hide file tree
Showing 68 changed files with 709 additions and 680 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added Example/.DS_Store
Binary file not shown.
Binary file added Example/Athlee-ImageEditorKit/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
046417921D3D50F300C9AE3F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 046417901D3D50F300C9AE3F /* Main.storyboard */; };
046417941D3D50F300C9AE3F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 046417931D3D50F300C9AE3F /* Assets.xcassets */; };
046417971D3D50F300C9AE3F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 046417951D3D50F300C9AE3F /* LaunchScreen.storyboard */; };
046417A21D3D50F400C9AE3F /* Athlee_ImageEditorKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 046417A11D3D50F400C9AE3F /* Athlee_ImageEditorKitTests.swift */; };
046417AF1D3D53D500C9AE3F /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 046417AE1D3D53D500C9AE3F /* ImageViewController.swift */; };
046417B11D3D53EB00C9AE3F /* ContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 046417B01D3D53EB00C9AE3F /* ContainerViewController.swift */; };
046417B31D3D540200C9AE3F /* FilterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 046417B21D3D540200C9AE3F /* FilterViewController.swift */; };
Expand Down Expand Up @@ -110,7 +109,6 @@
046417961D3D50F300C9AE3F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
046417981D3D50F300C9AE3F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0464179D1D3D50F400C9AE3F /* Athlee-ImageEditorKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Athlee-ImageEditorKitTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
046417A11D3D50F400C9AE3F /* Athlee_ImageEditorKitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Athlee_ImageEditorKitTests.swift; sourceTree = "<group>"; };
046417A31D3D50F400C9AE3F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
046417AE1D3D53D500C9AE3F /* ImageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageViewController.swift; sourceTree = "<group>"; };
046417B01D3D53EB00C9AE3F /* ContainerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -321,7 +319,6 @@
046417A01D3D50F400C9AE3F /* Athlee-ImageEditorKitTests */ = {
isa = PBXGroup;
children = (
046417A11D3D50F400C9AE3F /* Athlee_ImageEditorKitTests.swift */,
046417A31D3D50F400C9AE3F /* Info.plist */,
);
path = "Athlee-ImageEditorKitTests";
Expand Down Expand Up @@ -433,9 +430,12 @@
TargetAttributes = {
046417881D3D50F300C9AE3F = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = RG4N372RZE;
LastSwiftMigration = 0810;
};
0464179C1D3D50F400C9AE3F = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0810;
TestTargetID = 046417881D3D50F300C9AE3F;
};
};
Expand Down Expand Up @@ -507,7 +507,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
9703A31870DB4752FA3EBC66 /* [CP] Copy Pods Resources */ = {
Expand Down Expand Up @@ -582,7 +582,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
046417A21D3D50F400C9AE3F /* Athlee_ImageEditorKitTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -704,10 +703,12 @@
baseConfigurationReference = F6D6F5EEAA6737C7520DFF3B /* Pods-Athlee-ImageEditorKit.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = RG4N372RZE;
INFOPLIST_FILE = "Athlee-ImageEditorKit/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.athlee.Athlee-ImageEditorKit";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -717,10 +718,12 @@
baseConfigurationReference = 23388D0110DDFB6BDDAA317F /* Pods-Athlee-ImageEditorKit.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = RG4N372RZE;
INFOPLIST_FILE = "Athlee-ImageEditorKit/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.athlee.Athlee-ImageEditorKit";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -733,6 +736,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.athlee.Athlee-ImageEditorKitTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Athlee-ImageEditorKit.app/Athlee-ImageEditorKit";
};
name = Debug;
Expand All @@ -745,6 +749,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.athlee.Athlee-ImageEditorKitTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Athlee-ImageEditorKit.app/Athlee-ImageEditorKit";
};
name = Release;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
return true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ final class BrightnessViewController: UIViewController {

@IBOutlet weak var twoSideSlider: TwoSideSlider!

var parent: ContainerViewController!
var _parent: ContainerViewController!

override func viewDidLoad() {
super.viewDidLoad()
}

@IBAction func didUpdateValue(sender: TwoSideSlider) {
@IBAction func didUpdateValue(_ sender: TwoSideSlider) {
let value = Float(sender.currentValue) * 0.001
ContainerViewController.Children.image.brightnessValue = value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import UIKit
final class ContainerViewController: UIViewController {

enum State {
case Filters
case Brightness
case Crop
case filters
case brightness
case crop
}

// MARK: Outlets
Expand All @@ -35,7 +35,7 @@ final class ContainerViewController: UIViewController {
static var crop: CropViewController!
}

var state: State = .Filters { didSet { updateVisibility() } }
var state: State = .filters { didSet { updateVisibility() } }

// MARK: Life cycle

Expand All @@ -46,22 +46,22 @@ final class ContainerViewController: UIViewController {
updateVisibility()
}

override func prefersStatusBarHidden() -> Bool {
override var prefersStatusBarHidden : Bool {
return true
}

// MARK: Actions

@IBAction func didPressFilterButton(sender: AnyObject) {
state = .Filters
@IBAction func didPressFilterButton(_ sender: AnyObject) {
state = .filters
}

@IBAction func didPressBrightnessButton(sender: AnyObject) {
state = .Brightness
@IBAction func didPressBrightnessButton(_ sender: AnyObject) {
state = .brightness
}

@IBAction func didPressCropButton(sender: AnyObject) {
state = .Crop
@IBAction func didPressCropButton(_ sender: AnyObject) {
state = .crop
}

// MARK: Utils
Expand All @@ -77,7 +77,7 @@ final class ContainerViewController: UIViewController {

case is BrightnessViewController:
Children.brightness = child as! BrightnessViewController
Children.brightness.parent = self
Children.brightness._parent = self

case is CropViewController:
Children.crop = child as! CropViewController
Expand All @@ -93,25 +93,25 @@ final class ContainerViewController: UIViewController {
brightnessView.alpha = 0
cropView.alpha = 0

filtersButton.selected = false
brightnessButton.selected = false
cropButton.selected = false
filtersButton.isSelected = false
brightnessButton.isSelected = false
cropButton.isSelected = false

switch state {
case .Filters:
case .filters:
title = "Select a filter"
filtersView.alpha = 1
filtersButton.selected = true
filtersButton.isSelected = true
Children.image.croppingBegan(false)
case .Brightness:
case .brightness:
title = "Adjust brightness"
brightnessView.alpha = 1
brightnessButton.selected = true
brightnessButton.isSelected = true
Children.image.croppingBegan(false)
case .Crop:
case .crop:
title = "Crop the image"
cropView.alpha = 1
cropButton.selected = true
cropButton.isSelected = true
Children.image.croppingBegan(true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ final class CropViewController: UIViewController {

// MARK: Life cycle

override func viewDidAppear(animated: Bool) {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
scalePicker.reset()
}

// MARK: IBActions

@IBAction func didPressResetButton(sender: AnyObject) {
@IBAction func didPressResetButton(_ sender: AnyObject) {
scalePicker.reset()
transformView.transform = CGAffineTransformIdentity
transformView.transform = CGAffineTransform.identity
theta = 0
beta = 0
}

@IBAction func didChangeValue(sender: ScalePicker) {
@IBAction func didChangeValue(_ sender: ScalePicker) {
let value = sender.value
beta = value
let angle = theta + value
let transform = CGAffineTransformMakeRotation(angle.toRadians())
let transform = CGAffineTransform(rotationAngle: angle.toRadians())
transformView.transform = transform
}

@IBAction func didPressRotateButton(sender: AnyObject) {
@IBAction func didPressRotateButton(_ sender: AnyObject) {
theta += -90
let transform = CGAffineTransformMakeRotation((theta + beta).toRadians())
let transform = CGAffineTransform(rotationAngle: (theta + beta).toRadians())
transformView.transform = transform
}
}
Expand All @@ -58,4 +58,4 @@ extension Float {
func toRadians() -> CGFloat {
return CGFloat(self) * (CGFloat(M_PI) / 180)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ final class FilterCell: UICollectionViewCell {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var filterNameLabel: UILabel!

override var selected: Bool {
override var isSelected: Bool {
didSet {
if selected {
if isSelected {
filterNameLabel.textColor = UIColor(hex: 0x876DF3)
filterNameLabel.alpha = 1
} else {
filterNameLabel.textColor = UIColor.grayColor()
filterNameLabel.textColor = UIColor.gray
filterNameLabel.alpha = 0.8
}
}
Expand Down
Loading

0 comments on commit e761a6c

Please sign in to comment.