Add tooltip to sidebar buttons. (#2040)

This commit is contained in:
Igor Camilo 2024-05-08 10:38:27 +02:00 committed by GitHub
parent ccad00a094
commit 1f56fa1b9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 152 additions and 17 deletions

View File

@ -75,6 +75,7 @@ struct SideBarView<Content: View>: View {
.offset(x: 2, y: -2) .offset(x: 2, y: -2)
} }
.buttonStyle(.borderedProminent) .buttonStyle(.borderedProminent)
.help(Tab.post.title)
} }
private func makeAccountButton(account: AppAccount, showBadge: Bool) -> some View { private func makeAccountButton(account: AppAccount, showBadge: Bool) -> some View {
@ -102,12 +103,21 @@ struct SideBarView<Content: View>: View {
} }
} }
} }
.help(accountButtonTitle(accountName: account.accountName))
.frame(width: .sidebarWidth, height: 50) .frame(width: .sidebarWidth, height: 50)
.padding(.vertical, 8) .padding(.vertical, 8)
.background(selectedTab == .profile && account.id == appAccounts.currentAccount.id ? .background(selectedTab == .profile && account.id == appAccounts.currentAccount.id ?
theme.secondaryBackgroundColor : .clear) theme.secondaryBackgroundColor : .clear)
} }
private func accountButtonTitle(accountName: String?) -> LocalizedStringKey {
if let accountName {
"tab.profile-account-\(accountName)"
} else {
Tab.profile.title
}
}
private var tabsView: some View { private var tabsView: some View {
ForEach(tabs) { tab in ForEach(tabs) { tab in
if tab != .profile && sidebarTabs.isEnabled(tab) { if tab != .profile && sidebarTabs.isEnabled(tab) {
@ -132,6 +142,7 @@ struct SideBarView<Content: View>: View {
} label: { } label: {
makeIconForTab(tab: tab) makeIconForTab(tab: tab)
} }
.help(tab.title)
} }
} }
} }

View File

@ -80,41 +80,47 @@ enum Tab: Int, Identifiable, Hashable, CaseIterable, Codable {
@ViewBuilder @ViewBuilder
var label: some View { var label: some View {
if self != .other {
Label(title, systemImage: iconName)
}
}
var title: LocalizedStringKey {
switch self { switch self {
case .timeline: case .timeline:
Label("tab.timeline", systemImage: iconName) "tab.timeline"
case .trending: case .trending:
Label("tab.trending", systemImage: iconName) "tab.trending"
case .local: case .local:
Label("tab.local", systemImage: iconName) "tab.local"
case .federated: case .federated:
Label("tab.federated", systemImage: iconName) "tab.federated"
case .notifications: case .notifications:
Label("tab.notifications", systemImage: iconName) "tab.notifications"
case .mentions: case .mentions:
Label("tab.mentions", systemImage: iconName) "tab.mentions"
case .explore: case .explore:
Label("tab.explore", systemImage: iconName) "tab.explore"
case .messages: case .messages:
Label("tab.messages", systemImage: iconName) "tab.messages"
case .settings: case .settings:
Label("tab.settings", systemImage: iconName) "tab.settings"
case .profile: case .profile:
Label("tab.profile", systemImage: iconName) "tab.profile"
case .bookmarks: case .bookmarks:
Label("accessibility.tabs.profile.picker.bookmarks", systemImage: iconName) "accessibility.tabs.profile.picker.bookmarks"
case .favorites: case .favorites:
Label("accessibility.tabs.profile.picker.favorites", systemImage: iconName) "accessibility.tabs.profile.picker.favorites"
case .post: case .post:
Label("menu.new-post", systemImage: iconName) "menu.new-post"
case .followedTags: case .followedTags:
Label("timeline.filter.tags", systemImage: iconName) "timeline.filter.tags"
case .lists: case .lists:
Label("timeline.filter.lists", systemImage: iconName) "timeline.filter.lists"
case .links: case .links:
Label("explore.section.trending.links", systemImage: iconName) "explore.section.trending.links"
case .other: case .other:
EmptyView() ""
} }
} }

View File

@ -75763,6 +75763,124 @@
} }
} }
}, },
"tab.profile-account-%@" : {
"localizations" : {
"be" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"ca" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"de" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Profile (%@)"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"es" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"eu" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"fr" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"it" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"ja" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"ko" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"nb" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"nl" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"pl" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"tr" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"uk" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Profile (%@)"
}
}
}
},
"tab.settings" : { "tab.settings" : {
"localizations" : { "localizations" : {
"be" : { "be" : {