Sidebar Fixes

Closes: #587
This commit is contained in:
Ben Weeks
2023-02-13 10:10:54 +00:00
committed by William Casarin
parent e9ea96ffb6
commit 6653798d27
2 changed files with 51 additions and 41 deletions

View File

@@ -260,62 +260,67 @@ struct ContentView: View {
} }
var body: some View { var body: some View {
VStack(alignment: .leading, spacing: 0) { ZStack() {
if let damus = self.damus_state { if let damus = self.damus_state {
NavigationView { NavigationView {
ZStack { VStack(alignment: .leading, spacing: 0) {
TabView { // Prevents navbar appearance change on scroll ZStack {
MainContent(damus: damus) TabView { // Prevents navbar appearance change on scroll
.toolbar() { MainContent(damus: damus)
ToolbarItem(placement: .navigationBarLeading) { .toolbar() {
Button { ToolbarItem(placement: .navigationBarLeading) {
isSideBarOpened.toggle() Button {
} label: { isSideBarOpened.toggle()
ProfilePicView(pubkey: damus_state!.pubkey, size: 32, highlight: .none, profiles: damus_state!.profiles) } label: {
.opacity(isSideBarOpened ? 0 : 1) ProfilePicView(pubkey: damus_state!.pubkey, size: 32, highlight: .none, profiles: damus_state!.profiles)
.animation(isSideBarOpened ? .none : .default, value: isSideBarOpened) .opacity(isSideBarOpened ? 0 : 1)
} .animation(isSideBarOpened ? .none : .default, value: isSideBarOpened)
.disabled(isSideBarOpened)
}
ToolbarItem(placement: .navigationBarTrailing) {
HStack(alignment: .center) {
if home.signal.signal != home.signal.max_signal {
NavigationLink(destination: RelayConfigView(state: damus_state!)) {
Text("\(home.signal.signal)/\(home.signal.max_signal)", comment: "Fraction of how many of the user's relay servers that are operational.")
.font(.callout)
.foregroundColor(.gray)
}
} }
.disabled(isSideBarOpened)
// maybe expand this to other timelines in the future }
if selected_timeline == .search {
Button(action: { ToolbarItem(placement: .navigationBarTrailing) {
//isFilterVisible.toggle() HStack(alignment: .center) {
self.active_sheet = .filter if home.signal.signal != home.signal.max_signal {
}) { NavigationLink(destination: RelayConfigView(state: damus_state!)) {
// checklist, checklist.checked, lisdt.bullet, list.bullet.circle, line.3.horizontal.decrease..., line.3.horizontail.decrease Text("\(home.signal.signal)/\(home.signal.max_signal)", comment: "Fraction of how many of the user's relay servers that are operational.")
Label("Filter", systemImage: "line.3.horizontal.decrease") .font(.callout)
.foregroundColor(.gray) .foregroundColor(.gray)
}
}
// maybe expand this to other timelines in the future
if selected_timeline == .search {
Button(action: {
//isFilterVisible.toggle()
self.active_sheet = .filter
}) {
// checklist, checklist.checked, lisdt.bullet, list.bullet.circle, line.3.horizontal.decrease..., line.3.horizontail.decrease
Label("Filter", systemImage: "line.3.horizontal.decrease")
.foregroundColor(.gray)
//.contentShape(Rectangle()) //.contentShape(Rectangle())
}
} }
} }
} }
} }
} }
.tabViewStyle(.page(indexDisplayMode: .never))
} }
.tabViewStyle(.page(indexDisplayMode: .never))
TabBar(new_events: $home.new_events, selected: $selected_timeline, isSidebarVisible: $isSideBarOpened, action: switch_timeline)
.padding([.bottom], 8)
} }
.overlay( .overlay(
SideMenuView(damus_state: damus, isSidebarVisible: $isSideBarOpened.animation()) SideMenuView(damus_state: damus, isSidebarVisible: $isSideBarOpened.animation())
) )
.navigationBarTitleDisplayMode(.inline)
} }
.navigationViewStyle(.stack) .navigationViewStyle(.stack)
TabBar(new_events: $home.new_events, selected: $selected_timeline, isSidebarVisible: $isSideBarOpened, action: switch_timeline)
.padding([.bottom], 8)
} }
} }
.onAppear() { .onAppear() {
self.connect() self.connect()
setup_notifications() setup_notifications()

View File

@@ -166,8 +166,13 @@ struct SideMenuView: View {
@ViewBuilder @ViewBuilder
func navLabel(title: String, systemImage: String) -> some View { func navLabel(title: String, systemImage: String) -> some View {
Label(title, systemImage: systemImage) Label {
.font(.title2) Text(title)
.font(.title2)
} icon: {
Image(systemName: systemImage)
.frame(width:20)
}
.foregroundColor(textColor()) .foregroundColor(textColor())
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
} }