-
Notifications
You must be signed in to change notification settings - Fork 0
/
HomeEventsViewController.m
160 lines (119 loc) · 5.63 KB
/
HomeEventsViewController.m
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//
// HomeEventsViewController.m
// SeoulMate
//
// Created by Hassan Abid on 7/14/15.
//
//
#import "HomeEventsViewController.h"
#import "PAPSettingsButtonItem.h"
#import "PAPSettingsActionSheetDelegate.h"
#import "PAPSettingsButtonItem.h"
#import "PAPFindFriendsViewController.h"
#import "PAPAccountViewController.h"
#import "MBProgressHUD.h"
#import "AppDelegate.h"
#import "AddButtonItem.h"
#import "NewEventPostViewController.h"
#import "SettingsViewController.h"
@interface HomeEventsViewController () <UIActionSheetDelegate>
@property (nonatomic, strong) PAPSettingsActionSheetDelegate *settingsActionSheetDelegate;
@property (nonatomic, strong) UINavigationController *presentingAccountNavController;
@property (nonatomic, strong) UINavigationController *presentingFriendNavController;
@property (nonatomic, strong) UINavigationController *newEventPostNavController;
@property (nonatomic, strong) UINavigationController *presentingSettingsNavController;
@property (nonatomic, strong) UIView *blankTimelineView;
@end
@implementation HomeEventsViewController
@synthesize settingsActionSheetDelegate;
@synthesize blankTimelineView;
#pragma mark - UIViewController
- (UINavigationController *)presentingAccountNavController {
if (!_presentingAccountNavController) {
PAPAccountViewController *accountViewController = [[PAPAccountViewController alloc] initWithUser:[PFUser currentUser]];
_presentingAccountNavController = [[UINavigationController alloc] initWithRootViewController:accountViewController];
}
return _presentingAccountNavController;
}
- (UINavigationController *)presentingFriendNavController {
if (!_presentingFriendNavController) {
PAPFindFriendsViewController *findFriendsVC = [[PAPFindFriendsViewController alloc] init];
_presentingFriendNavController = [[UINavigationController alloc] initWithRootViewController:findFriendsVC];
}
return _presentingFriendNavController;
}
- (UINavigationController *)newEventPostNavController {
if (!_newEventPostNavController) {
NewEventPostViewController *newEventPostVC = [[NewEventPostViewController alloc] init];
_newEventPostNavController = [[UINavigationController alloc] initWithRootViewController:newEventPostVC];
}
return _newEventPostNavController;
}
- (UINavigationController *)presentingSettingsNavController {
if (!_presentingSettingsNavController) {
SettingsViewController *settingsViewController = [[SettingsViewController alloc] init];
_presentingSettingsNavController = [[UINavigationController alloc] initWithRootViewController:settingsViewController];
}
return _presentingSettingsNavController;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = [[PAPSettingsButtonItem alloc] initWithTarget:self action:@selector(settingsButtonAction:)];
self.navigationItem.title = @"Events & Festivals";
self.navigationItem.leftBarButtonItem = [[AddButtonItem alloc] initWithTarget:self action:@selector(addButtonAction:)];
self.blankTimelineView = [[UIView alloc] initWithFrame:self.tableView.bounds];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake( 33.0f, 96.0f, 253.0f, 173.0f);
[button setBackgroundImage:[UIImage imageNamed:@"HomeTimelineBlank.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(inviteFriendsButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[self.blankTimelineView addSubview:button];
}
#pragma mark - PFQueryTableViewController
- (void)objectsDidLoad:(NSError *)error {
[super objectsDidLoad:error];
if (self.objects.count == 0 && ![[self queryForTable] hasCachedResult]) {
self.tableView.scrollEnabled = NO;
if (!self.blankTimelineView.superview) {
self.blankTimelineView.alpha = 0.0f;
self.tableView.tableHeaderView = self.blankTimelineView;
[UIView animateWithDuration:0.200f animations:^{
self.blankTimelineView.alpha = 1.0f;
}];
}
} else {
self.tableView.tableHeaderView = nil;
self.tableView.scrollEnabled = YES;
}
}
#pragma mark - ()
- (void)settingsButtonAction:(id)sender {
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"My Profile",@"Settings",@"Log Out", nil];
[actionSheet showFromTabBar:self.tabBarController.tabBar];
}
- (void)inviteFriendsButtonAction:(id)sender {
PAPFindFriendsViewController *detailViewController = [[PAPFindFriendsViewController alloc] init];
[self.navigationController pushViewController:detailViewController animated:YES];
}
#pragma mark - UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (buttonIndex) {
case 0: {
[self presentViewController:self.presentingAccountNavController animated:YES completion:nil];
break;
}
case 1: {
[self presentViewController:self.presentingSettingsNavController animated:YES completion:nil];
break;
}
case 2: {
// Log out user and present the login view controller
[(AppDelegate *)[[UIApplication sharedApplication] delegate] logOut];
}
default:
break;
}
}
- (void)addButtonAction:(id)sender {
[self presentViewController:self.newEventPostNavController animated:YES completion:nil];
}
@end