Commits

José Manuel Sánchez Peñarroja  committed 9bbe7d5

Added mode to control rotate aspect. Added method to get url from string (remove whitespaces and such). Now the datasource sets itself as the datasource of the tableview. Added harlemshake method with strength option

  • Participants
  • Parent commits 5f3dd41

Comments (0)

Files changed (10)

File Example/Example.xcworkspace/xcuserdata/josanchez.xcuserdatad/UserInterfaceState.xcuserstate

Binary file modified.

File bmf/ios/aspects/BMFControlRotateAspect.h

 
 #import "BMFAspect.h"
 
+typedef NS_ENUM(NSUInteger, BMFControlRotateAspectMode) {
+    BMFControlRotateAspectModeOnce,
+    BMFControlRotateAspectModeToggle
+};
+
 @interface BMFControlRotateAspect : BMFAspect
 
+/// 90 by default
+@property (nonatomic, assign) CGFloat angle;
+
+/// BMFControlRotateAspectModeOnce by default
+@property (nonatomic, assign) BMFControlRotateAspectMode mode;
+
 /// 0.2 by default
 @property (nonatomic, assign) CGFloat animationDuration;
 

File bmf/ios/aspects/BMFControlRotateAspect.m

 - (instancetype) init {
 	self = [super init];
 	if (self) {
+		_angle = 90;
+		_mode = BMFControlRotateAspectModeOnce;
 		_animationDuration = 0.2;
 		_damping = 0.95;
 		_springVelocity = 0.05;
 		}
 		
 		[UIView animateWithDuration:self.animationDuration delay:0 usingSpringWithDamping:self.damping initialSpringVelocity:self.springVelocity options:0 animations:^{
-			control.transform = CGAffineTransformMakeRotation(BMF_DEGREES_TO_RADIANS(90));
+			if (_mode==BMFControlRotateAspectModeToggle && !CGAffineTransformIsIdentity(control.transform)) {
+				control.transform = CGAffineTransformIdentity;
+			}
+			else control.transform = CGAffineTransformMakeRotation(BMF_DEGREES_TO_RADIANS(_angle));
 		} completion:^(BOOL finished){
-			control.transform = CGAffineTransformIdentity;
+			if (_mode==BMFControlRotateAspectModeOnce) control.transform = CGAffineTransformIdentity;
 		}];
 	}
 }

File bmf/ios/data/data sources/BMFTableViewDataSource.m

 
 - (void) setTableView:(UITableView *)tableView {
  	_tableView = tableView;
+	
+	_tableView.dataSource = self;
  	
 	[self registerCells];
 	[self registerViews];
+	
+	[_tableView reloadData];
 }
 
 - (void) registerCells {

File bmf/ios/factories/BMFIOSDefaultFactory.h

 - (id) collectionViewDataSourceWithStore:(id<BMFDataReadProtocol>) store cellClassOrNib:(id) classOrNib sender:(id) sender;
 - (id) collectionViewDataSourceWithStore:(id<BMFDataReadProtocol>) store cellRegisterBlock:(BMFCellRegisterCellsBlock) registerBlock cellIdBlock:(BMFCellIdBlock)cellIdBlock sender:(id) sender;
 
+
+#pragma mark Cell Register
+- (id) blockCellRegister:(BMFCellRegisterCellsBlock)registerBlock cellIdBlock:(BMFCellIdBlock) cellIdBlock sender:(id)sender;
+
+
 #pragma mark Map view
 
 - (id<BMFDataSourceProtocol>) mapViewDataSourceWithStore:(id<BMFDataReadProtocol>) store sender:(id) sender;

File bmf/ios/views/cell configuration/BMFViewConfiguratorProtocol.h

 
 @protocol BMFViewConfiguratorProtocol <NSObject>
 
-+ (BOOL) canConfigure:(id) view kind:(BMFViewKind)kind withItem:(id) item inView:(id)view;
++ (BOOL) canConfigure:(id) view kind:(BMFViewKind)kind withItem:(id) item inView:(id)containerView;
 + (void) configure:(id) view kind:(BMFViewKind)kind withItem:(id)item inView:(UIView *) containerView atIndexPath:(NSIndexPath *) indexPath controller:(id) controller;
 
 @optional

File bmf/shared/categories/NSString+BMF.h

 
 - (NSString *) BMF_unaccentedString;
 
+- (NSURL *) BMF_url;
+
 @end

File bmf/shared/categories/NSString+BMF.m

 	return [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
 }
 
+- (NSURL *) BMF_url {
+	return [NSURL URLWithString:[self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
+}
+
 @end

File bmf/shared/utils/BMFAnimationUtils.h

 
 @interface BMFAnimationUtils : NSObject
 
+/// The strength used will be 0.05
 + (void) harlemShake:(CALayer *) layer vibrate:(BOOL) vibrate;
 
++ (void) harlemShake:(CALayer *) layer strength:(CGFloat)strength vibrate:(BOOL) vibrate;
+
 @end

File bmf/shared/utils/BMFAnimationUtils.m

 @implementation BMFAnimationUtils
 
 + (void) harlemShake:(CALayer *) layer vibrate:(BOOL) vibrate {
+	[self harlemShake:layer strength:0.05 vibrate:vibrate];
+}
+
++ (void) harlemShake:(CALayer *) layer strength:(CGFloat)strength vibrate:(BOOL) vibrate {
 	CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
-	[anim setToValue:[NSNumber numberWithFloat:-0.05f]];
-	[anim setFromValue:[NSNumber numberWithFloat:0.05f]];
+	[anim setToValue:[NSNumber numberWithFloat:-strength]];
+	[anim setFromValue:[NSNumber numberWithFloat:strength]];
 	[anim setDuration:0.09f];
 	[anim setRepeatCount:2];
 	[anim setAutoreverses:YES];