Commits

José Manuel Sánchez Peñarroja committed 54998c9

Added phoneAvailable to call activity. Added frmattedstring to complement formatString. Added buttonenabledsignal to loginvc

Comments (0)

Files changed (7)

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

Binary file modified.

bmf/ios/activities/BMFCallActivity.h

 
 @interface BMFCallActivity : BMFActivity
 
++ (BOOL) phoneAvailable;
+
 @end

bmf/ios/activities/BMFCallActivity.m

 
 @implementation BMFCallActivity
 
++ (BOOL) phoneAvailable {
+	return ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]]);
+}
+
 - (void) run:(BMFCompletionBlock)completionBlock {
 	
 	NSString *phone = [self finalPhoneValue];

bmf/ios/view controllers/BMFLoginViewController.h

 @property (nonatomic, weak) IBOutlet UIButton *loginButton;
 
 
+- (RACSignal *) buttonEnabledSignal;
+
 - (id<BMFTaskProtocol>) loginTask:(NSString *)user password:(NSString *) password;
 - (void) loginTaskFinished:(id) result error:(NSError *) error;
 

bmf/ios/view controllers/BMFLoginViewController.m

     [super viewDidLoad];
 
 	[self fillDefaultValues];
-	
-	RACSignal *userTextSignal = [self.userField rac_textSignal];
-	RACSignal *passTextSignal = [self.passwordField rac_textSignal];
+		
+//	@weakify(self);
+//	RACSignal *buttonEnabledSignal = [RACSignal combineLatest:@[ userTextSignal, passTextSignal ] reduce:^(NSString *user,NSString *password){
+//		@strongify(self);
+//		return @(user.length>0 && password.length>0 && !self.loaderView.progress.running);
+//	}];
 	
 	@weakify(self);
-	RACSignal *buttonEnabledSignal = [RACSignal combineLatest:@[ userTextSignal, passTextSignal ] reduce:^(NSString *user,NSString *password){
-		@strongify(self);
-		return @(user.length>0 && password.length>0 && !self.loaderView.progress.running);
-	}];
-	
-	self.loginButton.rac_command = [[RACCommand alloc] initWithEnabled:buttonEnabledSignal signalBlock:^RACSignal *(id input) {
+	self.loginButton.rac_command = [[RACCommand alloc] initWithEnabled:[self buttonEnabledSignal] signalBlock:^RACSignal *(id input) {
 		return [RACSignal defer:^RACSignal *{
 			@strongify(self);
 			[self login:self];
 		}];
 	}];
 	
+	RACSignal *userTextSignal = [self.userField rac_textSignal];
+	RACSignal *passTextSignal = [self.passwordField rac_textSignal];
+	
 	BMFResponderChainBehavior *textFieldsBehavior = [[BMFResponderChainBehavior alloc] initWithResponders:@[ self.userField,self.passwordField ]];
 	textFieldsBehavior.lastResponderReturnKeyType = UIReturnKeySend;
 	textFieldsBehavior.lastResponderActionBlock = ^(id sender) {
 	[self addBehavior:[BMFBackgroundTapStopsEditingBehavior new]];
 }
 
+- (RACSignal *) buttonEnabledSignal {
+	RACSignal *userTextSignal = [self.userField rac_textSignal];
+	RACSignal *passTextSignal = [self.passwordField rac_textSignal];
+
+	@weakify(self);
+	RACSignal *buttonEnabledSignal = [RACSignal combineLatest:@[ userTextSignal, passTextSignal ] reduce:^(NSString *user,NSString *password){
+		@strongify(self);
+		return @(user.length>0 && password.length>0 && !self.loaderView.progress.running);
+	}];
+	return buttonEnabledSignal;
+}
+
 - (void) fillDefaultValues {}
 
 - (void) login:(id) sender {

bmf/shared/categories/NSString+BMF.h

 @interface NSString (BMF)
 
 + (NSString *) BMF_formatString:(NSString *) string;
+- (NSString *) BMF_formattedString;
 
 + (NSString *) BMF_stringWithFloat:(CGFloat) value;
 + (NSString *) BMF_stringWithInteger:(NSInteger) value;

bmf/shared/categories/NSString+BMF.m

 	return @"";
 }
 
+- (NSString *) BMF_formattedString {
+	return [NSString BMF_formatString:self];
+}
+
 + (NSString *) BMF_stringWithFloat:(CGFloat) value {
 	char str[BMF_FLOAT_SIZE];
 	sprintf(str, "%f", value);