

Nextrek
@ 797
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 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
// // 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" #import "TutorialViewController.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==2) { newFrontController = [[WebViewVC alloc] init]; newFrontController.title = itemsArray[indexMenu]; // DATAMANAGER.menuWebViewURL = [NSURL URLWithString:COSA_SAFARI([[NSUserDefaults standardUserDefaults] objectForKey:@"lang"])]; DATAMANAGER.menuWebViewURL = [NSURL URLWithString:COSA_SAFARI([DATAMANAGER defineLanguageWeb])]; NSLog(@"WEB URL: %@", DATAMANAGER.menuWebViewURL); } else if(indexMenu == 3) { } else if(indexMenu == 4) { newFrontController = [[TutorialViewController alloc] init]; newFrontController.title = itemsArray[indexMenu]; } else if(indexMenu == 5) { newFrontController = [[WebViewVC alloc] init]; newFrontController.title = itemsArray[indexMenu]; DATAMANAGER.menuWebViewURL = [NSURL URLWithString:FAQ_SAFARI([DATAMANAGER defineLanguageWeb])]; NSLog(@"WEB URL: %@", DATAMANAGER.menuWebViewURL); } else if (indexMenu==6) { newFrontController = [[SettingsVC alloc] init]; } else if (indexMenu==7) { newFrontController = [[WebViewVC alloc] init]; newFrontController.title = itemsArray[indexMenu]; DATAMANAGER.menuWebViewURL = [NSURL URLWithString:Partner_SAFARI([DATAMANAGER defineLanguageWeb])]; NSLog(@"WEB URL: %@", DATAMANAGER.menuWebViewURL); } else if (indexMenu==8) { newFrontController = [[WebViewVC alloc] init]; newFrontController.title = itemsArray[indexMenu]; DATAMANAGER.menuWebViewURL = [NSURL URLWithString:Credits_SAFARI([DATAMANAGER defineLanguageWeb])]; NSLog(@"WEB URL: %@", DATAMANAGER.menuWebViewURL); } else if (indexMenu==9) { newFrontController = [[LoginVC alloc] init]; } UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:newFrontController]; [APPDEL setupNavigationBar:navigationController]; [revealController pushFrontViewController:navigationController animated:YES]; } #pragma mark - Tutorial -(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]; } #pragma mark - Custom actions - (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 |
---|---|---|---|
797
![]() |
![]() |
Wed 07 Oct, 2015 08:42:31 +0000 | fixato tutorial da menu |
796
![]() |
![]() |
Wed 07 Oct, 2015 07:46:13 +0000 | v.1 b.035 |
770
![]() |
![]() |
Tue 22 Sep, 2015 14:53:34 +0000 | ios9 fixes |
726
![]() |
![]() |
Thu 10 Sep, 2015 14:43:14 +0000 | fixed bug |
684
![]() |
![]() |
Fri 04 Sep, 2015 14:47:40 +0000 | modified image final Quiz |
668
![]() |
![]() |
Fri 04 Sep, 2015 10:52:23 +0000 | fixed bug |
663
![]() |
![]() |
Fri 04 Sep, 2015 08:03:01 +0000 | |
654
![]() |
![]() |
Wed 02 Sep, 2015 13:26:46 +0000 | bugs fixing |
648
![]() |
![]() |
Wed 02 Sep, 2015 08:43:35 +0000 | |
631 |
![]() |
Tue 01 Sep, 2015 10:08:10 +0000 | Cosa รจ safari d’arte – menu item |