Nextrek
@ 588
Nextrek / iOS / SafariArte / trunk / SafariArte / Controllers / PoiVC / PoiVC.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 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
// // PoiVC.m // SafariArte // // Created by IntellitronikaUser on 02/07/15. // Copyright (c) 2015 Nextrek. All rights reserved. // #import "PoiVC.h" #import "RouteMapVC.h" #import "PoiPhotoZoomVC.h" #import "QuizVC.h" #import "SFAPoi.h" #import "FinalQuizVC.h" #import "UIImageView+AFNetworking.h" #import "RouteQuestionsVC.h" #import "CongratulationVC.h" #import "CCMPopup/CCMPopupTransitioning.h" #import "PoiListVC.h" @interface PoiVC () <UIAlertViewDelegate> { BOOL isMenuHidden; BOOL isHelpUsed; NSTimer *countTimer; int count; } @property (nonatomic, weak) IBOutlet UIImageView *poiImage; @property (nonatomic, weak) IBOutlet UILabel *poiDuration; @property (nonatomic, weak) IBOutlet UILabel *poiTitle; @property (nonatomic, weak) IBOutlet UITextView *poiDescription; @property (nonatomic, weak) IBOutlet UIButton *stepOverButton; @property (nonatomic, weak) IBOutlet UIButton *testQuizButton; @property (nonatomic, weak) IBOutlet UIView *menuview; @property (nonatomic, weak) IBOutlet UIView *radiusView; @property (nonatomic, weak) IBOutlet UIButton *quizButton; @property (nonatomic, strong) SFAPoi *poi; @property (nonatomic, weak) IBOutlet UIView *coordinateView; @property (nonatomic, weak) IBOutlet UILabel *coordinateLabel; @property (nonatomic, weak) IBOutlet UILabel *coordinateValue; @property (weak, nonatomic) IBOutlet UILabel *IndizioLabel; @property (weak, nonatomic) IBOutlet UILabel *indizioVal; @property (weak, nonatomic) IBOutlet UIView *indiziView; @property (weak, nonatomic) IBOutlet UIView *introView; @end @implementation PoiVC - (void)viewDidLoad { [super viewDidLoad]; isMenuHidden = YES; isHelpUsed = NO; self.menuview.alpha = 0.0f; self.radiusView.layer.cornerRadius = self.radiusView.frame.size.width / 2; self.title = self.routeForDetail.routeLabel; self.poiIndex= [DATAMANAGER poiForRoute:self.routeForDetail]; if([self.poiIndex intValue] > 0) { [self.navigationItem setHidesBackButton:YES]; } self.poi = [self.routeForDetail.routePois objectAtIndex:[self.poiIndex intValue]]; [self.poi setStatus:@"999"]; DATAMANAGER.secondsCount = [DATAMANAGER.user.timeForRoute objectForKey:self.routeForDetail.routeId]; if (!DATAMANAGER.secondsCount) { DATAMANAGER.secondsCount=[NSNumber numberWithInt:0]; } if(self.allRoutes) { [self.poiImage setImageWithURL:[NSURL URLWithString:self.poi.fileImg2]]; } else { NSURLRequest *imageRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:self.poi.fileImg2] cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30.0f]; [self.poiImage setImageWithURLRequest:imageRequest placeholderImage:nil success:nil failure:nil]; } self.poiTitle.text = self.poi.poiLabel; UIBarButtonItem *homeButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"Home_new"] style:UIBarButtonItemStyleDone target:self action:@selector(pushToHome)]; self.navigationItem.rightBarButtonItem = homeButton; self.poiDescription.text = self.poi.poiDescription; self.poiDescription.textAlignment = NSTextAlignmentJustified; [self.poiDescription scrollRangeToVisible:NSMakeRange(0, 1)]; [self.stepOverButton setTitle:NSLocalizedString(@"StepOver", nil) forState:UIControlStateNormal]; [self.testQuizButton setTitle:NSLocalizedString(@"TestQuestion", nil) forState:UIControlStateNormal]; self.coordinateLabel.text = [NSLocalizedString(@"Coordinate", nil) uppercaseString]; self.coordinateView.layer.borderWidth = 1; self.coordinateView.layer.cornerRadius = self.coordinateView.frame.size.width / 2; self.coordinateView.layer.borderColor = [[UIColor whiteColor] CGColor]; self.coordinateValue.text = self.poi.position; self.indiziView.layer.borderWidth = 1; self.indiziView.layer.cornerRadius = self.coordinateView.frame.size.width / 2; self.indiziView.layer.borderColor = [[UIColor whiteColor] CGColor]; self.IndizioLabel.text = [NSLocalizedString(@"Clue", nil) uppercaseString]; self.indizioVal.text = [[NSNumber numberWithInt:[self.poiIndex intValue] + 1] stringValue]; [self.indiziView reloadInputViews]; } - (void) viewWillAppear:(BOOL)animated{ self.title = @""; [super viewWillAppear:animated]; [self timerStop]; self.poiDuration.text =[NSString stringWithFormat:@"Durata %@",[DATAMANAGER getTime] ]; countTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timeRun) userInfo:nil repeats:YES]; } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [self timerStop]; [DATAMANAGER saveTimerForRouteID:self.routeForDetail]; self.title = @""; [self.poiImage setContentMode:UIViewContentModeScaleAspectFit]; } #pragma mark - Open Curiosity - (IBAction)doOpenCuriosity{ isHelpUsed = YES; [DATAMANAGER showAlert:self withTitle:NSLocalizedString(@"Curiosity", nil) message:self.poi.curiosity tag:02]; } #pragma mark - IBActions - (IBAction)doOpenHelp{ isHelpUsed = YES; [DATAMANAGER showAlert:self withTitle:NSLocalizedString(@"Help", nil) message:self.poi.helpDescription tag:03]; } #pragma mark - IBActions - (IBAction)doOpenPoiList{ PoiListVC * poiLisVC = [[PoiListVC alloc]init]; poiLisVC.poi = self.poi; poiLisVC.routeForDetail = self.routeForDetail; self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; [self.navigationController pushViewController:poiLisVC animated:NO]; } #pragma mark - IBActions - (IBAction)doOpenMap { RouteMapVC *routeMapVC = [[RouteMapVC alloc] init]; routeMapVC.allRoutes = self.allRoutes; routeMapVC.routeForDetail = self.routeForDetail; CCMPopupTransitioning *popup = [CCMPopupTransitioning sharedInstance]; popup.destinationBounds = CGRectMake(0, 0, self.view.bounds.size.width-50, self.view.bounds.size.height-150); popup.presentedController = routeMapVC; popup.presentingController = self; popup.dismissableByTouchingBackground=YES; [self presentViewController:routeMapVC animated:YES completion:nil]; } - (IBAction)doEnlargePhoto { PoiPhotoZoomVC *poiPhotoZoomVC = [[PoiPhotoZoomVC alloc] init]; poiPhotoZoomVC.allRoutes = self.allRoutes; poiPhotoZoomVC.poi = self.poi; CCMPopupTransitioning *popup = [CCMPopupTransitioning sharedInstance]; popup.destinationBounds = CGRectMake(0, 0, self.view.layer.bounds.size.width, self.view.layer.bounds.size.width +20); popup.presentedController = poiPhotoZoomVC; popup.presentingController = self; popup.dismissableByTouchingBackground=YES; [self presentViewController:poiPhotoZoomVC animated:YES completion:nil]; } - (IBAction)doOpenCloseMenu { isMenuHidden = !isMenuHidden; [UIView animateWithDuration:0.5f animations:^{ [self.menuview setAlpha: !isMenuHidden ? 1.0f : 0.0f]; }]; } - (IBAction)doStepOver { [DATAMANAGER showMessageWithAlert:self message:NSLocalizedString(@"StepOverClue", nil) tag:15]; } - (IBAction)doOpenQuiz { QuizVC *quizVC = [[QuizVC alloc] init]; quizVC.allRoutes = self.allRoutes; quizVC.routeForDetail = self.routeForDetail; quizVC.questionIndex = [NSNumber numberWithInt:0]; quizVC.poiIndex = self.poiIndex; quizVC.helpUsed = isHelpUsed; self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; [self.navigationController pushViewController:quizVC animated:YES]; } #pragma mark - Push to home - (void) pushToHome{ [DATAMANAGER saveTimerForRouteID:self.routeForDetail]; [self.navigationController popToRootViewControllerAnimated:TRUE]; } #pragma UIAlertview Delegate - (void)customIOS7dialogButtonTouchUpInside: (CustomIOSAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex { if (alertView.tag == 1 && buttonIndex == 0) { FinalQuizVC *finalQuizVC = [[FinalQuizVC alloc] init]; finalQuizVC.routeForDetail = self.routeForDetail; self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; [self.navigationController pushViewController:finalQuizVC animated:YES]; } else if (alertView.tag == 1 && buttonIndex == 1) { RouteQuestionsVC *routeQuestionsVC = [[RouteQuestionsVC alloc] init]; routeQuestionsVC.allRoutes = self.allRoutes; routeQuestionsVC.routeForDetail = self.routeForDetail; self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; [self.navigationController pushViewController:routeQuestionsVC animated:YES]; } else if (alertView.tag == 02 || alertView.tag == 03) { [alertView close]; } if (alertView.tag == 15 && buttonIndex == 0) { [self stepOverClue]; [alertView close]; } else if (alertView.tag == 15 && buttonIndex == 1){ [alertView close]; } } - (void)stepOverClue { PoiVC *poiVC = [[PoiVC alloc] init]; poiVC.allRoutes = self.allRoutes; poiVC.routeForDetail = self.routeForDetail; poiVC.poiIndex = [NSNumber numberWithInt:[self.poiIndex intValue] + 1]; CATransition* transition = [CATransition animation]; transition.duration = 0.5; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; transition.type = kCATransitionFromLeft ; //kCATransitionFade; //kCATransitionMoveIn, kCATransitionPush, kCATransitionFade //transition.subtype = kCATransitionFromBottom; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom [self.navigationController.view.layer addAnimation:transition forKey:nil]; [self timerStop]; [DATAMANAGER saveTimerForRouteID:self.routeForDetail]; [DATAMANAGER savePOIforRoute:self.routeForDetail poiIndex:poiVC.poiIndex]; [self.poi setStatus:@"2"]; [self.routeForDetail.routePois setObject:self.poi atIndexedSubscript:[self.poiIndex integerValue ] ]; [DATAMANAGER.user.percorsi setObject:self.routeForDetail forKey:self.routeForDetail.routeId]; [DATAMANAGER saveUser]; if (![poiVC.poiIndex isEqualToNumber:[NSNumber numberWithInteger:self.routeForDetail.routePois.count]]) { self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; [self.navigationController pushViewController:poiVC animated:NO]; } else { CongratulationVC *conVC = [[CongratulationVC alloc] init]; conVC.routeForDetail = self.routeForDetail; conVC.allRoutes = self.allRoutes; [self.navigationController pushViewController:conVC animated:NO]; } } - (void)timeRun{ [DATAMANAGER timeInc]; self.poiDuration.text = [NSString stringWithFormat:@"Durata %@", [DATAMANAGER getTime]]; } - (void)timerStop{ if(countTimer){ [countTimer invalidate]; countTimer=Nil; } } #pragma mark - MemoryWarning - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } @end |
Commits for Nextrek/iOS/SafariArte/trunk/SafariArte/Controllers/PoiVC/PoiVC.m
Revision | Author | Commited | Message |
---|---|---|---|
588 Diff | PBonamassa | Thu 27 Aug, 2015 13:39:33 +0000 | fixed bug |
573 Diff | FAquili | Wed 26 Aug, 2015 14:27:40 +0000 | AGGIUNTO PARSER PER AVERE ETICHETTE PERCORSI UGUALI SIA UN PERCORSI GRATUITI CHE IN I MIEI PERCORSI |
530 Diff | FAquili | Mon 24 Aug, 2015 10:51:56 +0000 | Bug fixing |
504 Diff | FPompili | Fri 14 Aug, 2015 10:23:44 +0000 | fixed |
503 Diff | PBonamassa | Fri 14 Aug, 2015 08:38:39 +0000 | fixed graphic poi list |
501 Diff | PBonamassa | Thu 13 Aug, 2015 09:53:14 +0000 | fixed zoom image poi |
494 Diff | PBonamassa | Tue 11 Aug, 2015 12:34:38 +0000 | |
488 Diff | PBonamassa | Mon 10 Aug, 2015 12:12:43 +0000 | added new images |
485 Diff | PBonamassa | Thu 06 Aug, 2015 15:12:03 +0000 | changed images menĂ¹ PoiVC, added localized string & fixed other problem |
484 | PBonamassa | Thu 06 Aug, 2015 11:26:33 +0000 | modified label to list routes |