Commit 731207a6 authored by Carola Nitz's avatar Carola Nitz

ServerListViewController: Moved the CloudViewController into the ServerListViewController

in order to do this a remoteNetworkCell needed to be created
parent a7b75353
......@@ -144,6 +144,8 @@
"CLOUD_SERVICES" = "Cloud Services";
"LOGIN" = "Login";
"LOGGED_IN" = "Logged in";
"LOGGED_IN_SERVICES" = "%d logged in services";
"LOGGED_IN_SERVICE" = "1 logged in service";
"DROPBOX_DOWNLOAD" = "Download file?";
"DROPBOX_DL_LONG" = "Would you like to download \"%@\" to your %@?";
......
......@@ -128,7 +128,7 @@ let brightPalette = ColorPalette(isDark: false,
background: UIColor(0xf9f9f7),
cellBackgroundA: UIColor(0xf9f9f7),
cellBackgroundB: UIColor(0xe5e5e3),
cellDetailTextColor: UIColor(0xd3d3d3),
cellDetailTextColor: UIColor(0xa9a9a9),
cellTextColor: UIColor(0x000000),
lightTextColor: UIColor(0x888888),
sectionHeaderTextColor: UIColor(0xf9f9f7),
......
/*****************************************************************************
* RemoteNetworkCell.swift
* VLC for iOS
*****************************************************************************
* Copyright (c) 2018 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Carola Nitz <nitz.carola # googlemail.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
import UIKit
class VLCRemoteNetworkCell: UITableViewCell {
@objc static var cellIdentifier = "RemoteNetworkCell"
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
commonInit()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
func commonInit() {
NotificationCenter.default.addObserver(self, selector: #selector(updateTheme), name: .VLCThemeDidChangeNotification, object: nil)
accessoryType = .disclosureIndicator
updateTheme()
}
@objc func updateTheme() {
backgroundColor = PresentationTheme.current.colors.background
textLabel?.textColor = PresentationTheme.current.colors.cellTextColor
detailTextLabel?.textColor = PresentationTheme.current.colors.cellDetailTextColor
}
}
......@@ -11,17 +11,73 @@
*****************************************************************************/
import Foundation
@objc(VLCRemoteNetworkDataSource)
public class RemoteNetworkDataSource: NSObject, UITableViewDataSource {
enum RemoteNetworkCellType: Int {
case cloud = 0, wifi
static let count: Int = 2
}
@objc(VLCRemoteNetworkDataSourceDelegate)
protocol RemoteNetworkDataSourceDelegate {
func showViewController(_ viewController: UIViewController)
}
@objc(VLCRemoteNetworkDataSourceAndDelegate)
public class RemoteNetworkDataSource: NSObject, UITableViewDataSource, UITableViewDelegate {
let cloudVC = VLCCloudServicesTableViewController(nibName: "VLCCloudServicesTableViewController", bundle: Bundle.main)
@objc weak var delegate: RemoteNetworkDataSourceDelegate?
@objc public let height = RemoteNetworkCellType.count * 55
// MARK: - DataSource
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
return RemoteNetworkCellType.count
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let wifiCell = tableView.dequeueReusableCell(withIdentifier: VLCWiFiUploadTableViewCell.cellIdentifier()) {
return wifiCell
guard let cellType = RemoteNetworkCellType(rawValue: indexPath.row) else {
assertionFailure("We're having more rows than types of cells that should never happen")
return UITableViewCell()
}
switch cellType {
case .cloud:
if let networkCell = tableView.dequeueReusableCell(withIdentifier: VLCRemoteNetworkCell.cellIdentifier) {
networkCell.textLabel?.text = cloudVC.title
networkCell.detailTextLabel?.text = cloudVC.detailText
networkCell.imageView?.image = cloudVC.cellImage
return networkCell
}
case .wifi:
if let wifiCell = tableView.dequeueReusableCell(withIdentifier: VLCWiFiUploadTableViewCell.cellIdentifier()) {
return wifiCell
}
}
assertionFailure("Cell is nil, did you forget to register the identifier?")
return UITableViewCell()
}
// MARK: - Delegate
public func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
return RemoteNetworkCellType(rawValue: indexPath.row) == .wifi ? nil : indexPath
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
if let vc = viewController(indexPath: indexPath) {
delegate?.showViewController(vc)
}
}
@objc func viewController(indexPath: IndexPath) -> UIViewController? {
guard let cellType = RemoteNetworkCellType(rawValue: indexPath.row) else {
assertionFailure("We're having more rows than types of cells that should never happen")
return nil
}
switch cellType {
case .cloud:
return cloudVC
case .wifi:
assertionFailure("We shouldn't get in here since we return nil in willSelect")
return nil
}
}
}
......@@ -42,7 +42,7 @@
#import "VLC_iOS-Swift.h"
@interface VLCServerListViewController () <UITableViewDataSource, UITableViewDelegate, VLCLocalServerDiscoveryControllerDelegate, VLCNetworkLoginViewControllerDelegate>
@interface VLCServerListViewController () <UITableViewDataSource, UITableViewDelegate, VLCLocalServerDiscoveryControllerDelegate, VLCNetworkLoginViewControllerDelegate, VLCRemoteNetworkDataSourceDelegate>
{
VLCLocalServerDiscoveryController *_discoveryController;
......@@ -50,7 +50,7 @@
UIActivityIndicatorView *_activityIndicator;
UITableView *_localNetworkTableView;
UITableView *_remoteNetworkTableView;
VLCRemoteNetworkDataSource *_remoteNetworkDatasource;
VLCRemoteNetworkDataSourceAndDelegate *_remoteNetworkDataSourceAndDelegate;
}
@end
......@@ -61,7 +61,8 @@
{
[super loadView];
_remoteNetworkDatasource = [VLCRemoteNetworkDataSource new];
_remoteNetworkDataSourceAndDelegate = [VLCRemoteNetworkDataSourceAndDelegate new];
_remoteNetworkDataSourceAndDelegate.delegate = self;
_localNetworkTableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
_localNetworkTableView.translatesAutoresizingMaskIntoConstraints = NO;
......@@ -79,12 +80,14 @@
_remoteNetworkTableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
_remoteNetworkTableView.translatesAutoresizingMaskIntoConstraints = NO;
_remoteNetworkTableView.backgroundColor = PresentationTheme.current.colors.background;
_remoteNetworkTableView.delegate = self;
_remoteNetworkTableView.dataSource = _remoteNetworkDatasource;
_remoteNetworkTableView.delegate = _remoteNetworkDataSourceAndDelegate;
_remoteNetworkTableView.dataSource = _remoteNetworkDataSourceAndDelegate;
_remoteNetworkTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_remoteNetworkTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_remoteNetworkTableView.bounces = NO;
[_remoteNetworkTableView registerClass:[VLCWiFiUploadTableViewCell class] forCellReuseIdentifier:[VLCWiFiUploadTableViewCell cellIdentifier]];
[_remoteNetworkTableView registerClass:[VLCRemoteNetworkCell class] forCellReuseIdentifier:VLCRemoteNetworkCell.cellIdentifier];
_refreshControl = [[UIRefreshControl alloc] init];
_refreshControl.backgroundColor = PresentationTheme.current.colors.background;
......@@ -104,7 +107,8 @@
[_remoteNetworkTableView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor],
[_remoteNetworkTableView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor],
[_remoteNetworkTableView.topAnchor constraintEqualToAnchor:self.topLayoutGuide.bottomAnchor],
[_remoteNetworkTableView.heightAnchor constraintEqualToConstant:50],
//TODO: this should be rather be done dynamically with contenthugging of the tableview since the cellheights might vary
[_remoteNetworkTableView.heightAnchor constraintEqualToConstant:_remoteNetworkDataSourceAndDelegate.height],
[_localNetworkTableView.topAnchor constraintEqualToAnchor:_remoteNetworkTableView.bottomAnchor],
[_localNetworkTableView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor],
[_localNetworkTableView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor],
......@@ -205,11 +209,6 @@
return cell;
}
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
return tableView == _remoteNetworkTableView ? nil : indexPath;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
......@@ -259,6 +258,12 @@
[self.navigationController pushViewController:loginViewController animated:YES];
}
}
- (void)showViewController:(UIViewController *)viewController
{
[self.navigationController pushViewController:viewController animated:YES];
}
#pragma mark -
- (void)themeDidChange
{
......
......@@ -14,4 +14,7 @@
@interface VLCCloudServicesTableViewController : UITableViewController
@property (nonatomic, readonly, copy) NSString *detailText;
@property (nonatomic, readonly) UIImage *cellImage;
@end
......@@ -51,6 +51,15 @@
self.documentPickerController = [VLCDocumentPickerController new];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"CLOUD_SERVICES", @"");
}
return self;
}
- (void)themeDidChange
{
self.tableView.separatorColor = PresentationTheme.current.colors.background;
......@@ -69,6 +78,30 @@
[self.tableView reloadData];
}
- (NSString *)detailText
{
int services = [self numberOfAuthorizedServices];
if (services == 1) {
return NSLocalizedString(@"LOGGED_IN_SERVICE", nil);
} else {
return [NSString stringWithFormat:NSLocalizedString(@"LOGGED_IN_SERVICES", ""), services];
}
}
- (int)numberOfAuthorizedServices
{
int i = [[VLCDropboxController sharedInstance] isAuthorized] ? 1 : 0;
i += [[VLCGoogleDriveController sharedInstance] isAuthorized] ? 1 : 0;
i += [[BoxSDK sharedSDK].OAuth2Session isAuthorized] ? 1 : 0;
i += [[VLCOneDriveController sharedInstance] isAuthorized] ? 1 : 0;
return i;
}
- (UIImage *)cellImage
{
return [UIImage imageNamed:@"iCloudIcon"];
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
......
......@@ -87,15 +87,6 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC
selectedImage: UIImage(named: "Local"))
serverVC.tabBarItem.accessibilityIdentifier = "Server"
//CloudServices
let cloudVC = VLCCloudServicesTableViewController(nibName: "VLCCloudServicesTableViewController", bundle: Bundle.main)
cloudVC.title = NSLocalizedString("CLOUD_SERVICES", comment: "")
cloudVC.tabBarItem = UITabBarItem(
title: NSLocalizedString("CLOUD_SERVICES", comment: ""),
image: UIImage(named: "iCloudIcon"),
selectedImage: UIImage(named: "iCloudIcon"))
cloudVC.tabBarItem.accessibilityIdentifier = "Cloud"
//Settings
let settingsVC = VLCSettingsController()
settingsVC.title = NSLocalizedString("Settings", comment: "")
......@@ -123,7 +114,7 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC
selectedImage: UIImage(named: "OpenNetStream"))
streamVC.tabBarItem.accessibilityIdentifier = "Stream"
let controllers = [audioVC, serverVC, videoVC, settingsVC, cloudVC, downloadVC, streamVC]
let controllers = [audioVC, serverVC, videoVC, settingsVC, downloadVC, streamVC]
tabBarController.viewControllers = controllers.map { UINavigationController(rootViewController: $0)}
}
......
......@@ -42,6 +42,7 @@
41B93C081A53853B00102E8B /* VLCCloudServiceCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 41B93C071A53853B00102E8B /* VLCCloudServiceCell.xib */; };
41CD695C1A29D72600E60BCE /* VLCBoxController.m in Sources */ = {isa = PBXBuildFile; fileRef = 41CD69591A29D72600E60BCE /* VLCBoxController.m */; };
41CD695D1A29D72600E60BCE /* VLCBoxTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 41CD695B1A29D72600E60BCE /* VLCBoxTableViewController.m */; };
41E6BECD207E64E900E158BA /* RemoteNetworkCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E6BECC207E64E900E158BA /* RemoteNetworkCell.swift */; };
41EB91D71F7BE6F500821AA5 /* VLCRemoteControlService.m in Sources */ = {isa = PBXBuildFile; fileRef = 417D7F5F1F7BA26200DDF36A /* VLCRemoteControlService.m */; };
41EB91DD1F7BFF8500821AA5 /* VLCMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 41EB91DC1F7BFF8400821AA5 /* VLCMetadata.m */; };
41EB91DE1F7BFF8500821AA5 /* VLCMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 41EB91DC1F7BFF8400821AA5 /* VLCMetadata.m */; };
......@@ -567,6 +568,7 @@
41CD69591A29D72600E60BCE /* VLCBoxController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCBoxController.m; path = Sources/VLCBoxController.m; sourceTree = SOURCE_ROOT; };
41CD695A1A29D72600E60BCE /* VLCBoxTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCBoxTableViewController.h; path = Sources/VLCBoxTableViewController.h; sourceTree = SOURCE_ROOT; };
41CD695B1A29D72600E60BCE /* VLCBoxTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCBoxTableViewController.m; path = Sources/VLCBoxTableViewController.m; sourceTree = SOURCE_ROOT; };
41E6BECC207E64E900E158BA /* RemoteNetworkCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteNetworkCell.swift; sourceTree = "<group>"; };
41EB91DB1F7BFF8400821AA5 /* VLCMetadata.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCMetadata.h; sourceTree = "<group>"; };
41EB91DC1F7BFF8400821AA5 /* VLCMetadata.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCMetadata.m; sourceTree = "<group>"; };
41F5C0761F41ED55005EB9CB /* VLCLibrarySearchDisplayDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VLCLibrarySearchDisplayDataSource.h; path = Sources/VLCLibrarySearchDisplayDataSource.h; sourceTree = SOURCE_ROOT; };
......@@ -1407,6 +1409,7 @@
DD3EFEEB1BDEBA3800B68579 /* VLCServerListViewController.h */,
DD3EFEEC1BDEBA3800B68579 /* VLCServerListViewController.m */,
4195747C206A92ED00393A42 /* RemoteNetworkDataSource.swift */,
41E6BECC207E64E900E158BA /* RemoteNetworkCell.swift */,
);
name = "Local Network Connectivity";
path = Sources/LocalNetworkConnectivity;
......@@ -3248,6 +3251,7 @@
41273A3C1A955C4100A2EF77 /* VLCMigrationViewController.m in Sources */,
7D30F3C4183AB24C00FFC021 /* VLCHTTPUploaderController.m in Sources */,
7D30F3C7183AB26F00FFC021 /* VLCOpenNetworkStreamViewController.m in Sources */,
41E6BECD207E64E900E158BA /* RemoteNetworkCell.swift in Sources */,
DD1CB05A1BBAC549006EDDE6 /* VLCVolumeView.m in Sources */,
7D5CAA8C1A4AD8E5003F2CBC /* VLCTrackSelectorHeaderView.m in Sources */,
4171D35018A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.m in Sources */,
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment