blob: c39c6cd2d721ee13a16b34fe6a77b0a965136997 (
plain) (
blame)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
//
// RevealPanelViewController.m
// Juick
//
// Created by Vitaly Takmazov on 04.11.13.
// Copyright (c) 2013 com.juick. All rights reserved.
//
#import "SWRevealViewController.h"
#import "RevealPanelViewController.h"
#import "MessagesViewController.h"
#import "ColorScheme.h"
#import "NSURL+PathParameters.h"
#import "NavCell.h"
#import "Message.h"
static NSString *CellIdentifier = @"NavCell";
@interface RevealPanelViewController ()
@end
@implementation RevealPanelViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Juick";
if (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_6_1) {
self.navigationController.navigationBar.tintColor = [ColorScheme navbarBackground];
}
[self.view setBackgroundColor:[ColorScheme navbarBackground]];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.separatorColor =[UIColor blackColor];
[self.tableView registerClass:[NavCell class] forCellReuseIdentifier:CellIdentifier];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 4;
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NavCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSInteger row = indexPath.row;
[cell.contentView setBackgroundColor:[ColorScheme navbarBackground]];
cell.iconLabel.font = [UIFont fontWithName:kFontAwesomeFamilyName size:32.f];
cell.iconLabel.textColor = [ColorScheme navbarFont];
cell.iconLabel.backgroundColor = [ColorScheme navbarBackground];
cell.descriptionTextLabel.backgroundColor = [ColorScheme navbarBackground];
cell.descriptionTextLabel.textColor = [ColorScheme navbarFont];
if (row == 0) {
cell.descriptionTextLabel.text = @"My feed";
cell.iconLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconHome];
} else if (row == 1) {
cell.descriptionTextLabel.text = @"Popular";
cell.iconLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconComments];
} else if (row == 2) {
cell.descriptionTextLabel.text = @"Discover";
cell.iconLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconSearch];
} else if (row == 3) {
cell.descriptionTextLabel.text = @"Images";
cell.iconLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconPicture];
}
[cell setNeedsUpdateConstraints];
[cell updateConstraintsIfNeeded];
[cell.contentView setNeedsLayout];
[cell.contentView layoutIfNeeded];
return cell;
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger row = indexPath.row;
NSString *targetPath;
NSDictionary *targetParams;
NSString *targetTitle;
if (row == 0) {
if ([[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"] == nil) {
[self.revealViewController revealToggle:self];
UIViewController *loginView = [[LoginViewController alloc] initWithStyle:UITableViewStyleGrouped];
UINavigationController *messages = (UINavigationController *)self.revealViewController.frontViewController;
[messages pushViewController:loginView animated:YES];
return;
} else {
targetTitle = @"My feed";
targetPath = [Message feedUrl];
}
}
if (row == 1) {
targetTitle = @"Popular";
targetPath = [Message messagesUrl];
targetParams = [NSDictionary dictionaryWithObjectsAndKeys:@"1", @"popular", nil];
} else if (row == 2) {
targetTitle = @"Discover";
targetPath = [Message messagesUrl];
}
if (row == 3) {
targetTitle = @"Images";
targetPath = [Message messagesUrl];
targetParams = [NSDictionary dictionaryWithObjectsAndKeys:@"photo", @"media", nil];
}
SWRevealViewController *reveal = self.revealViewController;
UINavigationController *front = (UINavigationController *)reveal.frontViewController;
MessagesViewController *messages = (MessagesViewController *)[front.viewControllers objectAtIndex:0];
[messages loadFromPath:targetPath withParams:targetParams withTitle:targetTitle];
[reveal revealToggle:self];
}
@end
|