Skip to content

Commit

Permalink
#1066 support for iOS 15 SDK: Solving UI issues, removing unneeded code
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Hühne committed May 2, 2022
1 parent 867c787 commit e7e34b8
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 45 deletions.
Expand Up @@ -49,7 +49,7 @@ open class BreadCrumbTableViewController: StaticTableViewController {
var rows : [StaticTableViewRow] = []
let pathCount = pathComp.count
var currentViewContollerIndex = 2
let contentHeight : CGFloat = rowHeight * CGFloat(pathCount)
let contentHeight : CGFloat = rowHeight * CGFloat(pathCount) + 10
let contentWidth : CGFloat = (view.frame.size.width < maxContentWidth) ? view.frame.size.width : maxContentWidth
self.preferredContentSize = CGSize(width: contentWidth, height: contentHeight)

Expand Down
Expand Up @@ -35,9 +35,9 @@ class SortMethodTableViewController: StaticTableViewController {
self.tableView.rowHeight = rowHeight

var rows : [StaticTableViewRow] = []
let contentHeight : CGFloat = rowHeight * CGFloat(SortMethod.all.count) - 1
let contentHeight : CGFloat = rowHeight * CGFloat(SortMethod.all.count) + 8
let contentWidth : CGFloat = maxContentWidth
self.preferredContentSize = CGSize(width: contentWidth, height: contentHeight)
self.preferredContentSize = CGSize(width: contentWidth, height: contentHeight)

for method in SortMethod.all {
let title = method.localizedName
Expand Down
Expand Up @@ -264,4 +264,24 @@ open class StaticTableViewController: UITableViewController, Themeable {
open func applyThemeCollection(theme: Theme, collection: ThemeCollection, event: ThemeEvent) {
self.tableView.applyThemeCollection(collection)
}

public override func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
guard let sectionColor = Theme.shared.activeCollection.tableSectionHeaderColor else { return }

if let label = view as? UILabel {
label.textColor = sectionColor
} else if let headerView = view as? UITableViewHeaderFooterView {
headerView.textLabel?.textColor = sectionColor
}
}

public override func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) {
guard let sectionColor = Theme.shared.activeCollection.tableSectionFooterColor else { return }

if let label = view as? UILabel {
label.textColor = sectionColor
} else if let headerView = view as? UITableViewHeaderFooterView {
headerView.textLabel?.textColor = sectionColor
}
}
}
Expand Up @@ -125,15 +125,30 @@ public extension NSObject {
}

if let toolbar = self as? UIToolbar {
toolbar.barTintColor = collection.toolbarColors.backgroundColor
toolbar.tintColor = collection.toolbarColors.tintColor

if #available(iOS 15, *) {
let appearance = UIToolbarAppearance()
appearance.backgroundColor = collection.toolbarColors.backgroundColor
UIToolbar.appearance().standardAppearance = appearance
UIToolbar.appearance().scrollEdgeAppearance = appearance
} else {
toolbar.barTintColor = collection.toolbarColors.backgroundColor
}
}

if let tabBar = self as? UITabBar {
tabBar.barTintColor = collection.toolbarColors.backgroundColor
tabBar.tintColor = collection.toolbarColors.tintColor
tabBar.unselectedItemTintColor = collection.toolbarColors.secondaryLabelColor
}
if let tabBar = self as? UITabBar {
tabBar.tintColor = collection.toolbarColors.tintColor
tabBar.unselectedItemTintColor = collection.toolbarColors.secondaryLabelColor
if #available(iOS 15, *) {
let appearance = UITabBarAppearance()
appearance.backgroundColor = collection.toolbarColors.backgroundColor
UITabBar.appearance().standardAppearance = appearance
UITabBar.appearance().scrollEdgeAppearance = appearance
} else {
tabBar.barTintColor = collection.toolbarColors.backgroundColor
}
}

if let tableView = self as? UITableView {
tableView.backgroundColor = tableView.style == .grouped ? collection.tableGroupBackgroundColor : collection.tableBackgroundColor
Expand Down Expand Up @@ -284,37 +299,3 @@ public extension NSObject {
}
}
}

extension UITableViewController : ThemeableSectionHeader, ThemeableSectionFooter {
public var sectionHeaderColor: UIColor? {
get {
return self.value(forAnnotatedProperty: "sectionHeaderColor") as? UIColor
}

set {
self.setValue(newValue, forAnnotatedProperty: "sectionHeaderColor")
}
}

public var sectionFooterColor: UIColor? {
get {
return self.value(forAnnotatedProperty: "sectionFooterColor") as? UIColor
}

set {
self.setValue(newValue, forAnnotatedProperty: "sectionFooterColor")
}
}

public func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
if let label = view as? UILabel, let sectionHeaderColor = sectionHeaderColor {
label.textColor = sectionHeaderColor
}
}

public func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) {
if let label = view as? UILabel, let sectionFooterColor = sectionFooterColor {
label.textColor = sectionFooterColor
}
}
}
7 changes: 5 additions & 2 deletions ownCloudAppShared/User Interface/Theme/ThemeCollection.swift
Expand Up @@ -238,7 +238,7 @@ public class ThemeCollection : NSObject {
let color = colors.resolveColor("Table.tableSeparatorColor", UIColor.lightGray)
self.tableSeparatorColor = color
}
self.tableSectionHeaderColor = UIColor.gray
self.tableSectionHeaderColor = UIColor.gray
self.tableSectionFooterColor = UIColor.gray

let rowColor : UIColor? = UIColor.black.withAlphaComponent(0.1)
Expand Down Expand Up @@ -374,7 +374,10 @@ public class ThemeCollection : NSObject {
// Bars
self.navigationBarColors = colors.resolveThemeColorCollection("NavigationBar", self.darkBrandColors)
let tmpDarkBrandColors = self.darkBrandColors
tmpDarkBrandColors.secondaryLabelColor = UIColor(hex: 0xF7F7F7)

if VendorServices.shared.isBranded {
tmpDarkBrandColors.secondaryLabelColor = UIColor(hex: 0xF7F7F7)
}
if self.tintColor == UIColor(hex: 0xFFFFFF) {
tmpDarkBrandColors.secondaryLabelColor = .lightGray
}
Expand Down

0 comments on commit e7e34b8

Please sign in to comment.