Presents login form when voting and not logged in.

This commit is contained in:
Ash Furrow
2013-10-20 16:04:11 -04:00
parent 8ab53a8620
commit b127aeb191
5 changed files with 42 additions and 5 deletions

View File

@@ -62,7 +62,9 @@
FRPPhotoDetailViewController *viewController = [[FRPPhotoDetailViewController alloc] initWithPhotoModel:[self.pageViewController.viewControllers.firstObject photoModel]];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self presentViewController:navigationController animated:YES completion:nil];
[self presentViewController:navigationController animated:YES completion:^{
[subscriber sendCompleted];
}];
return nil;
}];

View File

@@ -80,7 +80,9 @@ static NSString *CellIdentifier = @"Cell";
FRPLoginViewController *viewController = [[FRPLoginViewController alloc] initWithNibName:@"FRPLoginViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self presentViewController:navigationController animated:YES completion:nil];
[self presentViewController:navigationController animated:YES completion:^{
[subscriber sendCompleted];
}];
return nil;
}];

View File

@@ -56,7 +56,9 @@
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
@strongify(self);
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
[self.presentingViewController dismissViewControllerAnimated:YES completion:^{
[subscriber sendCompleted];
}];
return nil;
}];

View File

@@ -6,7 +6,9 @@
// Copyright (c) 2013 Ash Furrow. All rights reserved.
//
// View Controllers
#import "FRPPhotoDetailViewController.h"
#import "FRPLoginViewController.h"
// Model
#import "FRPPhotoModel.h"
@@ -42,7 +44,9 @@
self.navigationItem.rightBarButtonItem.rac_command = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
@strongify(self);
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
[self.presentingViewController dismissViewControllerAnimated:YES completion:^{
[subscriber sendCompleted];
}];
return nil;
}];
@@ -77,8 +81,34 @@
UIButton *voteButton = [UIButton buttonWithType:UIButtonTypeCustom];
voteButton.frame = CGRectMake(20, CGRectGetHeight(self.view.bounds) - 44 - 20, CGRectGetWidth(self.view.bounds) - 40, 44);
[voteButton setTitle:@"Vote" forState:UIControlStateNormal];
voteButton.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
[RACObserve(self.photoModel, isVotedFor) subscribeNext:^(id x) {
if ([x boolValue]) {
[voteButton setTitle:@"Voted For!" forState:UIControlStateNormal];
} else {
[voteButton setTitle:@"Vote" forState:UIControlStateNormal];
}
}];
voteButton.rac_command = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
if (AppDelegate.apiHelper.authMode == PXAPIHelperModeNoAuth) {
// Not logged in
@strongify(self);
FRPLoginViewController *viewController = [[FRPLoginViewController alloc] initWithNibName:@"FRPLoginViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self presentViewController:navigationController animated:YES completion:^{
[subscriber sendCompleted];
}];
return nil;
} else {
return nil;
}
}];
}];
[self.view addSubview:voteButton];
}
@end

View File

@@ -18,5 +18,6 @@
@property (nonatomic, strong) NSData *thumbnailData;
@property (nonatomic, strong) NSString *fullsizedURL;
@property (nonatomic, strong) NSData *fullsizedData;
@property (nonatomic, assign, getter = isVotedFor) BOOL votedFor;
@end