diff --git a/Sources/VLCSectionTableHeaderView.swift b/Sources/VLCSectionTableHeaderView.swift index 8a4bfc00e6..16890e8b43 100644 --- a/Sources/VLCSectionTableHeaderView.swift +++ b/Sources/VLCSectionTableHeaderView.swift @@ -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) @@ -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 } } diff --git a/Sources/VLCSettingsController.m b/Sources/VLCSettingsController.m index 91c6e883ff..44af6b5079 100644 --- a/Sources/VLCSettingsController.m +++ b/Sources/VLCSettingsController.m @@ -18,7 +18,6 @@ #import #import "VLC_iOS-Swift.h" -CGFloat const SETTINGS_HEADER_HEIGHT = 64.; NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderViewIdentifier"; @interface VLCSettingsController () @@ -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]; } @@ -194,18 +194,13 @@ - (void)updateForPasscode:(NSString *)passcode #pragma mark - InAppSettings customization -- (CGFloat)settingsViewController:(id)settingsViewController tableView:(UITableView *)tableView heightForHeaderForSection:(NSInteger)section -{ - return section == 0. ? 0. : SETTINGS_HEADER_HEIGHT; -} - - (UIView *)settingsViewController:(id)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; } diff --git a/Sources/VLCSettingsTableViewCell.swift b/Sources/VLCSettingsTableViewCell.swift index 19374d500b..00570bcd1c 100644 --- a/Sources/VLCSettingsTableViewCell.swift +++ b/Sources/VLCSettingsTableViewCell.swift @@ -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() {