VLCOneDriveTableViewController.m 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*****************************************************************************
  2. * VLCOneDriveTableViewController.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2014 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "VLCOneDriveTableViewController.h"
  13. #import "VLCOneDriveController.h"
  14. #import "UIBarButtonItem+Theme.h"
  15. #import "VLCCloudStorageTableViewCell.h"
  16. #import "VLCAppDelegate.h"
  17. #import "VLCOneDriveController.h"
  18. @interface VLCOneDriveTableViewController () <UITableViewDataSource, UITableViewDelegate>
  19. {
  20. UIBarButtonItem *_backButton;
  21. UIBarButtonItem *_backToMenuButton;
  22. UIActivityIndicatorView *_activityIndicator;
  23. VLCOneDriveController *_oneDriveController;
  24. }
  25. @end
  26. @implementation VLCOneDriveTableViewController
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. _oneDriveController = [VLCOneDriveController sharedInstance];
  30. self.modalPresentationStyle = UIModalPresentationFormSheet;
  31. self.navigationItem.title = @"OneDrive";
  32. _backButton = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(goBack:)];
  33. _backToMenuButton = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(goBack:)];
  34. self.navigationItem.leftBarButtonItem = _backToMenuButton;
  35. self.tableView.rowHeight = [VLCCloudStorageTableViewCell heightOfCell];
  36. self.tableView.separatorColor = [UIColor VLCDarkBackgroundColor];
  37. self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
  38. self.cloudStorageLogo = nil;
  39. if (!SYSTEM_RUNS_IOS7_OR_LATER) {
  40. self.flatLoginButton.hidden = YES;
  41. [self.loginButton setTitle:NSLocalizedString(@"ONEDRIVE_LOGIN", nil) forState:UIControlStateNormal];
  42. } else {
  43. self.loginButton.hidden = YES;
  44. [self.flatLoginButton setTitle:NSLocalizedString(@"ONEDRIVE_LOGIN", nil) forState:UIControlStateNormal];
  45. }
  46. _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
  47. _activityIndicator.hidesWhenStopped = YES;
  48. _activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
  49. [self.view addSubview:_activityIndicator];
  50. [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_activityIndicator attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];
  51. [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_activityIndicator attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
  52. }
  53. - (void)viewWillAppear:(BOOL)animated
  54. {
  55. [super viewWillAppear:animated];
  56. // FIXME: we should update the listing...
  57. [self.cloudStorageLogo sizeToFit];
  58. self.cloudStorageLogo.center = self.view.center;
  59. }
  60. #pragma mark - generic interface interaction
  61. - (IBAction)goBack:(id)sender
  62. {
  63. [[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
  64. }
  65. #pragma mark - table view delegate
  66. - (void)tableView:(UITableView *)tableView
  67. willDisplayCell:(UITableViewCell *)cell
  68. forRowAtIndexPath:(NSIndexPath *)indexPath
  69. {
  70. cell.backgroundColor = (indexPath.row % 2 == 0)? [UIColor blackColor]: [UIColor VLCDarkBackgroundColor];
  71. }
  72. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  73. {
  74. }
  75. #pragma mark - login dialog
  76. - (void)_showLoginDialog
  77. {
  78. self.loginToCloudStorageView.frame = self.tableView.frame;
  79. [self.view addSubview:self.loginToCloudStorageView];
  80. }
  81. - (void)loginAction:(id)sender
  82. {
  83. [_oneDriveController login];
  84. }
  85. @end