much better overall header and adding log out ability

This commit is contained in:
talksik
2021-12-14 17:58:44 -08:00
parent 798fbc9e06
commit 6cea5ff0d6
2 changed files with 43 additions and 35 deletions
@@ -8,15 +8,9 @@
import SwiftUI import SwiftUI
struct UserMenuView: View { struct UserMenuView: View {
@Environment(\.dismiss) var dismiss
var body: some View { var body: some View {
Button("Press to dismiss") { Text("different menu options")
dismiss()
}
.font(.title)
.padding()
.background(Color.black)
} }
} }
+19 -5
View File
@@ -13,6 +13,16 @@ struct HeaderView: View {
@State var showingMenu: Bool = false @State var showingMenu: Bool = false
var body: some View { var body: some View {
if authStore.sessionState == SessionState.isLoggedOut {
HStack {
Image("undraw_handcrafts_leaf")
.resizable()
.frame(width: 20.0, height: 32.132)
.padding()
Spacer()
}
} else {
HStack(alignment:.center) { HStack(alignment:.center) {
Image("undraw_handcrafts_leaf") Image("undraw_handcrafts_leaf")
.resizable() .resizable()
@@ -21,16 +31,21 @@ struct HeaderView: View {
Spacer() Spacer()
if self.authStore.sessionState == SessionState.isAuthenticated { Menu {
Button("Log out") {
print("log out button clicked")
self.authStore.logOut()
}
Button("Friends") {
print("manage friends page")
}
} label: {
RemoteImage(url: self.authStore.user?.profilePictureUrl?.absoluteString ?? "https://avatars.githubusercontent.com/u/41487836") RemoteImage(url: self.authStore.user?.profilePictureUrl?.absoluteString ?? "https://avatars.githubusercontent.com/u/41487836")
.background(NirvanaColor.teal) .background(NirvanaColor.teal)
.aspectRatio(contentMode: .fill) .aspectRatio(contentMode: .fill)
.frame(width: 40, height: 40) .frame(width: 40, height: 40)
.clipShape(Circle()) .clipShape(Circle())
.padding(5) .padding(5)
.sheet(isPresented: $showingMenu) {
UserMenuView()
}
} }
} }
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
@@ -41,7 +56,6 @@ struct HeaderView: View {
.shadow(radius: 10) .shadow(radius: 10)
.onAppear{ .onAppear{
// set background color based on profile picture tint // set background color based on profile picture tint
if authStore.sessionState == SessionState.isAuthenticated {
if let userPicUrl = authStore.user?.profilePictureUrl { if let userPicUrl = authStore.user?.profilePictureUrl {
if let avgColor = NirvanaImage.getAverageColor(url: userPicUrl.absoluteString) { if let avgColor = NirvanaImage.getAverageColor(url: userPicUrl.absoluteString) {
self.averageColor = avgColor self.averageColor = avgColor