commit 8a70240968c67092a3c7870535ca5e19d3fce924
parent a4855775efcf275b931190f85dc999ad400bb2d3
Author: Jack Chakany <jack@chaker.net>
Date: Sun, 5 Mar 2023 14:24:32 -0500
Dedupe timelineNavItem
Changelog-Fixed: Fix issue where navbar back button would show the wrong text
Closes: #687
Diffstat:
1 file changed, 29 insertions(+), 37 deletions(-)
diff --git a/damus/ContentView.swift b/damus/ContentView.swift
@@ -148,26 +148,22 @@ struct ContentView: View {
isSideBarOpened = false
}
- var timelineNavItem: some View {
- VStack {
- switch selected_timeline {
- case .home:
- Image("damus-home")
- .resizable()
- .frame(width:30,height:30)
- .shadow(color: Color("DamusPurple"), radius: 2)
- case .dms:
- Text("DMs", comment: "Toolbar label for DMs view, where DM is the English abbreviation for Direct Message.")
- .bold()
- case .notifications:
- Text("Notifications", comment: "Toolbar label for Notifications view.")
- .bold()
- case .search:
- Text("Universe 🛸", comment: "Toolbar label for the universal view where posts from all connected relay servers appear.")
- .bold()
- case .none:
- Text(verbatim: "")
- }
+ var timelineNavItem: Text {
+ switch selected_timeline {
+ case .home:
+ return Text("Home", comment: "Navigation bar title for Home view where posts and replies appear from those who the user is following.")
+ .bold()
+ case .dms:
+ return Text("DMs", comment: "Toolbar label for DMs view, where DM is the English abbreviation for Direct Message.")
+ .bold()
+ case .notifications:
+ return Text("Notifications", comment: "Toolbar label for Notifications view.")
+ .bold()
+ case .search:
+ return Text("Universe 🛸", comment: "Toolbar label for the universal view where posts from all connected relay servers appear.")
+ .bold()
+ case .none:
+ return Text(verbatim: "")
}
}
@@ -203,25 +199,21 @@ struct ContentView: View {
EmptyView()
}
}
- .navigationBarTitle({
- switch selected_timeline {
- case .home:
- return NSLocalizedString("Home", comment: "Navigation bar title for Home view where posts and replies appear from those who the user is following.")
- case .dms:
- return NSLocalizedString("DMs", comment: "Navigation bar title for DMs view, where DM is the English abbreviation for Direct Message.")
- case .notifications:
- return NSLocalizedString("Notifications", comment: "Navigation bar title for Notifications view.")
- case .search:
- return NSLocalizedString("Universe 🛸", comment: "Navigation bar title for the universal view where posts from all connected relay servers appear.")
- case .none:
- return NSLocalizedString("", comment: "Toolbar label for unknown views. This label would be displayed only if a new timeline view is added but a toolbar label was not explicitly assigned to it yet.")
- }
- }(), displayMode: .inline)
+ .navigationBarTitle(timelineNavItem, displayMode: .inline)
.toolbar {
ToolbarItem(placement: .principal) {
- timelineNavItem
- .opacity(isSideBarOpened ? 0 : 1)
- .animation(isSideBarOpened ? .none : .default, value: isSideBarOpened)
+ VStack {
+ if selected_timeline == .home {
+ Image("damus-home")
+ .resizable()
+ .frame(width:30,height:30)
+ .shadow(color: Color("DamusPurple"), radius: 2)
+ } else {
+ timelineNavItem
+ .opacity(isSideBarOpened ? 0 : 1)
+ .animation(isSideBarOpened ? .none : .default, value: isSideBarOpened)
+ }
+ }
}
}
.ignoresSafeArea(.keyboard)