Skip to content

Commit

Permalink
First version of MKParentalGate
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkamprath committed Oct 20, 2013
1 parent 469d4bc commit acfc0ad
Show file tree
Hide file tree
Showing 18 changed files with 1,457 additions and 62 deletions.
2 changes: 2 additions & 0 deletions Other/MKParentalGate/MKParentalGate.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ typedef void (^MKParentalGateFailureBlock)(void);

+(void)displayGateWithCurrentViewController:(UIViewController*)inViewController successBlock:(MKParentalGateSuccessBlock)inSuccessBlock failureBlock:(MKParentalGateFailureBlock)inFailureBlock;

+(void)displayGateWithCurrentViewController:(UIViewController*)inViewController successBlock:(MKParentalGateSuccessBlock)inSuccessBlock failureBlock:(MKParentalGateFailureBlock)inFailureBlock title:(NSString*)inTitle explanatoryMessage:(NSString*)inMessage;

@end
7 changes: 5 additions & 2 deletions Other/MKParentalGate/MKParentalGate.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ @implementation MKParentalGate

+(void)displayGateWithCurrentViewController:(UIViewController*)inViewController successBlock:(MKParentalGateSuccessBlock)inSuccessBlock failureBlock:(MKParentalGateFailureBlock)inFailureBlock
{

[MKParentalGate displayGateWithCurrentViewController:inViewController successBlock:inSuccessBlock failureBlock:inFailureBlock title:nil explanatoryMessage:nil];
}

MKParentalGateViewController* gateVC = [[MKParentalGateViewController alloc] initWithStopIcon:[UIImage imageNamed:@"stop.png"] goIcon:nil successBlock:inSuccessBlock failureBlock:inFailureBlock];
+(void)displayGateWithCurrentViewController:(UIViewController*)inViewController successBlock:(MKParentalGateSuccessBlock)inSuccessBlock failureBlock:(MKParentalGateFailureBlock)inFailureBlock title:(NSString*)inTitle explanatoryMessage:(NSString*)inMessage
{
MKParentalGateViewController* gateVC = [[MKParentalGateViewController alloc] initWithStopIcon:[UIImage imageNamed:@"stop.png"] successBlock:inSuccessBlock failureBlock:inFailureBlock title:inTitle explanatoryMessage:inMessage];

[inViewController presentViewController:gateVC animated:YES completion:NULL];

Expand Down
26 changes: 24 additions & 2 deletions Other/MKParentalGate/MKParentalGateTouchCancelView.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
//
// MKParentalGateTouchCancelView.h
// iPhoneMK Sample App
//
// Created by Michael Kamprath on 10/20/13.
// Copyright 2013 Michael F. Kamprath
// [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import "MKTouchTrackingView.h"

@class MKParentalGateTouchCancelView;

@protocol MKParentalGateTouchCancelDelegate <NSObject>

@required
-(void)handleCancelTouchDown:(MKParentalGateTouchCancelView*)inTouchCancelView;
-(void)handleCancelTouchUp:(MKParentalGateTouchCancelView*)inTouchCancelView;

@end

@interface MKParentalGateTouchCancelView : MKTouchTrackingView
@property (weak,nonatomic) id<MKParentalGateTouchCancelDelegate> delegate;

@end
62 changes: 53 additions & 9 deletions Other/MKParentalGate/MKParentalGateTouchCancelView.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
//
// MKParentalGateTouchCancelView.m
// iPhoneMK Sample App
//
// Created by Michael Kamprath on 10/20/13.
// Copyright 2013 Michael F. Kamprath
// [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#ifndef __has_feature
#define __has_feature(x) 0
#endif
#ifndef __has_extension
#define __has_extension __has_feature // Compatibility with pre-3.0 compilers.
#endif

#if !(__has_feature(objc_arc) && __clang_major__ >= 3)
#error "MKParentalGate is designed to be used with ARC. Please add '-fobjc-arc' to the compiler flags of MKParentalGateViewController.m."
#endif // __has_feature(objc_arc)

#import "MKParentalGateTouchCancelView.h"

Expand All @@ -19,13 +41,35 @@ - (id)initWithFrame:(CGRect)frame
return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
}
return self;
}
*/

-(void)touchInViewBegan {
if (nil != self.delegate ) {
[self.delegate handleCancelTouchDown:self];
}
}

-(void)touchTrackedIntoView {
if (nil != self.delegate ) {
[self.delegate handleCancelTouchDown:self];
}
}

-(void)touchUpInView {
if (nil != self.delegate ) {
[self.delegate handleCancelTouchUp:self];
}
}

-(void)touchTrackedOutOfView {
if (nil != self.delegate ) {
[self.delegate handleCancelTouchUp:self];
}
}
@end
20 changes: 17 additions & 3 deletions Other/MKParentalGate/MKParentalGateTouchTargetView.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
//
// MKParentalGateTouchTargetView.h
// iPhoneMK Sample App
//
// Created by Michael Kamprath on 10/19/13.
// Copyright 2013 Michael F. Kamprath
// [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import "MKTouchTrackingAnimationView.h"
Expand All @@ -20,9 +31,12 @@

@interface MKParentalGateTouchTargetView : MKTouchTrackingAnimationView

- (id)initWithFrame:(CGRect)frame stopIcon:(UIImage*)inStopIcon goIcon:(UIImage*)inGoIcon delegate:(id<MKParentalGateTouchTargetDelegate>)inDelegate;
- (id)initWithFrame:(CGRect)frame stopIcon:(UIImage*)inStopIcon delegate:(id<MKParentalGateTouchTargetDelegate>)inDelegate;

-(void)resetAnimationLayerFrame;

-(void)startAnimation;
-(void)stopAnimation;
-(void)pauseAnimation;
-(void)resumeAnimation;

Expand Down
38 changes: 33 additions & 5 deletions Other/MKParentalGate/MKParentalGateTouchTargetView.m
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
//
// MKParentalGateTouchTargetView.m
// iPhoneMK Sample App
//
// Created by Michael Kamprath on 10/19/13.
// Copyright 2013 Michael F. Kamprath
// [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#ifndef __has_feature
#define __has_feature(x) 0
#endif
#ifndef __has_extension
#define __has_extension __has_feature // Compatibility with pre-3.0 compilers.
#endif

#if !(__has_feature(objc_arc) && __clang_major__ >= 3)
#error "MKParentalGate is designed to be used with ARC. Please add '-fobjc-arc' to the compiler flags of MKParentalGateViewController.m."
#endif // __has_feature(objc_arc)

#import "MKParentalGateTouchTargetView.h"
@interface MKParentalGateTouchTargetView ()
@property (strong,nonatomic) UIImage* goIcon;
@property (strong,nonatomic) UIImage* stopIcon;
@property (weak,nonatomic) id<MKParentalGateTouchTargetDelegate> delegate;
@end

@implementation MKParentalGateTouchTargetView

- (id)initWithFrame:(CGRect)frame stopIcon:(UIImage*)inStopIcon goIcon:(UIImage*)inGoIcon delegate:(id<MKParentalGateTouchTargetDelegate>)inDelegate;
- (id)initWithFrame:(CGRect)frame stopIcon:(UIImage*)inStopIcon delegate:(id<MKParentalGateTouchTargetDelegate>)inDelegate;
{
self = [super initWithFrame:frame];
if (self) {
self.goIcon = inGoIcon;
self.stopIcon = inStopIcon;
self.delegate = inDelegate;

Expand All @@ -40,12 +60,20 @@ - (void)drawRect:(CGRect)rect
}
*/

-(void)resetAnimationLayerFrame {
self.animationLayer.frame = CGRectMake(0, 0, self.animationLayer.frame.size.width, self.animationLayer.frame.size.height);
}

#pragma mark - Animation

-(void)startAnimation {
[self.animationLayer startAnimating];
}

-(void)stopAnimation {
[self.animationLayer stopAnimatingImmeditely:YES];
}

-(void)pauseAnimation {
[self.animationLayer pauseAnimation];
}
Expand Down
19 changes: 14 additions & 5 deletions Other/MKParentalGate/MKParentalGateViewController.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
//
// MKParentalGateViewController.h
// iPhoneMK Sample App
//
// Created by Michael Kamprath on 10/19/13.
// Copyright 2013 Michael F. Kamprath
// [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import <UIKit/UIKit.h>
#import "MKParentalGate.h"

@interface MKParentalGateViewController : UIViewController

- (id)initWithStopIcon:(UIImage*)inStopIcon goIcon:(UIImage*)inGoIcon successBlock:(MKParentalGateSuccessBlock)inSuccessBlock failureBlock:(MKParentalGateFailureBlock)inFailureBlock;

-(id)initWithStopIcon:(UIImage*)inStopIcon successBlock:(MKParentalGateSuccessBlock)inSuccessBlock failureBlock:(MKParentalGateFailureBlock)inFailureBlock title:(NSString*)inTitle explanatoryMessage:(NSString*)inMessage;
@end
Loading

0 comments on commit acfc0ad

Please sign in to comment.