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)
}
.buttonStyle(.borderedProminent)
.help(Tab.post.title)
}
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)
.padding(.vertical, 8)
.background(selectedTab == .profile && account.id == appAccounts.currentAccount.id ?
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 {
ForEach(tabs) { tab in
if tab != .profile && sidebarTabs.isEnabled(tab) {
@ -132,6 +142,7 @@ struct SideBarView<Content: View>: View {
} label: {
makeIconForTab(tab: tab)
}
.help(tab.title)
}
}
}

View file

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