Skip to content

Commit

Permalink
Add tooltip to sidebar buttons.
Browse files Browse the repository at this point in the history
  • Loading branch information
igorcamilo committed Apr 28, 2024
1 parent 6a7df10 commit c438567
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 17 deletions.
11 changes: 11 additions & 0 deletions IceCubesApp/App/SideBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand All @@ -132,6 +142,7 @@ struct SideBarView<Content: View>: View {
} label: {
makeIconForTab(tab: tab)
}
.help(tab.title)
}
}
}
Expand Down
40 changes: 23 additions & 17 deletions IceCubesApp/App/Tabs/Tabs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,41 +79,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()
""
}
}

Expand Down
10 changes: 10 additions & 0 deletions IceCubesApp/Resources/Localization/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -75175,6 +75175,16 @@
}
}
},
"tab.profile-account-%@" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Profile (%@)"
}
}
}
},
"tab.settings" : {
"localizations" : {
"be" : {
Expand Down

0 comments on commit c438567

Please sign in to comment.