mirror of
https://github.com/zhigang1992/FunctionalReactivePixels.git
synced 2026-01-12 22:47:31 +08:00
Presents login form when voting and not logged in.
This commit is contained in:
@@ -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;
|
||||
}];
|
||||
|
||||
@@ -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;
|
||||
}];
|
||||
|
||||
@@ -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;
|
||||
}];
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user