Skip to content

Commit 129d79e

Browse files
author
matan.cohen@jivesoftware.com
committed
Release 0.2.1 added spcift image resize size
1 parent 3c339b3 commit 129d79e

36 files changed

+498
-473
lines changed

.clang-format

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
BasedOnStyle: Chromium
3+
AlignTrailingComments: true
4+
ColumnLimit: 0
5+
IndentWidth: 4
6+
KeepEmptyLinesAtTheStartOfBlocks: false
7+
ObjCSpaceAfterProperty: true
8+
ObjCSpaceBeforeProtocolList: true
9+
PointerBindsToType: false
10+
SpacesBeforeTrailingComments: 1
11+
TabWidth: 8
12+
UseTab: Never

ImageFilesPicker.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'ImageFilesPicker'
4-
s.version = '0.2.0'
4+
s.version = '0.2.1'
55
s.summary = 'ImageFilesPicker'
66
s.homepage = 'https://github.com/mcmatan/ImageFilesPicker'
77
s.ios.deployment_target = '8.0'

ImagePicker/Resource/JVTActionSheetAction.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ typedef NS_ENUM(NSUInteger, kActionType) {
1414
};
1515

1616
@interface JVTActionSheetAction : NSObject
17-
@property (nonatomic,strong) NSString *title;
18-
@property (nonatomic,assign) kActionType actionType;
19-
@property (nonatomic,strong) void(^handler)(JVTActionSheetAction *handlerResonse);
20-
+ (JVTActionSheetAction *)actionWithTitle:(NSString *)title actionType:(kActionType) actionType handler:(void (^)(JVTActionSheetAction *action))handler;
17+
@property (nonatomic, strong) NSString *title;
18+
@property (nonatomic, assign) kActionType actionType;
19+
@property (nonatomic, strong) void (^handler)(JVTActionSheetAction *handlerResonse);
20+
+ (JVTActionSheetAction *)actionWithTitle:(NSString *)title actionType:(kActionType)actionType handler:(void (^)(JVTActionSheetAction *action))handler;
2121
@end

ImagePicker/Resource/JVTActionSheetAction.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
@implementation JVTActionSheetAction
1212

13-
+ (JVTActionSheetAction *)actionWithTitle:(NSString *)title actionType:(kActionType) actionType handler:(void (^)(JVTActionSheetAction *action))handler {
13+
+ (JVTActionSheetAction *)actionWithTitle:(NSString *)title actionType:(kActionType)actionType handler:(void (^)(JVTActionSheetAction *action))handler {
1414
return [[JVTActionSheetAction alloc] initWithActionWithTitle:title actionType:actionType handler:handler];
1515
}
1616

17-
- (instancetype)initWithActionWithTitle:(NSString *)title actionType:(kActionType) actionType handler:(void (^)(JVTActionSheetAction *action))handler {
17+
- (instancetype)initWithActionWithTitle:(NSString *)title actionType:(kActionType)actionType handler:(void (^)(JVTActionSheetAction *action))handler {
1818
self = [super init];
1919
if (self) {
2020
self.actionType = actionType;

ImagePicker/Resource/JVTActionSheetView.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010

1111
@protocol JVTActionSheetActionDelegate <NSObject>
1212

13-
-(void) actionSheetDidDismiss;
13+
- (void)actionSheetDidDismiss;
1414

1515
@end
1616

1717
@class JVTActionSheetAction;
1818
@import UIKit;
1919
@interface JVTActionSheetView : NSObject
2020
@property (nonatomic, weak) id<JVTActionSheetActionDelegate> delegate;
21-
-(void)addHeaderView:(UIView *) headerView ;
21+
- (void)addHeaderView:(UIView *)headerView;
2222
- (void)addAction:(JVTActionSheetAction *)action;
23-
-(void) presentOnTopOfView:(UIView *) view;
24-
-(void) dismiss;
25-
-(void) show ;
26-
-(BOOL) isPresented;
23+
- (void)presentOnTopOfView:(UIView *)view;
24+
- (void)dismiss;
25+
- (void)show;
26+
- (BOOL)isPresented;
2727
@end

ImagePicker/Resource/JVTActionSheetView.m

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,43 @@
1414

1515
static CGFloat itemHeight = 50;
1616

17-
@interface JVTActionSheetView () {}
18-
@property (nonatomic,strong) NSMutableArray<JVTActionSheetAction *> *actions;
19-
@property (nonatomic,weak) UIView *headerView;
20-
@property (nonatomic,assign) CGFloat sheetWidth;
21-
@property (nonatomic,strong) UIView *sheetView;
22-
@property (nonatomic,weak) UIView *presentingOnView;
17+
@interface JVTActionSheetView () {
18+
}
19+
@property (nonatomic, strong) NSMutableArray<JVTActionSheetAction *> *actions;
20+
@property (nonatomic, weak) UIView *headerView;
21+
@property (nonatomic, assign) CGFloat sheetWidth;
22+
@property (nonatomic, strong) UIView *sheetView;
23+
@property (nonatomic, weak) UIView *presentingOnView;
2324
@property (nonatomic, assign) BOOL isPresented;
2425
@end
2526

2627
@implementation JVTActionSheetView
2728

28-
-(instancetype) init {
29+
- (instancetype)init {
2930
self = [super init];
3031
if (self) {
31-
self.actions = [NSMutableArray array]; }
32+
self.actions = [NSMutableArray array];
33+
}
3234
return self;
3335
}
3436

3537
- (void)addAction:(JVTActionSheetAction *)action {
3638
[self.actions addObject:action];
3739
}
3840

39-
-(void)addHeaderView:(UIView *) headerView {
41+
- (void)addHeaderView:(UIView *)headerView {
4042
self.headerView = headerView;
4143
}
4244

43-
-(void) dismiss {
45+
- (void)dismiss {
4446
[self endPresentationAnimation];
4547
}
4648

47-
-(void) show {
49+
- (void)show {
4850
[self startPresentationAnimation];
4951
}
5052

51-
-(void) presentOnTopOfView:(UIView *) view {
53+
- (void)presentOnTopOfView:(UIView *)view {
5254
if (self.isPresented) {
5355
return;
5456
}
@@ -61,7 +63,6 @@ -(void) presentOnTopOfView:(UIView *) view {
6163
self.sheetView.backgroundColor = [UIColor whiteColor];
6264

6365
if (self.headerView) {
64-
6566
CGRect oldSheetViewFrame = self.sheetView.frame;
6667
oldSheetViewFrame.size.height += self.headerView.frame.size.height;
6768
self.sheetView.frame = oldSheetViewFrame;
@@ -74,7 +75,6 @@ -(void) presentOnTopOfView:(UIView *) view {
7475
}
7576

7677
for (JVTActionSheetAction *action in self.actions) {
77-
7878
UIView *itemView = [self itemViewForAction:action];
7979

8080
CGRect oldSheetViewFrame = self.sheetView.frame;
@@ -88,15 +88,14 @@ -(void) presentOnTopOfView:(UIView *) view {
8888
[self.sheetView addSubview:itemView];
8989
}
9090

91-
9291
[self.sheetView setHidden:YES];
9392

9493
[view addSubview:self.sheetView];
9594

9695
[self startPresentationAnimation];
9796
}
9897

99-
-(void) startPresentationAnimation {
98+
- (void)startPresentationAnimation {
10099
CGRect startFrame = self.sheetView.frame;
101100
startFrame.origin.y = self.presentingOnView.bounds.size.height;
102101
CGRect endFrame = startFrame;
@@ -105,39 +104,48 @@ -(void) startPresentationAnimation {
105104
[self.sheetView setFrame:startFrame];
106105
[self.sheetView setHidden:NO];
107106

108-
[UIView animateWithDuration:0.4 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
109-
[self.sheetView setFrame:endFrame];
110-
} completion:^(BOOL finished) {}];
107+
[UIView animateWithDuration:0.4
108+
delay:0
109+
options:UIViewAnimationOptionCurveEaseInOut
110+
animations:^{
111+
[self.sheetView setFrame:endFrame];
112+
}
113+
completion:^(BOOL finished){
114+
}];
111115
}
112116

113-
-(void) endPresentationAnimation {
117+
- (void)endPresentationAnimation {
114118
CGRect endFrame = self.sheetView.frame;
115119
endFrame.origin.y = self.presentingOnView.bounds.size.height;
116-
120+
117121
@weakify(self);
118-
[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
119-
@strongify(self);
120-
[self.sheetView setFrame:endFrame];
121-
} completion:^(BOOL finished) {
122-
@strongify(self);
123-
self.isPresented = NO;
124-
125-
if (self.delegate) {
126-
[self.delegate actionSheetDidDismiss];
127-
}
128-
}];
122+
[UIView animateWithDuration:0.3
123+
delay:0
124+
options:UIViewAnimationOptionCurveEaseInOut
125+
animations:^{
126+
@strongify(self);
127+
[self.sheetView setFrame:endFrame];
128+
}
129+
completion:^(BOOL finished) {
130+
@strongify(self);
131+
self.isPresented = NO;
132+
133+
if (self.delegate) {
134+
[self.delegate actionSheetDidDismiss];
135+
}
136+
}];
129137
}
130138

131-
-(UIView *) itemViewForAction:(JVTActionSheetAction *) action {
139+
- (UIView *)itemViewForAction:(JVTActionSheetAction *)action {
132140
UIView *view = [[UIView alloc] init];
133141
CGFloat linePaddingFromLeft = 10;
134142
UIView *topLineView = [[UIView alloc] initWithFrame:CGRectMake(linePaddingFromLeft, 0, self.sheetWidth - linePaddingFromLeft, 0.5)];
135-
topLineView.backgroundColor = [UIColor colorWithRed:221.0/255.0 green:221.0/255.0 blue:221.0/255.0 alpha:1.0];
143+
topLineView.backgroundColor = [UIColor colorWithRed:221.0 / 255.0 green:221.0 / 255.0 blue:221.0 / 255.0 alpha:1.0];
136144
[view addSubview:topLineView];
137145
UIBlockButton *btn = [[UIBlockButton alloc] init];
138146
[btn setTitle:action.title forState:UIControlStateNormal];
139147
[btn.titleLabel setTextAlignment:NSTextAlignmentCenter];
140-
[btn setTitleColor:[UIColor colorWithRed:46.0/255.0 green:145.0/255.0 blue:255.0/255.0 alpha:1.0] forState:UIControlStateNormal];
148+
[btn setTitleColor:[UIColor colorWithRed:46.0 / 255.0 green:145.0 / 255.0 blue:255.0 / 255.0 alpha:1.0] forState:UIControlStateNormal];
141149

142150
[view setFrame:CGRectMake(0, 0, self.sheetWidth, itemHeight)];
143151
[btn setFrame:view.frame];
@@ -148,16 +156,17 @@ -(UIView *) itemViewForAction:(JVTActionSheetAction *) action {
148156
[btn.titleLabel setFont:[UIFont systemFontOfSize:fontSize weight:fontWeight]];
149157

150158
@weakify(self);
151-
[btn handleControlEvent:UIControlEventTouchUpInside withBlock:^{
152-
@strongify(self);
153-
[self endPresentationAnimation];
154-
action.handler(action);
155-
}];
159+
[btn handleControlEvent:UIControlEventTouchUpInside
160+
withBlock:^{
161+
@strongify(self);
162+
[self endPresentationAnimation];
163+
action.handler(action);
164+
}];
156165

157166
return view;
158167
}
159168

160-
-(void) didTapOnDimmedBackground {
169+
- (void)didTapOnDimmedBackground {
161170
[self dismiss];
162171
}
163172

ImagePicker/Resource/JVTCameraAccesebility.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
#import <Foundation/Foundation.h>
1010

1111
@interface JVTCameraAccesebility : NSObject
12-
+(void) getCameraAccessibilityAndRequestIfNeeded:(void(^)(BOOL allowedToUseCamera))callback ;
13-
+(void) getPhotoRollAccessibilityAndRequestIfNeeded:(void(^)(BOOL allowedToUseCamera))callback ;
12+
+ (void)getCameraAccessibilityAndRequestIfNeeded:(void (^)(BOOL allowedToUseCamera))callback;
13+
+ (void)getPhotoRollAccessibilityAndRequestIfNeeded:(void (^)(BOOL allowedToUseCamera))callback;
1414
@end

ImagePicker/Resource/JVTCameraAccesebility.m

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,19 @@
1111
@import Photos;
1212
@import AssetsLibrary;
1313

14-
1514
@implementation JVTCameraAccesebility
1615

17-
+(void) getCameraAccessibilityAndRequestIfNeeded:(void(^)(BOOL allowedToUseCamera))callback {
18-
16+
+ (void)getCameraAccessibilityAndRequestIfNeeded:(void (^)(BOOL allowedToUseCamera))callback {
1917
AVAuthorizationStatus authorizationState = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
2018
switch (authorizationState) {
2119
case AVAuthorizationStatusNotDetermined: {
22-
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
23-
dispatch_async(dispatch_get_main_queue(), ^{
24-
callback(granted);
25-
});
26-
}];
27-
}
28-
break;
20+
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo
21+
completionHandler:^(BOOL granted) {
22+
dispatch_async(dispatch_get_main_queue(), ^{
23+
callback(granted);
24+
});
25+
}];
26+
} break;
2927
case AVAuthorizationStatusDenied:
3028
callback(NO);
3129
break;
@@ -35,12 +33,9 @@ +(void) getCameraAccessibilityAndRequestIfNeeded:(void(^)(BOOL allowedToUseCamer
3533
default:
3634
break;
3735
}
38-
39-
4036
}
4137

42-
+(void) getPhotoRollAccessibilityAndRequestIfNeeded:(void(^)(BOOL allowedToUseCamera))callback {
43-
38+
+ (void)getPhotoRollAccessibilityAndRequestIfNeeded:(void (^)(BOOL allowedToUseCamera))callback {
4439
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
4540
switch (status) {
4641
case PHAuthorizationStatusAuthorized:

ImagePicker/Resource/JVTCameraViewPreviewVC.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
@protocol JVTCameraViewPreviewVCDelegate <NSObject>
1313

14-
-(void) didPressTakeImage;
14+
- (void)didPressTakeImage;
1515

1616
@end
1717

1818
@interface JVTCameraViewPreviewVC : UIViewController
19-
-(void) setViewToPresent:(UIView *) view ;
19+
- (void)setViewToPresent:(UIView *)view;
2020
@property (nonatomic, weak) id<JVTCameraViewPreviewVCDelegate> delegate;
2121
@end

0 commit comments

Comments
 (0)