fixing issues and navigation smooth now
This commit is contained in:
@@ -9,8 +9,6 @@ import SwiftUI
|
||||
import NavigationStack
|
||||
|
||||
struct AddBasicInfoView: View {
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
@EnvironmentObject var navigationStack : NavigationStack
|
||||
@EnvironmentObject var authSessionStore: AuthSessionStore
|
||||
@ObservedObject var addInfoViewModel: AddBasicInfoViewModel = AddBasicInfoViewModel()
|
||||
@@ -24,114 +22,123 @@ struct AddBasicInfoView: View {
|
||||
count: 5)
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ZStack {
|
||||
// bg
|
||||
WavesGlassBackgroundView()
|
||||
ZStack {
|
||||
// bg
|
||||
WavesGlassBackgroundView()
|
||||
|
||||
// programmatic back button
|
||||
ZStack(alignment: .topLeading) {
|
||||
Color.clear
|
||||
|
||||
// main content
|
||||
VStack {
|
||||
// header logo area
|
||||
LogoHeaderView()
|
||||
Button {
|
||||
self.navigationStack.pop()
|
||||
} label: {
|
||||
Label("back", systemImage:"chevron.left")
|
||||
.labelStyle(.iconOnly)
|
||||
.font(.title2)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
|
||||
|
||||
// main content
|
||||
VStack {
|
||||
// header logo area
|
||||
LogoHeaderView()
|
||||
|
||||
// action text
|
||||
VStack(alignment: .leading) {
|
||||
Text("Let's Build A Profile")
|
||||
.font(.title)
|
||||
.fontWeight(.medium)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
// action text
|
||||
VStack(alignment: .leading) {
|
||||
Text("Let's Build A Profile")
|
||||
.font(.title)
|
||||
.fontWeight(.medium)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
Text("Select an avatar you like, then make a username! You can always change this later.")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(Color.black.opacity(0.7))
|
||||
}
|
||||
|
||||
// Horizontal scroll view to allow user to select the avatar he or she wants
|
||||
ScrollView([.horizontal, .vertical], showsIndicators: false) {
|
||||
LazyVGrid(columns: columns) {
|
||||
ForEach(0..<Avatars.avatarSystemNames.count) { index in
|
||||
Image(Avatars.avatarSystemNames[index])
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: 50, height: 50, alignment: .center)
|
||||
.blur(radius: self.selectedAvatarIndex == index ? 0 : 0.2)
|
||||
.scaleEffect(self.selectedAvatarIndex == index ? 1.5 : 1)
|
||||
.padding()
|
||||
.background(self.selectedAvatarIndex == index ? NirvanaColor.teal.opacity(0.5) : Color.clear)
|
||||
.clipShape(Circle())
|
||||
.onTapGesture {
|
||||
print("selected another avatar: \(index)")
|
||||
|
||||
self.selectedAvatarIndex = index
|
||||
}
|
||||
.animation(.spring())
|
||||
}
|
||||
}.padding(.top, 20)
|
||||
}
|
||||
Text("Select an avatar you like, then make a username! You can always change this later.")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(Color.black.opacity(0.7))
|
||||
}
|
||||
|
||||
// Horizontal scroll view to allow user to select the avatar he or she wants
|
||||
ScrollView([.horizontal, .vertical], showsIndicators: false) {
|
||||
LazyVGrid(columns: columns) {
|
||||
ForEach(0..<Avatars.avatarSystemNames.count) { index in
|
||||
Image(Avatars.avatarSystemNames[index])
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: 50, height: 50, alignment: .center)
|
||||
.blur(radius: self.selectedAvatarIndex == index ? 0 : 0.2)
|
||||
.scaleEffect(self.selectedAvatarIndex == index ? 1.5 : 1)
|
||||
.padding()
|
||||
.background(self.selectedAvatarIndex == index ? NirvanaColor.teal.opacity(0.5) : Color.clear)
|
||||
.clipShape(Circle())
|
||||
.onTapGesture {
|
||||
print("selected another avatar: \(index)")
|
||||
|
||||
// input nickname
|
||||
VStack {
|
||||
TextField("nickname", text: self.$nickname)
|
||||
.padding()
|
||||
.background(.ultraThinMaterial)
|
||||
.clipShape(Capsule())
|
||||
.shadow(radius:10)
|
||||
.font(.subheadline)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
Text("What do your friends call you?")
|
||||
.font(.caption)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
|
||||
}
|
||||
.padding()
|
||||
|
||||
|
||||
Spacer()
|
||||
|
||||
// button to save information
|
||||
Button {
|
||||
var updatedUser = self.authSessionStore.user
|
||||
updatedUser?.avatar = Avatars.avatarSystemNames[self.selectedAvatarIndex]
|
||||
updatedUser?.nickname = self.nickname
|
||||
|
||||
print("attempting to save information \(updatedUser)")
|
||||
|
||||
if updatedUser != nil {
|
||||
self.addInfoViewModel.updateUser(currUser: updatedUser!) {
|
||||
self.navigationStack.push(InnerCircleView())
|
||||
}
|
||||
self.selectedAvatarIndex = index
|
||||
}
|
||||
.animation(.spring())
|
||||
}
|
||||
}.padding(.top, 20)
|
||||
}
|
||||
|
||||
// input nickname
|
||||
VStack {
|
||||
TextField("nickname", text: self.$nickname)
|
||||
.padding()
|
||||
.background(.ultraThinMaterial)
|
||||
.clipShape(Capsule())
|
||||
.shadow(radius:10)
|
||||
.font(.subheadline)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
Text("What do your friends call you?")
|
||||
.font(.caption)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
|
||||
}
|
||||
.padding()
|
||||
|
||||
|
||||
Spacer()
|
||||
|
||||
// button to save information
|
||||
Button {
|
||||
var updatedUser = self.authSessionStore.user
|
||||
updatedUser?.avatar = Avatars.avatarSystemNames[self.selectedAvatarIndex]
|
||||
updatedUser?.nickname = self.nickname
|
||||
|
||||
print("attempting to save information \(updatedUser)")
|
||||
|
||||
if updatedUser != nil {
|
||||
self.addInfoViewModel.updateUser(currUser: updatedUser!) {
|
||||
self.navigationStack.push(InnerCircleView())
|
||||
}
|
||||
} label: {
|
||||
Text("Save")
|
||||
.fontWeight(.heavy)
|
||||
.foregroundColor(self.nickname.count == 0 ? Color.white.opacity(0.2) : Color.white)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 20)
|
||||
.background(self.nickname.count == 0 ? Color.white.opacity(0.3) : NirvanaColor.teal)
|
||||
.clipShape(Capsule())
|
||||
.shadow(radius:10)
|
||||
}
|
||||
.animation(.default)
|
||||
.padding()
|
||||
} label: {
|
||||
Text("Save")
|
||||
.fontWeight(.heavy)
|
||||
.foregroundColor(self.nickname.count == 0 ? Color.white.opacity(0.2) : Color.white)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 20)
|
||||
.background(self.nickname.count == 0 ? Color.white.opacity(0.3) : NirvanaColor.teal)
|
||||
.clipShape(Capsule())
|
||||
.shadow(radius:10)
|
||||
}
|
||||
.frame(maxWidth: UIScreen.main.bounds.width - 20, maxHeight: .infinity)
|
||||
.animation(.default)
|
||||
.padding()
|
||||
}
|
||||
.onAppear {
|
||||
// get current user nickname and avatar if they have one
|
||||
self.nickname = self.authSessionStore.user?.nickname ?? ""
|
||||
if self.authSessionStore.user?.avatar != nil { // if user has previously selected an avatar
|
||||
self.selectedAvatarIndex = Avatars.avatarSystemNames.firstIndex(of: (self.authSessionStore.user?.avatar)!) ?? 0 // 0 in case the system names doesn't have it anymore
|
||||
}
|
||||
}
|
||||
.navigationBarItems(trailing: Button(action: {
|
||||
dismiss()
|
||||
}, label: {
|
||||
Text("Cancel")
|
||||
}))
|
||||
.navigationBarHidden(true)
|
||||
.frame(maxWidth: UIScreen.main.bounds.width - 20, maxHeight: .infinity)
|
||||
}
|
||||
.onAppear {
|
||||
// get current user nickname and avatar if they have one
|
||||
self.nickname = self.authSessionStore.user?.nickname ?? ""
|
||||
if self.authSessionStore.user?.avatar != nil { // if user has previously selected an avatar
|
||||
self.selectedAvatarIndex = Avatars.avatarSystemNames.firstIndex(of: (self.authSessionStore.user?.avatar)!) ?? 0 // 0 in case the system names doesn't have it anymore
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: hook up the alert with the view model
|
||||
// .alert(isPresented: Binding<Bool>(
|
||||
// get: { self.addInfoViewModel.state == ProfileRegistrationState.failed},
|
||||
|
||||
@@ -9,10 +9,8 @@ import SwiftUI
|
||||
import Contacts
|
||||
import NavigationStack
|
||||
|
||||
|
||||
|
||||
struct FindFriendsView: View {
|
||||
@Environment(\.dismiss) var dismiss
|
||||
@EnvironmentObject var navigationStack : NavigationStack
|
||||
@EnvironmentObject var authSessionStore: AuthSessionStore
|
||||
|
||||
@StateObject var contactsVM = ContactsViewModel()
|
||||
@@ -20,11 +18,41 @@ struct FindFriendsView: View {
|
||||
@State private var searchQuery: String = ""
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ZStack {
|
||||
WavesGlassBackgroundView()
|
||||
|
||||
// programmatic back button
|
||||
ZStack(alignment: .topLeading) {
|
||||
Color.clear
|
||||
|
||||
Button {
|
||||
self.navigationStack.pop()
|
||||
} label: {
|
||||
Label("back", systemImage:"chevron.left")
|
||||
.labelStyle(.iconOnly)
|
||||
.font(.title2)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
|
||||
// main content
|
||||
VStack {
|
||||
Text("You must have someone in your phone contacts to add them. 🥬")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(Color.gray)
|
||||
// header logo area
|
||||
LogoHeaderView()
|
||||
|
||||
// action text
|
||||
VStack(alignment: .leading) {
|
||||
Text("Let's add some friends.")
|
||||
.font(.title)
|
||||
.fontWeight(.medium)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
Text("You must have someone in your phone contacts to add them. You can only add 10 people to your circle! 🥬")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
}
|
||||
|
||||
List {
|
||||
ForEach(searchItems, id: \.self) { key in
|
||||
@@ -35,12 +63,6 @@ struct FindFriendsView: View {
|
||||
}
|
||||
.searchable(text: self.$searchQuery)
|
||||
}
|
||||
.navigationTitle("Find Friends")
|
||||
.navigationBarItems(trailing: Button(action: {
|
||||
dismiss()
|
||||
}, label: {
|
||||
Text("Cancel")
|
||||
}))
|
||||
}
|
||||
.onAppear {
|
||||
self.contactsVM.fetchContacts()
|
||||
|
||||
@@ -13,22 +13,12 @@ struct CircleNavigationView: View {
|
||||
@EnvironmentObject var navigationStack: NavigationStack
|
||||
@EnvironmentObject var authSessionStore: AuthSessionStore
|
||||
|
||||
@Binding var sheetView: SheetView?
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .center) {
|
||||
Menu {
|
||||
Button(role: .destructive) {
|
||||
print("manage inbox")
|
||||
self.sheetView = .inbox
|
||||
} label: {
|
||||
Label("inbox", systemImage: "envelope.badge")
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
}
|
||||
|
||||
Button {
|
||||
print("going to show contacts now")
|
||||
self.sheetView = .contacts
|
||||
self.navigationStack.push(FindFriendsView())
|
||||
} label: {
|
||||
Label("add peeps", systemImage: "person.2.wave.2")
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
@@ -146,6 +136,6 @@ struct CircleNavigationView: View {
|
||||
|
||||
struct CircleNavigationView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
CircleNavigationView(sheetView: .constant(SheetView.contacts)).environmentObject(AuthSessionStore(isPreview: true))
|
||||
CircleNavigationView().environmentObject(AuthSessionStore(isPreview: true))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,20 +8,11 @@
|
||||
import SwiftUI
|
||||
import NavigationStack
|
||||
|
||||
enum SheetView : Identifiable {
|
||||
var id: Self { self }
|
||||
case contacts
|
||||
case inbox
|
||||
case profile
|
||||
}
|
||||
|
||||
struct InnerCircleView: View {
|
||||
@StateObject var innerCircleVM: InnerCircleViewModel = InnerCircleViewModel()
|
||||
@EnvironmentObject var authSessionStore: AuthSessionStore
|
||||
@EnvironmentObject var navigationStack: NavigationStack
|
||||
|
||||
@State var sheetView: SheetView? = nil
|
||||
|
||||
@State var selectedFriendIndex: Int? = nil
|
||||
|
||||
let universalSize = UIScreen.main.bounds
|
||||
@@ -40,7 +31,7 @@ struct InnerCircleView: View {
|
||||
.padding(.bottom)
|
||||
|
||||
Button {
|
||||
self.sheetView = SheetView.profile
|
||||
self.navigationStack.push(AddBasicInfoView())
|
||||
} label: {
|
||||
Text("Create Profile")
|
||||
.fontWeight(.heavy)
|
||||
@@ -69,7 +60,7 @@ struct InnerCircleView: View {
|
||||
.padding(.bottom)
|
||||
|
||||
Button {
|
||||
self.sheetView = SheetView.contacts
|
||||
self.navigationStack.push(FindFriendsView())
|
||||
} label: {
|
||||
Text("Add Friends")
|
||||
.fontWeight(.heavy)
|
||||
@@ -104,26 +95,13 @@ struct InnerCircleView: View {
|
||||
// header
|
||||
VStack(alignment: .leading) {
|
||||
|
||||
CircleNavigationView(sheetView: self.$sheetView).environmentObject(innerCircleVM)
|
||||
CircleNavigationView().environmentObject(innerCircleVM)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
||||
CircleFooterView(selectedFriendIndex: self.$selectedFriendIndex)
|
||||
}
|
||||
.sheet(item: self.$sheetView) {page in
|
||||
switch page {
|
||||
case SheetView.contacts:
|
||||
FindFriendsView()
|
||||
// case SheetView.inbox: // removing feature for now
|
||||
// InboxView()
|
||||
case SheetView.profile:
|
||||
AddBasicInfoView()
|
||||
default:
|
||||
Text("asdf")
|
||||
}
|
||||
|
||||
}
|
||||
.onAppear() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ struct OnboardingOneView: View {
|
||||
.frame(width: 5, height: 5)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
|
||||
Circle()
|
||||
Capsule()
|
||||
.frame(width: 5, height: 5)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
|
||||
@@ -82,7 +82,7 @@ struct OnboardingTwo: View {
|
||||
.frame(width: 20, height: 5)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
|
||||
Circle()
|
||||
Capsule()
|
||||
.frame(width: 5, height: 5)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
|
||||
@@ -104,7 +104,7 @@ struct OnboardingTwo: View {
|
||||
}
|
||||
|
||||
Button {
|
||||
self.navigationStack.push(OnboardingTwo())
|
||||
self.navigationStack.push(OnboardingThree())
|
||||
} label: {
|
||||
Text("Next")
|
||||
.fontWeight(.heavy)
|
||||
@@ -146,7 +146,7 @@ struct OnboardingThree: View {
|
||||
.frame(width: 5, height: 5)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
|
||||
Circle()
|
||||
Capsule()
|
||||
.frame(width: 20, height: 5)
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
|
||||
@@ -168,7 +168,7 @@ struct OnboardingThree: View {
|
||||
}
|
||||
|
||||
Button {
|
||||
self.navigationStack.push(OnboardingTwo())
|
||||
self.navigationStack.push(InnerCircleView())
|
||||
} label: {
|
||||
Text("Get Started")
|
||||
.fontWeight(.heavy)
|
||||
|
||||
Reference in New Issue
Block a user