fixing bug regarding profile edit page as the lazygrid was rebuilt everytimte but now it's smooth
This commit is contained in:
@@ -13,8 +13,8 @@ struct AddBasicInfoView: View {
|
|||||||
@EnvironmentObject var authSessionStore: AuthSessionStore
|
@EnvironmentObject var authSessionStore: AuthSessionStore
|
||||||
@ObservedObject var addInfoViewModel: AddBasicInfoViewModel = AddBasicInfoViewModel()
|
@ObservedObject var addInfoViewModel: AddBasicInfoViewModel = AddBasicInfoViewModel()
|
||||||
|
|
||||||
@State var nickname = ""
|
@State private var nickname: String = ""
|
||||||
@State var selectedAvatarIndex: Int = 0
|
@State private var selectedAvatarIndex: Int = 0
|
||||||
|
|
||||||
var columns: [GridItem] =
|
var columns: [GridItem] =
|
||||||
Array(
|
Array(
|
||||||
@@ -55,7 +55,7 @@ struct AddBasicInfoView: View {
|
|||||||
.foregroundColor(NirvanaColor.teal)
|
.foregroundColor(NirvanaColor.teal)
|
||||||
.multilineTextAlignment(.center)
|
.multilineTextAlignment(.center)
|
||||||
|
|
||||||
Text("Select an avatar you like, then make a username! You can always change this later.")
|
Text("Select an avatar you like, then put your nickname! You can always change this later.")
|
||||||
.font(.subheadline)
|
.font(.subheadline)
|
||||||
.foregroundColor(Color.black.opacity(0.7))
|
.foregroundColor(Color.black.opacity(0.7))
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ struct AddBasicInfoView: View {
|
|||||||
// Horizontal scroll view to allow user to select the avatar he or she wants
|
// Horizontal scroll view to allow user to select the avatar he or she wants
|
||||||
ScrollView([.horizontal, .vertical], showsIndicators: false) {
|
ScrollView([.horizontal, .vertical], showsIndicators: false) {
|
||||||
LazyVGrid(columns: columns) {
|
LazyVGrid(columns: columns) {
|
||||||
ForEach(0..<Avatars.avatarSystemNames.count) { index in
|
ForEach(0..<Avatars.avatarSystemNames.count, id: \.self) { index in
|
||||||
Image(Avatars.avatarSystemNames[index])
|
Image(Avatars.avatarSystemNames[index])
|
||||||
.resizable()
|
.resizable()
|
||||||
.scaledToFit()
|
.scaledToFit()
|
||||||
@@ -81,6 +81,7 @@ struct AddBasicInfoView: View {
|
|||||||
.animation(.spring())
|
.animation(.spring())
|
||||||
}
|
}
|
||||||
}.padding(.top, 20)
|
}.padding(.top, 20)
|
||||||
|
.id(UUID())
|
||||||
}
|
}
|
||||||
|
|
||||||
// input nickname
|
// input nickname
|
||||||
@@ -134,18 +135,11 @@ struct AddBasicInfoView: View {
|
|||||||
.onAppear {
|
.onAppear {
|
||||||
// get current user nickname and avatar if they have one
|
// get current user nickname and avatar if they have one
|
||||||
self.nickname = self.authSessionStore.user?.nickname ?? ""
|
self.nickname = self.authSessionStore.user?.nickname ?? ""
|
||||||
|
|
||||||
if self.authSessionStore.user?.avatar != nil { // if user has previously selected an avatar
|
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
|
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},
|
|
||||||
// set: { _ in self.addInfoViewModel.state = ProfileRegistrationState.na }
|
|
||||||
// )) {
|
|
||||||
// Alert(title: Text("Important message"), message: Text("Wear sunscreen"), dismissButton: .default(Text("Got it!")))
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user