Commit 6397c5f6 authored by Mike JS. Choi's avatar Mike JS. Choi Committed by Carola Nitz

EmptyView: Adjust view for devices and theme

Adapt EmptyView to theme
Add adaptive layout to empty view
Collapse navigation bar for empty view
parent 252bed6c
This diff is collapsed.
......@@ -39,7 +39,6 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
let name = String(describing: VLCEmptyLibraryView.self)
let nib = Bundle.main.loadNibNamed(name, owner: self, options: nil)
guard let emptyView = nib?.first as? VLCEmptyLibraryView else { fatalError("Can't find nib for \(name)") }
emptyView.frame = view.bounds
return emptyView
}()
......@@ -63,7 +62,7 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
@objc func reloadData() {
collectionView?.reloadData()
displayEmptyViewIfNeeded()
updateUIForEmptyView()
}
@available(*, unavailable)
......@@ -126,20 +125,29 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
backgroundview.clipsToBounds = true
}
}
if #available(iOS 11.0, *) {
navigationItem.searchController = searchController
} else {
navigationItem.titleView = searchController?.searchBar
searchController?.hidesNavigationBarDuringPresentation = false
}
}
func setupNavigationBar() {
navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("SORT", comment: ""), style: .plain, target: self, action: #selector(sort))
}
func updateUIForEmptyView() {
let isEmpty = collectionView?.numberOfItems(inSection: 0) == 0
func displayEmptyViewIfNeeded() {
collectionView?.backgroundView = collectionView?.numberOfItems(inSection: 0) == 0 ? emptyView : nil
if isEmpty {
collectionView?.setContentOffset(.zero, animated: false)
collectionView?.backgroundView = emptyView
edgesForExtendedLayout = []
} else {
collectionView?.backgroundView = nil
edgesForExtendedLayout = .all
}
if #available(iOS 11.0, *) {
navigationItem.searchController = isEmpty ? nil :searchController
} else {
navigationItem.titleView = isEmpty ? nil : searchController?.searchBar
}
}
// MARK: Renderer
......
......@@ -16,7 +16,6 @@
@property (nonatomic, strong) IBOutlet UILabel *emptyLibraryLabel;
@property (nonatomic, strong) IBOutlet UILabel *emptyLibraryLongDescriptionLabel;
@property (nonatomic, strong) IBOutlet UIActivityIndicatorView *activityIndicator;
@property (nonatomic, strong) IBOutlet UIButton *learnMoreButton;
- (IBAction)learnMore:(id)sender;
......
......@@ -13,6 +13,7 @@
#import <Foundation/Foundation.h>
#import "VLCEmptyLibraryView.h"
#import "VLCFirstStepsViewController.h"
#import "VLC_iOS-Swift.h"
@implementation VLCEmptyLibraryView
......@@ -21,6 +22,12 @@
_emptyLibraryLabel.text = NSLocalizedString(@"EMPTY_LIBRARY", nil);
_emptyLibraryLongDescriptionLabel.text = NSLocalizedString(@"EMPTY_LIBRARY_LONG", nil);
[_learnMoreButton setTitle:NSLocalizedString(@"BUTTON_LEARN_MORE", nil) forState:UIControlStateNormal];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(themeDidChange)
name:kVLCThemeDidChangeNotification
object:nil];
[self themeDidChange];
[super awakeFromNib];
}
......@@ -32,4 +39,10 @@
[self.window.rootViewController presentViewController:navCon animated:YES completion:nil];
}
- (void)themeDidChange
{
_emptyLibraryLabel.textColor = PresentationTheme.current.colors.cellTextColor;
_emptyLibraryLongDescriptionLabel.textColor = PresentationTheme.current.colors.lightTextColor;
}
@end
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