much better overall header and adding log out ability
This commit is contained in:
@@ -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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,35 +13,49 @@ struct HeaderView: View {
|
|||||||
@State var showingMenu: Bool = false
|
@State var showingMenu: Bool = false
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(alignment:.center) {
|
if authStore.sessionState == SessionState.isLoggedOut {
|
||||||
Image("undraw_handcrafts_leaf")
|
HStack {
|
||||||
.resizable()
|
Image("undraw_handcrafts_leaf")
|
||||||
.frame(width: 20.0, height: 32.132)
|
.resizable()
|
||||||
.padding(.leading, 20)
|
.frame(width: 20.0, height: 32.132)
|
||||||
|
.padding()
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
if self.authStore.sessionState == SessionState.isAuthenticated {
|
|
||||||
RemoteImage(url: self.authStore.user?.profilePictureUrl?.absoluteString ?? "https://avatars.githubusercontent.com/u/41487836")
|
|
||||||
.background(NirvanaColor.teal)
|
|
||||||
.aspectRatio(contentMode: .fill)
|
|
||||||
.frame(width: 40, height: 40)
|
|
||||||
.clipShape(Circle())
|
|
||||||
.padding(5)
|
|
||||||
.sheet(isPresented: $showingMenu) {
|
|
||||||
UserMenuView()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
.frame(maxWidth: .infinity)
|
HStack(alignment:.center) {
|
||||||
// .background(Color(self.averageColor)) // color based on user's profilepicture dominant color
|
Image("undraw_handcrafts_leaf")
|
||||||
.background(NirvanaColor.solidBlue)
|
.resizable()
|
||||||
.cornerRadius(100)
|
.frame(width: 20.0, height: 32.132)
|
||||||
.padding(.horizontal)
|
.padding(.leading, 20)
|
||||||
.shadow(radius: 10)
|
|
||||||
.onAppear{
|
Spacer()
|
||||||
// set background color based on profile picture tint
|
|
||||||
if 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")
|
||||||
|
.background(NirvanaColor.teal)
|
||||||
|
.aspectRatio(contentMode: .fill)
|
||||||
|
.frame(width: 40, height: 40)
|
||||||
|
.clipShape(Circle())
|
||||||
|
.padding(5)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
// .background(Color(self.averageColor)) // color based on user's profilepicture dominant color
|
||||||
|
.background(NirvanaColor.solidBlue)
|
||||||
|
.cornerRadius(100)
|
||||||
|
.padding(.horizontal)
|
||||||
|
.shadow(radius: 10)
|
||||||
|
.onAppear{
|
||||||
|
// set background color based on profile picture tint
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user