This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TCAppDelegate.m | |
// Three Cents | |
// | |
// Created by Shaun Parker on 11/5/12. | |
// Copyright (c) 2012 Three Cents, Inc. All rights reserved. | |
// | |
#if DEBUG | |
//#import <SparkInspector/SparkInspector.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) viewDidLoad { | |
//... | |
RACSignal *usernameIsValidSignal = RACObserve(self.viewModel, isUsernameValid); | |
RAC(self.goButton, enabled) = usernameIsValidSignal; | |
RAC(self.goButton, alpha) = [usernameIsValidSignal | |
map:^id(NSNumber *usernameIsValid) { | |
return usernameIsValid.boolValue ? @1.0 : @0.5; | |
}]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) viewDidLoad { | |
// ... | |
// create and get a reference to the signal | |
RACSignal *usernameValidSignal = RACObserve(self.viewModel, isUsernameValid); | |
// update the local property when this value changes | |
[usernameValidSignal subscribeNext:^(NSNumber *isValidNumber) { | |
self.usernameIsValid = isValidNumber.boolValue | |
}]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)textFieldDidChange:(UITextField *)sender { | |
// update the view-model | |
self.viewModel.username = sender.text; | |
// check if things are now valid | |
self.goButton.enabled = self.viewModel.isUsernameValid; | |
self.goButton.alpha = self.viewModel.isUsernameValid ? 1.0 : 0.5; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (id) initWithViewModel:(MYTwitterLookupViewModel *) viewModel { | |
self = [super init]; | |
if (!self) return nil; | |
_viewModel = viewModel; | |
return self; | |
} | |
- (void) viewDidLoad { | |
[super viewDidLoad]; | |
_goButton.enabled = viewModel.isUsernameValid; | |
_goButton.alpha = viewModel.isUsernameValid ? 1 : 0.5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.keyboardObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillChangeFrameNotification object:nil queue:nil usingBlock:^(NSNotification *notification) { | |
@strongify(self); | |
NSDictionary *keyboardAnimationDetail = [notification userInfo]; | |
CGRect keyboardEndFrameWindow = [keyboardAnimationDetail[UIKeyboardFrameEndUserInfoKey] CGRectValue]; | |
double keyboardTransitionDuration = [keyboardAnimationDetail[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; | |
UIViewAnimationCurve keyboardTransitionAnimationCurve = [keyboardAnimationDetail[UIKeyboardAnimationCurveUserInfoKey] integerValue]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (IBAction) didTapPrimaryUserAvatar | |
{ | |
MYTwitterUserProfileViewModel *userProfileViewModel = [self.viewModel viewModelForCurrentUser]; | |
MYTwitterUserProfileViewController *profileViewController = | |
[[MYTwitterUserProfileViewController alloc] initWithViewModel: userProfileViewModel]; | |
[self.navigationController pushViewController: profileViewController animated:YES]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface MYTweetCellViewModel: NSObject | |
@property (nonatomic, strong, readonly) NSString *tweetAuthorFullName; | |
@property (nonatomic, strong, readonly) UIImage *tweetAuthorAvatarImage; | |
@property (nonatomic, strong, readonly) NSString *tweetContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface MYTwitterLookupViewModel: NSObject | |
@property (nonatomic, assign, readonly, getter=isUsernameValid) BOOL usernameValid; | |
@property (nonatomic, strong, readonly) NSString *userFullName; | |
@property (nonatomic, strong, readonly) UIImage *userAvatarImage; | |
@property (nonatomic, strong, readonly) NSArray *tweets; | |
@property (nonatomic, assign, readonly) BOOL allTweetsLoaded; | |
@property (nonatomic, strong, readwrite) NSString *username; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) viewDidLoad { | |
[super viewDidLoad]; | |
self.fetchUserMenuDataCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) { | |
return [TCAPI fetchUserMenuData]; | |
}]; | |
RAC(self, menuData) = [self.fetchUserMenuDataCommand.executionSignals switchToLatest]; | |
RACSignal *userIsLoggedInSignal = [[[[NSNotificationCenter defaultCenter] rac_addObserverForName:kUserLoggedOutNotification object:nil] |