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
|
||||
@ObservedObject var addInfoViewModel: AddBasicInfoViewModel = AddBasicInfoViewModel()
|
||||
|
||||
@State var nickname = ""
|
||||
@State var selectedAvatarIndex: Int = 0
|
||||
@State private var nickname: String = ""
|
||||
@State private var selectedAvatarIndex: Int = 0
|
||||
|
||||
var columns: [GridItem] =
|
||||
Array(
|
||||
@@ -55,7 +55,7 @@ struct AddBasicInfoView: View {
|
||||
.foregroundColor(NirvanaColor.teal)
|
||||
.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)
|
||||
.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
|
||||
ScrollView([.horizontal, .vertical], showsIndicators: false) {
|
||||
LazyVGrid(columns: columns) {
|
||||
ForEach(0..<Avatars.avatarSystemNames.count) { index in
|
||||
ForEach(0..<Avatars.avatarSystemNames.count, id: \.self) { index in
|
||||
Image(Avatars.avatarSystemNames[index])
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
@@ -75,14 +75,15 @@ struct AddBasicInfoView: View {
|
||||
.clipShape(Circle())
|
||||
.onTapGesture {
|
||||
print("selected another avatar: \(index)")
|
||||
|
||||
|
||||
self.selectedAvatarIndex = index
|
||||
}
|
||||
.animation(.spring())
|
||||
}
|
||||
}.padding(.top, 20)
|
||||
.id(UUID())
|
||||
}
|
||||
|
||||
|
||||
// input nickname
|
||||
VStack {
|
||||
TextField("nickname", text: self.$nickname)
|
||||
@@ -134,18 +135,11 @@ struct AddBasicInfoView: View {
|
||||
.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},
|
||||
// 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