Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Settings view (closes #268) #109

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 27 additions & 15 deletions Sources/VLCSectionTableHeaderView.swift
Expand Up @@ -15,6 +15,21 @@ import Foundation
class VLCSectionTableHeaderView: UITableViewHeaderFooterView {

let separator = UIView()

@objc let label: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = PresentationTheme.current.font.tableHeaderFont
return label
}()

let stackView: UIStackView = {
let stackView = UIStackView()
stackView.spacing = 8
stackView.axis = .vertical
stackView.translatesAutoresizingMaskIntoConstraints = false
return stackView
}()

override init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)
Expand All @@ -28,26 +43,23 @@ class VLCSectionTableHeaderView: UITableViewHeaderFooterView {
}

func setupUI() {
separator.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(separator)

stackView.addArrangedSubview(separator)
stackView.addArrangedSubview(label)
contentView.addSubview(stackView)

NSLayoutConstraint.activate([
separator.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
separator.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
separator.heightAnchor.constraint(equalToConstant: 1),
separator.topAnchor.constraint(equalTo: contentView.topAnchor)
])
stackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 15),
stackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -15),
stackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 15),
stackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -9),

separator.heightAnchor.constraint(equalToConstant: 1)
])
}

@objc func updateTheme() {
contentView.backgroundColor = PresentationTheme.current.colors.background
separator.backgroundColor = PresentationTheme.current.colors.separatorColor
textLabel?.textColor = PresentationTheme.current.colors.cellTextColor
}

override func layoutSubviews() {
super.layoutSubviews()
textLabel?.font = PresentationTheme.current.font.tableHeaderFont
textLabel?.textColor = PresentationTheme.current.colors.cellTextColor
label.textColor = PresentationTheme.current.colors.cellTextColor
}
}
13 changes: 4 additions & 9 deletions Sources/VLCSettingsController.m
Expand Up @@ -18,7 +18,6 @@
#import <LocalAuthentication/LocalAuthentication.h>
#import "VLC_iOS-Swift.h"

CGFloat const SETTINGS_HEADER_HEIGHT = 64.;
NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderViewIdentifier";

@interface VLCSettingsController ()<PAPasscodeViewControllerDelegate>
Expand Down Expand Up @@ -59,16 +58,17 @@ - (void)viewDidLoad
self.navigationItem.leftBarButtonItem.accessibilityIdentifier = VLCAccessibilityIdentifier.about;

self.neverShowPrivacySettings = YES;
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 100;
self.tableView.sectionHeaderHeight = UITableViewAutomaticDimension;
self.tableView.estimatedSectionHeaderHeight = 64;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.rowHeight = UITableViewAutomaticDimension;
[self.tableView registerClass:[VLCSectionTableHeaderView class] forHeaderFooterViewReuseIdentifier:kVLCSectionTableHeaderViewIdentifier];
[self themeDidChange];
}

- (void)themeDidChange
{

self.view.backgroundColor = PresentationTheme.current.colors.background;
[self setNeedsStatusBarAppearanceUpdate];
}
Expand Down Expand Up @@ -194,18 +194,13 @@ - (void)updateForPasscode:(NSString *)passcode

#pragma mark - InAppSettings customization

- (CGFloat)settingsViewController:(id<IASKViewController>)settingsViewController tableView:(UITableView *)tableView heightForHeaderForSection:(NSInteger)section
{
return section == 0. ? 0. : SETTINGS_HEADER_HEIGHT;
}

- (UIView *)settingsViewController:(id<IASKViewController>)settingsViewController tableView:(UITableView *)tableView viewForHeaderForSection:(NSInteger)section
{
if (section == 0) {
return nil;
}
VLCSectionTableHeaderView *header = [tableView dequeueReusableHeaderFooterViewWithIdentifier:kVLCSectionTableHeaderViewIdentifier];
header.textLabel.text = [self.settingsReader titleForSection:section];
header.label.text = [self.settingsReader titleForSection:section];
return header;
}

Expand Down
1 change: 1 addition & 0 deletions Sources/VLCSettingsTableViewCell.swift
Expand Up @@ -46,6 +46,7 @@ class VLCSettingsTableViewCell: UITableViewCell {

@objc func configure(specifier: IASKSpecifier, settingsValue: Any?) {
textLabel?.text = specifier.title()
textLabel?.numberOfLines = 0
detailTextLabel?.text = specifier.subtitle()

switch specifier.type() {
Expand Down