diff --git a/yana/Features/CreateFeedFeature.swift b/yana/Features/CreateFeedFeature.swift index fbd8d3b..e25806f 100644 --- a/yana/Features/CreateFeedFeature.swift +++ b/yana/Features/CreateFeedFeature.swift @@ -16,7 +16,7 @@ struct CreateFeedFeature { processedImages.count < 9 } var canPublish: Bool { - !content.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty && !isLoading + (!content.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || !processedImages.isEmpty) && !isLoading } var isLoading: Bool = false @@ -108,7 +108,7 @@ struct CreateFeedFeature { case .publishButtonTapped: guard state.canPublish else { - state.errorMessage = "请输入内容" + state.errorMessage = "请输入内容或选择图片" return .none } @@ -203,7 +203,7 @@ struct CreateFeedFeature { let userId = await UserInfoManager.getCurrentUserId() ?? "" let type = resList.isEmpty ? "0" : "2" // 0: 纯文字, 2: 图片 let request = await PublishFeedRequest.make( - content: content, + content: content.isEmpty ? "" : content, uid: userId, type: type, resList: resList.isEmpty ? nil : resList diff --git a/yana/Views/CreateFeedView.swift b/yana/Views/CreateFeedView.swift index 575450a..d93dc3b 100644 --- a/yana/Views/CreateFeedView.swift +++ b/yana/Views/CreateFeedView.swift @@ -22,9 +22,6 @@ struct CreateFeedView: View { ContentInputSection(store: store, isFocused: $isTextEditorFocused) ImageSelectionSection(store: store) LoadingAndErrorSection(store: store) - - // 底部间距 - // Color.clear.frame(height: geometry.safeAreaInsets.bottom + 100) Spacer() } .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top) @@ -32,9 +29,10 @@ struct CreateFeedView: View { .background(Color(hex: 0x0C0527)) } - // 底部发布按钮 - 始终显示 - PublishButtonSection(store: store, geometry: geometry, isFocused: $isTextEditorFocused) - + // 底部发布按钮 - 只在键盘隐藏时显示 + if !isKeyboardVisible { + PublishButtonSection(store: store, geometry: geometry, isFocused: $isTextEditorFocused) + } } .onTapGesture { isTextEditorFocused = false // 点击空白处收起键盘 @@ -55,6 +53,12 @@ struct CreateFeedView: View { } } + ToolbarItem(placement: .principal) { + Text(NSLocalizedString("createFeed.title", comment: "Image & Text Publish")) + .font(.system(size: 18, weight: .medium)) + .foregroundColor(.white) + } + // 右上角发布按钮 - 只在键盘显示时出现 ToolbarItem(placement: .navigationBarTrailing) { if isKeyboardVisible { @@ -69,9 +73,22 @@ struct CreateFeedView: View { .scaleEffect(0.7) } Text(toolbarButtonText) - .font(.system(size: 16, weight: .medium)) + .font(.system(size: 14, weight: .medium)) .foregroundColor(.white) } + .padding(.horizontal, 12) + .padding(.vertical, 8) + .background( + LinearGradient( + gradient: Gradient(colors: [ + Color(hex: 0xF854FC), + Color(hex: 0x500FFF) + ]), + startPoint: .leading, + endPoint: .trailing + ) + ) + .cornerRadius(16) } .disabled(store.isLoading || store.isUploadingImages || !store.canPublish) .opacity(toolbarButtonOpacity) @@ -250,7 +267,7 @@ struct PublishButtonSection: View { @FocusState.Binding var isFocused: Bool var body: some View { - VStack { + VStack(spacing: 0) { Button(action: { isFocused = false // 收起键盘 store.send(.publishButtonTapped) @@ -286,7 +303,7 @@ struct PublishButtonSection: View { .opacity(buttonOpacity) } .padding(.horizontal, 16) - .padding(.bottom, geometry.safeAreaInsets.bottom + 20) + .padding(.bottom, 20) // 使用固定间距,不受键盘影响 } .background(Color(hex: 0x0C0527)) }