Skip to content

Commit

Permalink
PR Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nodes11 committed Jun 21, 2024
1 parent b13bac1 commit ce077c4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ extension TableViewHeaderFooterViewDemoController {
if section.footerLinkText.isEmpty {
footer?.setup(style: .footer, title: section.footerText)
} else {
let title = NSMutableAttributedString(string: section.footerText)
let title = NSMutableAttributedString(string: section.footerText, attributes: [NSAttributedString.Key.foregroundColor: footer?.tokenSet[.textColor].uiColor ?? .white])
let range = (title.string as NSString).range(of: section.footerLinkText)
if range.location != -1 {
title.addAttribute(.link, value: "https://github.com/microsoft/fluentui-apple", range: range)
Expand Down
33 changes: 18 additions & 15 deletions ios/FluentUI/Table View/TableViewHeaderFooterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,17 +320,12 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont
accessoryButtonTitle: String = "",
accessoryView: UIView? = nil,
leadingView: UIView? = nil) {
attributedTitleFont = nil
attributedTitleColor = nil

if let attributedTitle = attributedTitle {
if let attributedTitle {
self.attributedTitle = attributedTitle
titleView.attributedText = attributedTitle
titleView.isSelectable = true

let attributes = attributedTitle.attributes(at: 0, effectiveRange: nil)
attributedTitleFont = attributes[NSAttributedString.Key.font] as? UIFont ?? tokenSet[.textFont].uiFont
attributedTitleColor = attributes[NSAttributedString.Key.foregroundColor] as? UIColor ?? tokenSet[.textColor].uiColor
} else {
self.attributedTitle = nil
titleView.attributedText = NSAttributedString(string: " ") // to clear attributes
titleView.text = title
titleView.isSelectable = false
Expand Down Expand Up @@ -458,8 +453,10 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont

private func updateTitleViewFont() {
if let window = window {
let titleFont = attributedTitleFont ?? tokenSet[.textFont].uiFont
titleView.font = titleFont
let titleFont = tokenSet[.textFont].uiFont
if !isUsingAttributedTitle {
titleView.font = titleFont
}

// offset text container to center its content
#if os(iOS)
Expand All @@ -474,8 +471,6 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont
}

private func updateTitleAndBackgroundColors() {
titleView.textColor = attributedTitleColor ?? tokenSet[.textColor].uiColor

if tableViewCellStyle == .grouped {
backgroundView?.backgroundColor = tokenSet[.backgroundColorGrouped].uiColor
} else if tableViewCellStyle == .plain {
Expand All @@ -484,7 +479,10 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont
backgroundView?.backgroundColor = .clear
}

titleView.font = attributedTitleFont ?? tokenSet[.textFont].uiFont
if !isUsingAttributedTitle {
titleView.textColor = tokenSet[.textColor].uiColor
titleView.font = tokenSet[.textFont].uiFont
}
titleView.linkColor = tokenSet[.linkTextColor].uiColor
}

Expand Down Expand Up @@ -524,8 +522,13 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont
onHeaderViewTapped?()
}

private var attributedTitleFont: UIFont?
private var attributedTitleColor: UIColor?
private var attributedTitle: NSAttributedString? {
didSet {
isUsingAttributedTitle = attributedTitle != nil
}
}

private var isUsingAttributedTitle: Bool = false
}

// MARK: - TableViewHeaderFooterView: UITextViewDelegate
Expand Down

0 comments on commit ce077c4

Please sign in to comment.