Nextrek
@ 588
Nextrek / iOS / SafariArte / trunk / SafariArte / Controllers / MenuVC / MenuVC.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 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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
// // MenuVC.m // SafariArte // // Created by IntellitronikaUser on 12/06/15. // Copyright (c) 2015 Nextrek. All rights reserved. // #import "MenuVC.h" #import "LoginVC.h" #import "MenuItemCell.h" #import "WebViewVC.h" #import "HomeVC.h" #import "IAPVC.h" #import "SettingsVC.h" #import "GenericWebViewVC.h" #import "RFRateMe.h" @interface MenuVC ()<CustomIOSAlertViewDelegate> { NSMutableArray *itemsArray; NSArray *imagesForItemsArray; NSInteger _presentedRow; } @property (nonatomic, weak) IBOutlet UILabel *userMainLabel; @property (nonatomic, weak) IBOutlet UILabel *userSubLabel; @property (weak, nonatomic) IBOutlet UIImageView *userImage; @property (weak, nonatomic) IBOutlet UILabel *labelCredits; @end @implementation MenuVC - (void)viewDidLoad { [super viewDidLoad]; itemsArray = [NSMutableArray arrayWithObjects: NSLocalizedString(@"menu_iap", nil), NSLocalizedString(@"menu_home", nil), NSLocalizedString(@"menu_0", nil), NSLocalizedString(@"menu_1", nil), NSLocalizedString(@"menu_2", nil), NSLocalizedString(@"menu_3", nil), NSLocalizedString(@"menu_4", nil), NSLocalizedString(@"menu_5", nil), NSLocalizedString(@"menu_6", nil), NSLocalizedString(@"menu_7", nil), nil]; if ([DATAMANAGER.user.name isEqualToString:@"Anonimo"]){ itemsArray[9]= NSLocalizedString(@"SignIn",nil); } imagesForItemsArray = [NSArray arrayWithObjects: @"coin", @"home", @"info", @"classifica", @"istruzioni", @"faq", @"impostazioni", @"partnership", @"credits", @"logout", nil]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; if ([DATAMANAGER.user.name isEqualToString:@"Anonimo"]){ self.userMainLabel.text=DATAMANAGER.user.name; [self.userImage setImage:[UIImage imageNamed:@"male_user"]]; }else { if ([DATAMANAGER.user.sex isEqualToString:@"M"]){ self.userMainLabel.text=DATAMANAGER.user.name; [self.userImage setImage:[UIImage imageNamed:@"male_user"]]; }else{ self.userMainLabel.text=DATAMANAGER.user.name; [self.userImage setImage:[UIImage imageNamed:@"female_user"]]; } } self.userSubLabel.text=[self checkRouteStatus]; self.userMainLabel.text= DATAMANAGER.user.name; self.labelCredits.text=[NSString stringWithFormat:@"%i %@" ,[DATAMANAGER.user.credits intValue],NSLocalizedString(@"menu_6", nil) ]; } #pragma mark - Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [itemsArray count]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 44.0f; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"MenuItemCell"; MenuItemCell *cell = (MenuItemCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil]; cell = [topLevelObjects objectAtIndex:0]; } cell.imageValue.image = [UIImage imageNamed:[imagesForItemsArray objectAtIndex:indexPath.row]]; cell.itemValue.text = [itemsArray objectAtIndex:indexPath.row]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if(indexPath.row == 0) { [self openMenuItem:(int)indexPath.row]; } else if(indexPath.row == 1) { [self openMenuItem:(int)indexPath.row]; } else if(indexPath.row == 2) { [self openMenuItem:(int)indexPath.row]; } else if(indexPath.row == 3) { [RFRateMe showRateAlertAnyway]; } else if(indexPath.row == 4) { [self openMenuItem:(int)indexPath.row]; } else if(indexPath.row == 5) { [self openMenuItem:(int)indexPath.row]; } else if(indexPath.row == 6) { [self openMenuItem:(int)indexPath.row]; } else if(indexPath.row == 7) { [self openMenuItem:(int)indexPath.row]; } else if(indexPath.row == 8) { [self openMenuItem:(int)indexPath.row]; } //LOGOUT else if(indexPath.row == 9) { if ([DATAMANAGER.user.name isEqualToString:@"Anonimo"]) { DATAMANAGER.user = nil; [APPDEL initUser]; [self openMenuItem:(int)indexPath.row]; } else{ [DATAMANAGER showMessageWithAlert:self message:NSLocalizedString(@"Logout", nil) tag:001]; } } [tableView deselectRowAtIndexPath:indexPath animated:NO]; } - (void) openMenuItem:(int) indexMenu { SWRevealViewController *revealController = self.revealViewController; UIViewController *newFrontController = nil; if (indexMenu == 0) { newFrontController = [[IAPVC alloc] init]; } else if (indexMenu==1) { newFrontController = [[HomeVC alloc] init]; } else if(indexMenu == 3) { // newFrontController = [[WebViewVC alloc] init]; // newFrontController.title = itemsArray[indexMenu]; // NSString *urlToCall = [NSString stringWithFormat:@"http://www.gazzetta.it"]; // DATAMANAGER.menuWebViewURL =[NSURL URLWithString:urlToCall]; // RFRateMe.showRateAlert; } else if (indexMenu==6) { newFrontController = [[SettingsVC alloc] init]; } else if (indexMenu==9) { newFrontController = [[LoginVC alloc] init]; } else { newFrontController = [[WebViewVC alloc] init]; newFrontController.title = itemsArray[indexMenu]; DATAMANAGER.menuWebViewURL =[NSURL URLWithString:WEBVIEW_URL[indexMenu -1]]; } UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:newFrontController]; [APPDEL setupNavigationBar:navigationController]; [revealController pushFrontViewController:navigationController animated:YES]; } -(NSString *)checkRouteStatus{ NSArray *routeID=[DATAMANAGER.user.percorsi allKeys]; int started=0; int ended=0; for(int n=0 ;n < routeID.count;n++ ) { SFAPercorso *percorso=(SFAPercorso*)[DATAMANAGER.user.percorsi objectForKey:routeID[n]]; if (percorso.routePois ==nil) { } else if ([[DATAMANAGER poiForRoute:percorso] intValue] >0 && [[DATAMANAGER poiForRoute:percorso] intValue]<percorso.routePois.count && ([[DATAMANAGER.user.poiForRoute allKeys] containsObject:percorso.routeId])) { started++; } else if ( percorso.routePois.count==[[DATAMANAGER poiForRoute:percorso] intValue] || ([[DATAMANAGER.user.poiForRoute allKeys] containsObject:percorso.routeId])) { ended++; } } return [NSString stringWithFormat:NSLocalizedString(@"StartedEndedLabel", nil),started,ended]; } #pragma mark - MemoryWarning - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)customIOS7dialogButtonTouchUpInside: (CustomIOSAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex { if(buttonIndex == 0) { DATAMANAGER.user = nil; [APPDEL initUser]; [APPDEL initWithLogin]; } [alertView close]; } @end |
Commits for Nextrek/iOS/SafariArte/trunk/SafariArte/Controllers/MenuVC/MenuVC.m
Revision | Author | Commited | Message |
---|---|---|---|
588 Diff | PBonamassa | Thu 27 Aug, 2015 13:39:33 +0000 | fixed bug |
504 Diff | FPompili | Fri 14 Aug, 2015 10:23:44 +0000 | fixed |
453 Diff | PBonamassa | Thu 30 Jul, 2015 15:25:09 +0000 | added sound Frocix |
444 Diff | FPompili | Tue 28 Jul, 2015 14:26:36 +0000 | added customAlertView |
440 Diff | PBonamassa | Mon 27 Jul, 2015 10:33:32 +0000 | added CongratulationVC and fixed other bug |
438 Diff | FPompili | Fri 24 Jul, 2015 08:27:56 +0000 | added alertview for to vote |
409 Diff | PBonamassa | Tue 21 Jul, 2015 09:43:31 +0000 | fixed string |
408 Diff | PBonamassa | Tue 21 Jul, 2015 09:18:19 +0000 | fixed constraints, added label to menĂ¹, modified credits View Cell |
405 Diff | FPompili | Mon 20 Jul, 2015 15:39:34 +0000 | added credit info to menu |
404 | FPompili | Mon 20 Jul, 2015 15:30:34 +0000 | fixed introduced bug |