
- 在Info.plist中新增API签名密钥配置。 - 将Splash视图替换为SplashV2,优化启动逻辑和用户体验。 - 更新API请求中的User-Agent逻辑,使用UserAgentProvider提供的动态值。 - 在APILogger中添加敏感信息脱敏处理,增强安全性。 - 新增CreateFeedPage视图,支持用户发布动态功能。 - 更新MainPage和Splash视图的导航逻辑,整合统一的AppRoute管理。 - 移除冗余的SplashFeature视图,提升代码整洁性和可维护性。
90 lines
3.6 KiB
Swift
90 lines
3.6 KiB
Swift
import SwiftUI
|
|
|
|
@MainActor
|
|
final class CreateFeedViewModel: ObservableObject {
|
|
@Published var content: String = ""
|
|
@Published var selectedImages: [UIImage] = []
|
|
@Published var isPublishing: Bool = false
|
|
@Published var errorMessage: String? = nil
|
|
var canPublish: Bool { !content.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || !selectedImages.isEmpty }
|
|
}
|
|
|
|
struct CreateFeedPage: View {
|
|
@StateObject private var viewModel = CreateFeedViewModel()
|
|
let onDismiss: () -> Void
|
|
|
|
var body: some View {
|
|
GeometryReader { _ in
|
|
ZStack {
|
|
Color(hex: 0x0C0527).ignoresSafeArea()
|
|
VStack(spacing: 16) {
|
|
HStack {
|
|
Button(action: onDismiss) {
|
|
Image(systemName: "xmark")
|
|
.foregroundColor(.white)
|
|
.font(.system(size: 18, weight: .medium))
|
|
}
|
|
Spacer()
|
|
Text(LocalizedString("createFeed.title", comment: "Image & Text Publish"))
|
|
.foregroundColor(.white)
|
|
.font(.system(size: 18, weight: .medium))
|
|
Spacer()
|
|
Button(action: publish) {
|
|
if viewModel.isPublishing {
|
|
ProgressView()
|
|
.progressViewStyle(CircularProgressViewStyle(tint: .white))
|
|
} else {
|
|
Text(LocalizedString("createFeed.publish", comment: "Publish"))
|
|
.foregroundColor(.white)
|
|
.font(.system(size: 14, weight: .medium))
|
|
}
|
|
}
|
|
.disabled(!viewModel.canPublish || viewModel.isPublishing)
|
|
.opacity((!viewModel.canPublish || viewModel.isPublishing) ? 0.6 : 1)
|
|
}
|
|
.padding(.horizontal, 16)
|
|
.padding(.top, 12)
|
|
|
|
ZStack(alignment: .topLeading) {
|
|
RoundedRectangle(cornerRadius: 8).fill(Color(hex: 0x1C143A))
|
|
if viewModel.content.isEmpty {
|
|
Text(LocalizedString("createFeed.enterContent", comment: "Enter Content"))
|
|
.foregroundColor(.white.opacity(0.5))
|
|
.padding(.horizontal, 16)
|
|
.padding(.vertical, 12)
|
|
}
|
|
TextEditor(text: $viewModel.content)
|
|
.foregroundColor(.white)
|
|
.padding(.horizontal, 12)
|
|
.padding(.vertical, 8)
|
|
.scrollContentBackground(.hidden)
|
|
.frame(height: 200)
|
|
}
|
|
.frame(height: 200)
|
|
.padding(.horizontal, 20)
|
|
|
|
if let error = viewModel.errorMessage {
|
|
Text(error)
|
|
.foregroundColor(.red)
|
|
.font(.system(size: 14))
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|
|
.navigationBarBackButtonHidden(true)
|
|
}
|
|
|
|
private func publish() {
|
|
viewModel.isPublishing = true
|
|
Task { @MainActor in
|
|
try? await Task.sleep(nanoseconds: 500_000_000)
|
|
viewModel.isPublishing = false
|
|
onDismiss()
|
|
}
|
|
}
|
|
}
|
|
|
|
|