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