-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSidePanel.m
More file actions
199 lines (151 loc) · 7.06 KB
/
SidePanel.m
File metadata and controls
199 lines (151 loc) · 7.06 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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
//
// SidePanel.m
// CarServiceProject
//
// Created by NetSet on 3/30/15.
// Copyright (c) 2015 NetSet. All rights reserved.
//
#import "SidePanel.h"
#import "SWRevealViewController.h"
#import "HistoryViewController.h"
#import "MainHomeViewController.h"
#import "ServiceHomeViewController.h"
#import "ViewController.h"
#import "SettingViewController.h"
@interface SidePanel ()
@end
@implementation SidePanel
{
NSArray *menuItems;
NSArray *menuItems1;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
_imgView.layer.cornerRadius =_imgView.frame.size.width / 2;
_imgView.clipsToBounds=YES;
_imgView.layer.masksToBounds = YES;
//_tableISideView.allowsSelection=NO;
// _tableISideView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"side_bg.png"]];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)viewWillAppear:(BOOL)animated
{
if ([ [NSUserDefaults standardUserDefaults] boolForKey:@"consumerVIEW"] == YES) {
menuItems1 = nil;
menuItems=@[@"home",@"profile",@"history",@"newrequest",@"settings",@"logout"];
}
if ([ [NSUserDefaults standardUserDefaults] boolForKey:@"serviceVIEW"] == YES)
{
menuItems = nil;
menuItems1=@[@"home",@"profile",@"history",@"settings",@"logout"];
}
[_tableISideView reloadData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
if ([ [NSUserDefaults standardUserDefaults] boolForKey:@"consumerVIEW"] == YES) {
return [menuItems count];
}
if ([ [NSUserDefaults standardUserDefaults] boolForKey:@"serviceVIEW"] == YES)
{
return [menuItems1 count];
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell ;
if ([ [NSUserDefaults standardUserDefaults] boolForKey:@"consumerVIEW"] == YES) {
NSString * CellIdentifier = [menuItems objectAtIndex:indexPath.row];
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
}
if ([ [NSUserDefaults standardUserDefaults] boolForKey:@"serviceVIEW"] == YES)
{
if (!menuItems1.count<=indexPath.row) {
NSString * CellIdentifier1 = [menuItems1 objectAtIndex:indexPath.row];
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1 forIndexPath:indexPath];
}
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
if ([ [NSUserDefaults standardUserDefaults] boolForKey:@"consumerVIEW"] == YES)
{
if(indexPath.row == 0)
{
ViewController * consumerHomeView = [self.storyboard instantiateViewControllerWithIdentifier:@"viewHome"];
UINavigationController* navController = (UINavigationController*)self.revealViewController.frontViewController;
[navController setViewControllers: @[consumerHomeView] animated: NO ];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
}
if(indexPath.row == 2)
{
HistoryViewController * historyView = [self.storyboard instantiateViewControllerWithIdentifier:@"history_Vw"];
UINavigationController* navController = (UINavigationController*)self.revealViewController.frontViewController;
[navController setViewControllers: @[historyView] animated: NO ];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
}
if(indexPath.row == 4)
{
SettingViewController * settingView = [self.storyboard instantiateViewControllerWithIdentifier:@"setting_View"];
UINavigationController* navController = (UINavigationController*)self.revealViewController.frontViewController;
[navController setViewControllers: @[settingView] animated: NO ];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
}
if(indexPath.row ==5)
{
[[NSUserDefaults standardUserDefaults]setBool:NO forKey:@"consumerVIEW"];
[[NSUserDefaults standardUserDefaults]synchronize];
MainHomeViewController * mainHomeView = [self.storyboard instantiateViewControllerWithIdentifier:@"mainHomeVw"];
UINavigationController* navController = (UINavigationController*)self.revealViewController.frontViewController;
[navController setViewControllers: @[mainHomeView] animated: NO ];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
}
}
if ([ [NSUserDefaults standardUserDefaults] boolForKey:@"serviceVIEW"] == YES)
{
if(indexPath.row == 0)
{
ServiceHomeViewController * serviceHomeView = [self.storyboard instantiateViewControllerWithIdentifier:@"serviceView"];
UINavigationController* navController = (UINavigationController*)self.revealViewController.frontViewController;
[navController setViewControllers: @[serviceHomeView] animated: NO ];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
}
if(indexPath.row ==4)
{
[[NSUserDefaults standardUserDefaults]setBool:NO forKey:@"serviceVIEW"];
[[NSUserDefaults standardUserDefaults]synchronize];
MainHomeViewController * mainHomeView = [self.storyboard instantiateViewControllerWithIdentifier:@"mainHomeVw"];
UINavigationController* navController = (UINavigationController*)self.revealViewController.frontViewController;
[navController setViewControllers: @[mainHomeView] animated: NO ];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
}
}
}
- (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender
{ if ([ [NSUserDefaults standardUserDefaults] boolForKey:@"consumerVIEW"] == YES)
{
// Set the title of navigation bar by using the menu items
NSIndexPath *indexPath = [self.tableISideView indexPathForSelectedRow];
UINavigationController *destViewController = (UINavigationController*)segue.destinationViewController;
destViewController.title = [[menuItems objectAtIndex:indexPath.row] capitalizedString];
//if ([segue.identifier isEqualToString:@"history"])
//{
// HistoryViewController *historyController = (HistoryViewController*)segue.destinationViewController;
// }
}
}
@end