@@ -11,6 +11,10 @@ import TinodiosDB
1111import UIKit
1212
1313class SettingsHelpViewController : UITableViewController {
14+ // 44px is the default UITableView row height.
15+ // TODO: may be 88px for retina display. Handle it.
16+ private static let kDefaultRowHeight : CGFloat = 44
17+
1418 @IBOutlet weak var contactUs : UITableViewCell !
1519 @IBOutlet weak var termsOfUse : UITableViewCell !
1620 @IBOutlet weak var privacyPolicy : UITableViewCell !
@@ -19,9 +23,12 @@ class SettingsHelpViewController: UITableViewController {
1923 @IBOutlet weak var serviceNameLabel : UILabel !
2024 @IBOutlet weak var serviceLinkLabel : UILabel !
2125 @IBOutlet weak var serverAddressLabel : UILabel !
26+ @IBOutlet weak var poweredByView : UIView !
2227
2328 private var tosUrl : URL !
2429 private var privacyUrl : URL !
30+ private var isUsingCustomBranding = false
31+ private var contentHeight : CGFloat = 0
2532
2633 override func viewDidLoad( ) {
2734 super. viewDidLoad ( )
@@ -52,8 +59,6 @@ class SettingsHelpViewController: UITableViewController {
5259 // Logo.
5360 if let logo = SharedUtils . largeIcon {
5461 logoView. image = logo
55- } else {
56- logoView. image = UIImage ( named: " logo-ios " )
5762 }
5863 // Service name.
5964 if let serviceName = SharedUtils . serviceName {
@@ -67,6 +72,39 @@ class SettingsHelpViewController: UITableViewController {
6772 // Server address.
6873 let ( host, tls) = Tinode . getConnectionParams ( )
6974 serverAddressLabel. text = ( tls ? " https:// " : " http:// " ) + host
75+
76+ // Precompute content height.
77+ // Table is confitured as static cells. Can use simple loop.
78+ self . contentHeight = 0
79+ for i in 0 ..< tableView. numberOfSections {
80+ let numRows = tableView. numberOfRows ( inSection: i)
81+ for j in 0 ..< numRows {
82+ let h = tableView ( self . tableView, heightForRowAt: IndexPath ( row: j, section: i) )
83+ self . contentHeight += h > 0 ? h : SettingsHelpViewController . kDefaultRowHeight
84+ }
85+ }
86+
87+ if SharedUtils . appId != nil {
88+ self . isUsingCustomBranding = true
89+ }
90+ self . poweredByView. isHidden = !isUsingCustomBranding
91+ }
92+
93+ override func viewDidLayoutSubviews( ) {
94+ super. viewDidLayoutSubviews ( )
95+
96+ if isUsingCustomBranding {
97+ // Adjust "Powered by" view position.
98+ let topPadding = self . tableView. safeAreaInsets. top
99+ let bottomPadding = self . tableView. safeAreaInsets. bottom
100+ // Total space available below table content and the bottom.
101+ let height = tableView. frame. height - topPadding - bottomPadding - self . contentHeight
102+ // height < 0 means "Powered By" isn't visible.
103+ let h = height > 0 ? height : SettingsHelpViewController . kDefaultRowHeight
104+ if h >= SettingsHelpViewController . kDefaultRowHeight && poweredByView. frame. size. height != h {
105+ poweredByView. frame. size. height = h
106+ }
107+ }
70108 }
71109
72110 @objc func termsOfUseClicked( sender: UITapGestureRecognizer ) {
0 commit comments