-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeftNavViewController.m
More file actions
102 lines (79 loc) · 3.01 KB
/
LeftNavViewController.m
File metadata and controls
102 lines (79 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// LeftNavViewController.m
// TwitterClient
//
// Created by Jessica Ko on 4/3/14.
// Copyright (c) 2014 Jessica Ko. All rights reserved.
//
#import "LeftNavViewController.h"
#import "MenuSliderViewController.h"
#import "MyProfileViewController.h"
#import "Client.h"
#import "User.h"
@interface LeftNavViewController ()
- (void)handleTap:(UITapGestureRecognizer *)recognizer;
@end
@implementation LeftNavViewController
@synthesize delegate = _delegate;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSDictionary *currentUser = [User currentUserDictionary];
self.fullname.text = [currentUser objectForKey:@"name"];
self.screenname.text = [NSString stringWithFormat:@"@%@", [currentUser objectForKey:@"screen_name"]];
NSString *biggerImgUrl = [[currentUser objectForKey:@"profile_image_url"] stringByReplacingOccurrencesOfString:@"_normal" withString:@"_bigger"];
NSURL *url = [NSURL URLWithString:biggerImgUrl];
NSLog(@"%@", currentUser);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
NSData *imageData = [NSData dataWithContentsOfURL:url];
dispatch_async(dispatch_get_main_queue(), ^{
self.profileImage.image = [UIImage imageWithData:imageData];
});
});
NSURL *urlbg = [NSURL URLWithString:[NSString stringWithFormat:@"%@/web", [currentUser objectForKey:@"profile_banner_url"]]];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
NSData *imageDataBG = [NSData dataWithContentsOfURL:urlbg];
dispatch_async(dispatch_get_main_queue(), ^{
self.backgroundImage.image = [UIImage imageWithData:imageDataBG];
});
});
UITapGestureRecognizer *tabRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[self.profileImage addGestureRecognizer:tabRecognizer];
CALayer * l = [self.profileImage layer];
[l setMasksToBounds:YES];
[l setCornerRadius:5.0];
[self.profileImage.layer setBorderColor: [[UIColor whiteColor] CGColor]];
[self.profileImage.layer setBorderWidth: 2.0];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)OnMyHomeLink:(id)sender {
if ([self.delegate respondsToSelector:@selector(loadHome)]) {
[self.delegate loadHome];
}
}
- (IBAction)OnSignOutLink:(id)sender {
Client *client = [Client instance];
[client logout];
}
- (IBAction)OnMentionsLink:(id)sender {
if ([self.delegate respondsToSelector:@selector(loadMentions)]) {
[self.delegate loadMentions];
}
}
- (void)handleTap:(UITapGestureRecognizer *)recognizer {
if ([self.delegate respondsToSelector:@selector(loadProfile)]) {
[self.delegate loadProfile];
}
}
@end