Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(991)

Unified Diff: pkg/immi_samples/lib/ios/ImmiSamples/LoginPresenter.mm

Issue 2035023003: Remove service-compiler related code. (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/immi_samples/lib/ios/ImmiSamples/LoginPresenter.mm
diff --git a/pkg/immi_samples/lib/ios/ImmiSamples/LoginPresenter.mm b/pkg/immi_samples/lib/ios/ImmiSamples/LoginPresenter.mm
deleted file mode 100644
index 8902612590be774c1f7bf201e9432426c6043d9a..0000000000000000000000000000000000000000
--- a/pkg/immi_samples/lib/ios/ImmiSamples/LoginPresenter.mm
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE.md file.
-
-#import "LoginPresenter.h"
-
-@interface LoginPresenter()
-@property UINavigationController* navigationController;
-@property Node* loginState;
-@end
-
-@implementation LoginPresenter
-
-- (void)viewDidLoad {
- self.password.delegate = self;
- [self.logoutButton setEnabled:NO];
-}
-
--(id)initWithCoder:(NSCoder*)aDecoder {
- self = [super initWithCoder:aDecoder];
- self.navigationController =
- [[UINavigationController alloc] initWithRootViewController:self];
- return self;
-}
-
-- (void)presentLogin:(LoginNode*)node {
- [self updateLoginState:node.state];
-}
-
-- (void)patchLogin:(LoginPatch*)patch {
- [self updateLoginState:patch.current.state];
-}
-
-- (void)updateLoginState:(Node*)state {
- self.loginState = state;
- if ([state is:LoginRequestStateNode.class]) {
-
- LoginRequestStateNode* loginRequestNode =
- [state as:LoginRequestStateNode.class];
- HttpsRequestNode* requestNode = loginRequestNode.request;
-
- NSString* authToken = requestNode.authorization;
- NSURL* url = [NSURL URLWithString:requestNode.url];
- NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
- [request setValue:authToken forHTTPHeaderField:@"Authorization"];
- NSURLSession* session = [NSURLSession sharedSession];
- NSURLSessionDataTask* postDataTask =
- [session dataTaskWithRequest:request
- completionHandler:^(NSData* data,
- NSURLResponse* response,
- NSError* error) {
- NSString* json =
- [[NSString alloc] initWithData:data
- encoding:NSUTF8StringEncoding];
- requestNode.handleResponse(json);
- }];
- [postDataTask resume];
- } else if ([state is:LoggedInStateNode.class]) {
- LoggedInStateNode* loggedInStateNode = [state as:LoggedInStateNode.class];
-
- dispatch_async(dispatch_get_main_queue(),^() {
- [self.logoutButton setEnabled:YES];
- [self.loginButton setEnabled:NO];
- [self.username setEnabled:NO];
- [self.password setEnabled:NO];
- [self.user setText:loggedInStateNode.user];
- [self.response setText:@""];
- });
- } else if ([state is:LoggedOutStateNode.class]) {
- dispatch_async(dispatch_get_main_queue(),^() {
- LoggedOutStateNode* loggedOutNode = [state as:LoggedOutStateNode.class];
-
- [self.logoutButton setEnabled:NO];
- [self.loginButton setEnabled:YES];
- [self.username setEnabled:YES];
- [self.password setEnabled:YES];
- [self.response setText:loggedOutNode.message];
- [self.user setText:@""];
- });
- }
-}
-
-- (IBAction)handleLogin:(id)sender {
- if ([self.loginState is:LoggedOutStateNode.class]) {
- LoggedOutStateNode* node = [self.loginState as:LoggedOutStateNode.class];
- node.login(self.username.text, self.password.text);
-
- [self.username setText: @""];
- [self.password setText: @""];
- }
-}
-
-- (BOOL)textFieldShouldReturn:(UITextField*)textField {
- [self handleLogin:textField];
- return YES;
-}
-
-- (IBAction)handleLogout:(id)sender {
- if ([self.loginState is:LoggedInStateNode.class]) {
- LoggedInStateNode* loggedIn = [self.loginState as:LoggedInStateNode.class];
- loggedIn.logout();
- }
-}
-
-- (UIViewController*)viewController {
- return self.navigationController;
-}
-
-@end
« no previous file with comments | « pkg/immi_samples/lib/ios/ImmiSamples/LoginPresenter.h ('k') | pkg/immi_samples/lib/ios/ImmiSamples/MenuPresenter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698