Skip to content

Commit 57c000a

Browse files
committed
Fixed memory managment in table header.
1 parent 490b0d9 commit 57c000a

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

Sources/NativeUIKit/Controllers/Complex/Profile/NativeProfileHeaderView.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ open class NativeProfileHeaderView: SPView {
3838
$0.textColor = .label
3939
$0.numberOfLines = 1
4040
$0.textAlignment = .center
41-
$0.adjustsFontSizeToFitWidth = true
42-
$0.minimumScaleFactor = 0.5
41+
// $0.adjustsFontSizeToFitWidth = true
42+
// $0.minimumScaleFactor = 0.5
4343
$0.text = nil
4444
}
4545

@@ -48,17 +48,16 @@ open class NativeProfileHeaderView: SPView {
4848
$0.textColor = .secondaryLabel
4949
$0.numberOfLines = 1
5050
$0.textAlignment = .center
51-
$0.adjustsFontSizeToFitWidth = true
52-
$0.minimumScaleFactor = 0.5
51+
// $0.adjustsFontSizeToFitWidth = true
52+
// $0.minimumScaleFactor = 0.5
5353
$0.text = nil
5454
}
5555

5656
// Add tap to clipboard
5757
public let emailButton = SPDimmedButton().do {
5858
$0.titleLabel?.font = UIFont.preferredFont(forTextStyle: .body, weight: .regular, addPoints: -2)
59-
$0.titleLabel?.adjustsFontSizeToFitWidth = true
60-
$0.titleLabel?.minimumScaleFactor = 0.5
61-
$0.setTitle(.space)
59+
// $0.titleLabel?.adjustsFontSizeToFitWidth = true
60+
// $0.titleLabel?.minimumScaleFactor = 0.5
6261
$0.titleImageInset = 2
6362
}
6463

@@ -103,7 +102,7 @@ open class NativeProfileHeaderView: SPView {
103102
// MARK: - Layout
104103

105104
private var usingNameLabel: SPLabel {
106-
if nameLabel.text == nil {
105+
if nameLabel.text?.isEmptyContent ?? true {
107106
return namePlaceholderLabel
108107
} else {
109108
return nameLabel

Sources/NativeUIKit/Controllers/Table/Header/NativeHeaderTableController.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,20 @@ open class NativeHeaderTableController: SPDiffableTableController {
3636
public init(style: UITableView.Style, headerView: UIView) {
3737
self.headerContainerView = HeaderContainerView(contentView: headerView)
3838
super.init(style: style)
39-
headerContainerView.setWidthAndFit(width: view.frame.width)
40-
tableView.tableHeaderView = headerContainerView
41-
4239
}
4340

4441
public required init?(coder: NSCoder) {
4542
fatalError("init(coder:) has not been implemented")
4643
}
4744

45+
// MARK: - Lifecycle
46+
47+
open override func viewDidLoad() {
48+
super.viewDidLoad()
49+
headerContainerView.setWidthAndFit(width: view.frame.width)
50+
tableView.tableHeaderView = headerContainerView
51+
}
52+
4853
// MARK: - Layout
4954

5055
open override func viewDidLayoutSubviews() {

Sources/NativeUIKit/Views/NativeAvatarView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ open class NativeAvatarView: SPView {
8888
}
8989

9090
open var placeholderImage = UIImage.system("person.crop.circle.fill", font: .systemFont(ofSize: 80, weight: .medium))
91-
open var placeholderColorise = SPDimmedButton.Colorise.init(content: .init(light: .systemGray4, dark: .systemGray2), background: .clear)
91+
open var placeholderColorise = SPDimmedButton.Colorise.init(content: .init(light: .systemGray3, dark: .systemGray2), background: .clear)
9292
open var indicatorAddImage = UIImage.system("plus", font: .preferredFont(forTextStyle: .title3, weight: .bold))
9393
open var indicatorAddColorise = SPDimmedButton.Colorise.init(content: .white, background: .systemGreen)
9494
open var indicatorEditImage = UIImage.system("pencil", font: .preferredFont(forTextStyle: .title3, weight: .bold))

0 commit comments

Comments
 (0)