Commit 6046d9e8 authored by Carola Nitz's avatar Carola Nitz

LocalNetworkView: Corrected size and scrolling behavior of the tableview

The heigt of the remotetableView gets now calculated dynamically and both views can now scroll when they get too big for the screen
parent b0f70796
......@@ -35,8 +35,6 @@ public class RemoteNetworkDataSource: NSObject, UITableViewDataSource, UITableVi
@objc weak var delegate: RemoteNetworkDataSourceDelegate?
@objc public let height = RemoteNetworkCellType.count * 55
// MARK: - DataSource
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return RemoteNetworkCellType.count
......
......@@ -50,7 +50,9 @@
UIActivityIndicatorView *_activityIndicator;
UITableView *_localNetworkTableView;
UITableView *_remoteNetworkTableView;
UIScrollView *_scrollView;
VLCRemoteNetworkDataSourceAndDelegate *_remoteNetworkDataSourceAndDelegate;
NSLayoutConstraint* _localNetworkHeight;
}
@end
......@@ -61,6 +63,17 @@
{
[super loadView];
_scrollView = [[UIScrollView alloc] init];
_scrollView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:_scrollView];
[NSLayoutConstraint activateConstraints:@[
[_scrollView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor],
[_scrollView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor],
[_scrollView.topAnchor constraintEqualToAnchor:self.topLayoutGuide.bottomAnchor],
[_scrollView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor],
]];
_remoteNetworkDataSourceAndDelegate = [VLCRemoteNetworkDataSourceAndDelegate new];
_remoteNetworkDataSourceAndDelegate.delegate = self;
......@@ -71,12 +84,9 @@
_localNetworkTableView.dataSource = self;
_localNetworkTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_localNetworkTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_localNetworkTableView.bounces = NO;
_localNetworkTableView.rowHeight = [VLCNetworkListCell heightOfCell];
_localNetworkTableView.separatorColor = PresentationTheme.current.colors.background;
//TODO: this is very much work in progress we need to accomodate the wificell for now
//When we know how many cells go above the the local servers we should create and move this into a headerview of the localNetworkTable
_remoteNetworkTableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
_remoteNetworkTableView.translatesAutoresizingMaskIntoConstraints = NO;
_remoteNetworkTableView.backgroundColor = PresentationTheme.current.colors.background;
......@@ -101,20 +111,25 @@
_activityIndicator.hidesWhenStopped = YES;
[_localNetworkTableView addSubview:_activityIndicator];
[self.view addSubview:_localNetworkTableView];
[self.view addSubview:_remoteNetworkTableView];
[_scrollView addSubview:_localNetworkTableView];
[_scrollView addSubview:_remoteNetworkTableView];
[_remoteNetworkTableView layoutIfNeeded];
CGSize contentSize = [_remoteNetworkTableView contentSize];
_localNetworkHeight = [_localNetworkTableView.heightAnchor constraintEqualToConstant:_localNetworkTableView.contentSize.height];
[NSLayoutConstraint activateConstraints:@[
[_remoteNetworkTableView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor],
[_remoteNetworkTableView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor],
[_remoteNetworkTableView.topAnchor constraintEqualToAnchor:self.topLayoutGuide.bottomAnchor],
//TODO: this should be rather be done dynamically with contenthugging of the tableview since the cellheights might vary
[_remoteNetworkTableView.heightAnchor constraintEqualToConstant:_remoteNetworkDataSourceAndDelegate.height],
[_remoteNetworkTableView.topAnchor constraintEqualToAnchor:_scrollView.topAnchor],
[_remoteNetworkTableView.heightAnchor constraintEqualToConstant:contentSize.height],
[_localNetworkTableView.topAnchor constraintEqualToAnchor:_remoteNetworkTableView.bottomAnchor],
[_localNetworkTableView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor],
[_localNetworkTableView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor],
[_localNetworkTableView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor],
[_localNetworkTableView.bottomAnchor constraintEqualToAnchor:_scrollView.bottomAnchor],
_localNetworkHeight
]];
self.view.backgroundColor = PresentationTheme.current.colors.background;
_scrollView.backgroundColor = PresentationTheme.current.colors.background;
}
- (void)viewDidLoad
......@@ -268,6 +283,8 @@
- (void)themeDidChange
{
_localNetworkTableView.backgroundColor = PresentationTheme.current.colors.background;
_remoteNetworkTableView.backgroundColor = PresentationTheme.current.colors.background;
_scrollView.backgroundColor = PresentationTheme.current.colors.background;
_localNetworkTableView.separatorColor = PresentationTheme.current.colors.background;
_refreshControl.backgroundColor = PresentationTheme.current.colors.background;
}
......@@ -282,7 +299,7 @@
#pragma mark - Refresh
-(void)handleRefresh
- (void)handleRefresh
{
//set the title while refreshing
_refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:NSLocalizedString(@"LOCAL_SERVER_REFRESH",nil)];
......@@ -328,6 +345,8 @@
- (void)discoveryFoundSomethingNew
{
[_localNetworkTableView reloadData];
[_localNetworkTableView layoutIfNeeded];
_localNetworkHeight.constant = _localNetworkTableView.contentSize.height;
}
#pragma mark - custom table view appearance
......
......@@ -56,7 +56,6 @@
self.textLabel.text = NSLocalizedString(@"WEBINTF_TITLE", nil);
self.detailTextLabel.text = NSLocalizedString(@"HTTP_UPLOAD_SERVER_OFF", nil);
self.detailTextLabel.translatesAutoresizingMaskIntoConstraints = NO;
self.detailTextLabel.numberOfLines = 0;
self.serverToggle = [[UISwitch alloc] init];
......
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