feat: 固定按钮

This commit is contained in:
jinyaqiu 2025-09-01 14:07:03 +08:00
parent c069f0f205
commit 6bc0648fc7
2 changed files with 58 additions and 64 deletions

View File

@ -81,60 +81,64 @@ struct UserInfo: View {
//
GeometryReader { geometry in
ScrollView {
VStack(spacing: 0) {
// Spacer -
if !isKeyboardVisible {
Spacer(minLength: 0)
.frame(height: geometry.size.height * 0.1) // 10% of available height
}
// Content VStack
VStack(spacing: 20) {
// Title
Text(showUsername ? "Add Your Avatar" : "What's Your Name?")
.font(Typography.font(for: .body, family: .quicksandBold))
.frame(maxWidth: .infinity, alignment: .center)
// Avatar
AvatarPicker(
selectedImage: $avatarImage,
showUsername: $showUsername,
isKeyboardVisible: $isKeyboardVisible,
uploadedFileId: $uploadedFileId
)
.padding(.top, isKeyboardVisible ? 0 : 20)
if showUsername {
TextField("Username", text: $userName)
.font(Typography.font(for: .subtitle, family: .inter))
.multilineTextAlignment(.center)
.frame(maxWidth: .infinity)
.padding()
.foregroundColor(.black)
.background(
RoundedRectangle(cornerRadius: 16)
.fill(Color.themePrimaryLight)
)
.focused($isTextFieldFocused)
.submitLabel(.done)
.onSubmit {
isTextFieldFocused = false
}
ZStack(alignment: .bottom) {
ScrollView {
VStack(spacing: 0) {
// Spacer -
if !isKeyboardVisible {
Spacer(minLength: 0)
.frame(height: geometry.size.height * 0.1) // 10% of available height
}
// Content VStack
VStack(spacing: 20) {
// Title
Text(showUsername ? "Add Your Avatar" : "What's Your Name?")
.font(Typography.font(for: .body, family: .quicksandBold))
.frame(maxWidth: .infinity, alignment: .center)
// Avatar
AvatarPicker(
selectedImage: $avatarImage,
showUsername: $showUsername,
isKeyboardVisible: $isKeyboardVisible,
uploadedFileId: $uploadedFileId
)
.padding(.top, isKeyboardVisible ? 0 : 20)
if showUsername {
TextField("Username", text: $userName)
.font(Typography.font(for: .subtitle, family: .inter))
.multilineTextAlignment(.center)
.frame(maxWidth: .infinity)
.padding()
.foregroundColor(.black)
.background(
RoundedRectangle(cornerRadius: 16)
.fill(Color.themePrimaryLight)
)
.focused($isTextFieldFocused)
.submitLabel(.done)
.onSubmit {
isTextFieldFocused = false
}
}
}
.padding()
.background(Color(.white))
.cornerRadius(20)
.padding(.horizontal)
//
Spacer(minLength: 40) // +
}
.padding()
.background(Color(.white))
.cornerRadius(20)
.padding(.horizontal)
// Spacer -
if !isKeyboardVisible {
Spacer(minLength: 0)
.frame(height: geometry.size.height * 0.1) // 10% of available height
}
// Continue Button
.frame(minHeight: geometry.size.height) //
.padding(.bottom, isKeyboardVisible ? 300 : 0) //
}
// Fixed Button at bottom
VStack {
Spacer()
Button(action: {
if showUsername {
let parameters: [String: Any] = [
@ -150,11 +154,9 @@ struct UserInfo: View {
switch result {
case .success(let response):
print("✅ 用户信息更新成功")
// Update local state with the new user info
if let userData = response.data {
self.userName = userData.username
}
// Navigate using router
Router.shared.navigate(to: .blindBox(mediaType: .image))
case .failure(let error):
@ -181,18 +183,10 @@ struct UserInfo: View {
.fill(Color.themePrimary)
)
}
.padding(.horizontal, 32) //
.padding(.horizontal, 32)
.padding(.bottom, isKeyboardVisible ? 20 : 40)
.animation(.easeInOut, value: showUsername)
.frame(maxWidth: .infinity)
//
if isKeyboardVisible {
Spacer(minLength: 0)
.frame(height: 20) //
}
}
.frame(minHeight: geometry.size.height) //
}
}
.background(Color.themeTextWhiteSecondary)

View File

@ -46,7 +46,7 @@ struct WakeApp: App {
if authState.isAuthenticated {
//
NavigationStack(path: $router.path) {
BlindBoxView(mediaType: .all)
UserInfo()
.navigationDestination(for: AppRoute.self) { route in
route.view
}