refactor sidemenu items

This commit is contained in:
William Casarin
2023-05-03 12:19:31 -07:00
parent b85be50cc4
commit ac2e7d108d

View File

@@ -42,14 +42,37 @@ struct SideMenuView: View {
} }
} }
var content: some View { func SidemenuItems(profile_model: ProfileModel, followers: FollowersModel) -> some View {
HStack(alignment: .top) { return VStack(spacing: verticalSpacing) {
ZStack(alignment: .top) { NavigationLink(destination: ProfileView(damus_state: damus_state, profile: profile_model, followers: followers)) {
fillColor() navLabel(title: NSLocalizedString("Profile", comment: "Sidebar menu label for Profile view."), systemImage: "person")
.ignoresSafeArea() }
VStack(alignment: .leading, spacing: 0) { /*
NavigationLink(destination: EmptyView()) {
navLabel(title: NSLocalizedString("Wallet", comment: "Sidebar menu label for Wallet view."), systemImage: "bolt")
}
*/
NavigationLink(destination: MutelistView(damus_state: damus_state, users: get_mutelist_users(damus_state.contacts.mutelist) )) {
navLabel(title: NSLocalizedString("Muted", comment: "Sidebar menu label for muted users view."), systemImage: "exclamationmark.octagon")
}
NavigationLink(destination: RelayConfigView(state: damus_state)) {
navLabel(title: NSLocalizedString("Relays", comment: "Sidebar menu label for Relays view."), systemImage: "network")
}
NavigationLink(destination: BookmarksView(state: damus_state)) {
navLabel(title: NSLocalizedString("Bookmarks", comment: "Sidebar menu label for Bookmarks view."), systemImage: "bookmark")
}
NavigationLink(destination: ConfigView(state: damus_state)) {
navLabel(title: NSLocalizedString("Settings", comment: "Sidebar menu label for accessing the app settings"), systemImage: "gear")
}
}
}
var MainSidemenu: some View {
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
let profile = damus_state.profiles.lookup(id: damus_state.pubkey) let profile = damus_state.profiles.lookup(id: damus_state.pubkey)
let followers = FollowersModel(damus_state: damus_state, target: damus_state.pubkey) let followers = FollowersModel(damus_state: damus_state, target: damus_state.pubkey)
@@ -81,37 +104,21 @@ struct SideMenuView: View {
Divider() Divider()
ScrollView { ScrollView {
VStack(spacing: verticalSpacing) { SidemenuItems(profile_model: profile_model, followers: followers)
NavigationLink(destination: ProfileView(damus_state: damus_state, profile: profile_model, followers: followers)) {
navLabel(title: NSLocalizedString("Profile", comment: "Sidebar menu label for Profile view."), systemImage: "person")
}
/*
NavigationLink(destination: EmptyView()) {
navLabel(title: NSLocalizedString("Wallet", comment: "Sidebar menu label for Wallet view."), systemImage: "bolt")
}
*/
NavigationLink(destination: MutelistView(damus_state: damus_state, users: get_mutelist_users(damus_state.contacts.mutelist) )) {
navLabel(title: NSLocalizedString("Muted", comment: "Sidebar menu label for muted users view."), systemImage: "exclamationmark.octagon")
}
NavigationLink(destination: RelayConfigView(state: damus_state)) {
navLabel(title: NSLocalizedString("Relays", comment: "Sidebar menu label for Relays view."), systemImage: "network")
}
NavigationLink(destination: BookmarksView(state: damus_state)) {
navLabel(title: NSLocalizedString("Bookmarks", comment: "Sidebar menu label for Bookmarks view."), systemImage: "bookmark")
}
NavigationLink(destination: ConfigView(state: damus_state)) {
navLabel(title: NSLocalizedString("Settings", comment: "Sidebar menu label for accessing the app settings"), systemImage: "gear")
}
}
.labelStyle(SideMenuLabelStyle()) .labelStyle(SideMenuLabelStyle())
.padding([.top, .bottom], verticalSpacing) .padding([.top, .bottom], verticalSpacing)
} }
} }
}
var content: some View {
HStack(alignment: .top) {
ZStack(alignment: .top) {
fillColor()
.ignoresSafeArea()
VStack(alignment: .leading, spacing: 0) {
MainSidemenu
.simultaneousGesture(TapGesture().onEnded { .simultaneousGesture(TapGesture().onEnded {
isSidebarVisible = false isSidebarVisible = false
}) })