Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions GKClasses/GKImageCropViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ @implementation GKImageCropViewController


- (void)_actionCancel{
[self.navigationController popViewControllerAnimated:YES];
if (self.navigationController && self.navigationController.viewControllers.count > 1) {
[self.navigationController popViewControllerAnimated:YES];
} else {
[self dismissViewControllerAnimated:YES completion:NULL];
}
}


Expand Down Expand Up @@ -224,7 +228,12 @@ - (void)viewWillLayoutSubviews{
[super viewWillLayoutSubviews];

self.imageCropView.frame = self.view.bounds;
self.toolbar.frame = CGRectMake(0, CGRectGetHeight(self.view.frame) - 54, 320, 54);
CGSize size = [[UIScreen mainScreen] bounds].size;
UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, 0, 0);
if (@available(iOS 11.0, *)) {
insets = [UIApplication sharedApplication].keyWindow.safeAreaInsets;
}
self.toolbar.frame = CGRectMake(0, size.height - 54 - insets.bottom, size.width, 54);
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
Expand Down
4 changes: 3 additions & 1 deletion GKClasses/GKImagePicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>

@protocol GKImagePickerDelegate;

Expand Down Expand Up @@ -38,4 +40,4 @@
*/
- (void)imagePickerDidCancel:(GKImagePicker *)imagePicker;

@end
@end
28 changes: 28 additions & 0 deletions GKClasses/include/GKImageCropViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// GKImageCropViewController.h
// GKImagePicker
//
// Created by Georg Kitz on 6/1/12.
// Copyright (c) 2012 Aurora Apps. All rights reserved.
//

#import <UIKit/UIKit.h>

@protocol GKImageCropControllerDelegate;

@interface GKImageCropViewController : UIViewController{
UIImage *_croppedImage;
}

@property (nonatomic, strong) UIImage *sourceImage;
@property (nonatomic, assign) CGSize cropSize; //size of the crop rect, default is 320x320
@property (nonatomic, assign) BOOL resizeableCropArea;
@property (nonatomic, strong) id<GKImageCropControllerDelegate> delegate;

@end


@protocol GKImageCropControllerDelegate <NSObject>
@required
- (void)imageCropController:(GKImageCropViewController *)imageCropController didFinishWithCroppedImage:(UIImage *)croppedImage;
@end
43 changes: 43 additions & 0 deletions GKClasses/include/GKImagePicker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// GKImagePicker.h
// GKImagePicker
//
// Created by Georg Kitz on 6/1/12.
// Copyright (c) 2012 Aurora Apps. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>

@protocol GKImagePickerDelegate;

@interface GKImagePicker : NSObject

@property (nonatomic, weak) id<GKImagePickerDelegate> delegate;
@property (nonatomic, assign) CGSize cropSize; //default value is 320x320 (which is exactly the same as the normal imagepicker uses)
@property (nonatomic, strong, readonly) UIImagePickerController *imagePickerController;
@property (nonatomic, assign) BOOL resizeableCropArea;

@end


@protocol GKImagePickerDelegate <NSObject>

@optional

/**
* @method imagePicker:pickedImage: gets called when a user has chosen an image
* @param imagePicker, the image picker instance
* @param image, the picked and cropped image
*/
- (void)imagePicker:(GKImagePicker *)imagePicker pickedImage:(UIImage *)image;


/**
* @method imagePickerDidCancel: gets called when the user taps the cancel button
* @param imagePicker, the image picker instance
*/
- (void)imagePickerDidCancel:(GKImagePicker *)imagePicker;

@end
16 changes: 16 additions & 0 deletions GKImagePicker.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Pod::Spec.new do |s|
s.name = 'GKImagePicker'
s.version = '1.0.0'
s.summary = 'Image Picker easy for usage. Compatible with both Swift and Objective-C.'

s.homepage = 'https://github.com/janlionly/GKImagePicker'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'janlionly' => 'janlionly@gmail.com' }
s.source = { :git => 'https://github.com/janlionly/GKImagePicker.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/janlionly'
s.ios.deployment_target = '9.0'
s.requires_arc = true
s.source_files = 'GKClasses/*.{h,m}'
s.swift_versions = ['4.2', '5.0', '5.1', '5.2', '5.3']
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.2' }
end
29 changes: 29 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "GKImagePicker",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "GKImagePicker",
targets: ["GKImagePicker"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "GKImagePicker",
dependencies: [],
path: "GKClasses"),
.testTarget(
name: "GKImagePickerTests",
dependencies: ["GKImagePicker"]),
]
)
15 changes: 15 additions & 0 deletions Tests/GKImagePickerTests/GKImagePickerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import XCTest
@testable import GKImagePicker

final class GKImagePickerTests: XCTestCase {
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
XCTAssertEqual(GKImagePicker().text, "Hello, World!")
}

static var allTests = [
("testExample", testExample),
]
}
9 changes: 9 additions & 0 deletions Tests/GKImagePickerTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import XCTest

#if !canImport(ObjectiveC)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(GKImagePickerTests.allTests),
]
}
#endif
7 changes: 7 additions & 0 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import XCTest

import GKImagePickerTests

var tests = [XCTestCaseEntry]()
tests += GKImagePickerTests.allTests()
XCTMain(tests)
18 changes: 10 additions & 8 deletions license
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
Copyright (C) 2012, Georg Kitz, @gekitz
MIT License

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:
Copyright (c) 2020 janlionly

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.
Expand All @@ -16,4 +18,4 @@ 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.
SOFTWARE.