Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions LoopFollow/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
LogManager.shared.log(category: .general, message: "App started")
LogManager.shared.cleanupOldLogs()

configureTabBarAppearance()

let options: UNAuthorizationOptions = [.alert, .sound, .badge]
notificationCenter.requestAuthorization(options: options) {
didAllow, _ in
Expand Down Expand Up @@ -87,6 +89,31 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true
}

// MARK: - Tab bar appearance

/// Pin the tab bar item titles to a fixed, non-scaling font so large
/// Dynamic Type sizes don't wrap or truncate the labels.
private func configureTabBarAppearance() {
// 10pt medium matches the system default tab bar label.
let titleFont = UIFont.systemFont(ofSize: 10, weight: .medium)
let attributes: [NSAttributedString.Key: Any] = [.font: titleFont]

func apply(to itemAppearance: UITabBarItemAppearance) {
itemAppearance.normal.titleTextAttributes = attributes
itemAppearance.selected.titleTextAttributes = attributes
itemAppearance.disabled.titleTextAttributes = attributes
itemAppearance.focused.titleTextAttributes = attributes
}

let appearance = UITabBarAppearance()
apply(to: appearance.stackedLayoutAppearance)
apply(to: appearance.inlineLayoutAppearance)
apply(to: appearance.compactInlineLayoutAppearance)

UITabBar.appearance().standardAppearance = appearance
UITabBar.appearance().scrollEdgeAppearance = appearance
}

// MARK: - BFU recovery

@objc private func protectedDataDidBecomeAvailable() {
Expand Down
19 changes: 17 additions & 2 deletions LoopFollow/Application/MainTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct MainTabView: View {
ForEach(Array(orderedItems.prefix(4).enumerated()), id: \.element) { index, item in
tabContent(for: item)
.tabItem {
Label(item.displayName, systemImage: item.icon)
tabLabel(item.displayName, systemImage: item.icon)
}
.tag(index)
}
Expand All @@ -34,7 +34,7 @@ struct MainTabView: View {
MoreMenuView()
}
.tabItem {
Label("Menu", systemImage: "line.3.horizontal")
tabLabel("Menu", systemImage: "line.3.horizontal")
}
.tag(4)
}
Expand Down Expand Up @@ -62,6 +62,21 @@ struct MainTabView: View {
}
}

/// Tab bar label with a fixed-size icon so large Dynamic Type sizes don't
/// grow the symbol and squeeze the title. The title font is pinned in AppDelegate.
private func tabLabel(_ title: String, systemImage: String) -> some View {
Label {
Text(title)
} icon: {
let config = UIImage.SymbolConfiguration(pointSize: 24, weight: .regular)
if let image = UIImage(systemName: systemImage, withConfiguration: config) {
Image(uiImage: image.withRenderingMode(.alwaysTemplate))
} else {
Image(systemName: systemImage)
}
}
}

@ViewBuilder
private func tabContent(for item: TabItem) -> some View {
switch item {
Expand Down
Loading