From 481f513b11fa833f77512dc0034080ecab8f710b Mon Sep 17 00:00:00 2001 From: wangdl Date: Thu, 28 May 2026 11:00:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(ios):=20=E5=B0=81=E9=9D=A2=E5=9B=BE?= =?UTF-8?q?=E5=BA=95=E9=83=A8=E5=8D=8A=E5=B1=8F=E6=8A=BD=E5=B1=89=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=20+=20=E5=B7=A6=E4=BE=A7=E6=AD=A3=E6=96=B9=E5=BD=A2?= =?UTF-8?q?=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 封面图有独立中文标签"封面图" - 120×120 正方形虚线框,左侧对齐 - 点击弹出底部半屏 sheet(height: 220) - sheet 内:从相册选择(带图标+描述+箭头) - 顶部有指示条(灰色胶囊) Co-Authored-By: Claude Opus 4.7 --- .../Features/Library/LibrarySubpages.swift | 66 +++++++++++++------ 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/AIStudyApp/AIStudyApp/Features/Library/LibrarySubpages.swift b/AIStudyApp/AIStudyApp/Features/Library/LibrarySubpages.swift index 4e325b0..e8cea9c 100644 --- a/AIStudyApp/AIStudyApp/Features/Library/LibrarySubpages.swift +++ b/AIStudyApp/AIStudyApp/Features/Library/LibrarySubpages.swift @@ -12,29 +12,28 @@ struct CreateLibraryPage: View { var body: some View { ZStack { Color.zxBg0.ignoresSafeArea(); VStack(spacing: 0) { ScrollView { VStack(spacing: 20) { - // 封面卡片 - Button { showCoverSheet = true } label: { - ZStack { - RoundedRectangle(cornerRadius: 14).fill(Color.zxFill004) - .overlay(RoundedRectangle(cornerRadius: 14).stroke(Color.zxBorder008, lineWidth: 1)) - if let img = coverImage { - Image(uiImage: img).resizable().scaledToFill().frame(height: 140).clipShape(RoundedRectangle(cornerRadius: 14)) - } else { - VStack(spacing: 8) { - Image(systemName: "photo.on.rectangle.angled").font(.system(size: 28)).foregroundColor(Color.zxF04) - Text("添加封面图").font(.system(size: 13, weight: .medium)).foregroundColor(Color.zxF04) - Text("从相册选择").font(.system(size: 11)).foregroundColor(Color.zxF03) + // 封面图 + VStack(alignment: .leading, spacing: 8) { + Text("封面图").font(.system(size: 12, weight: .semibold)).foregroundColor(Color.zxF035) + Button { showCoverSheet = true } label: { + ZStack { + RoundedRectangle(cornerRadius: 14).fill(Color.zxFill004) + .overlay(RoundedRectangle(cornerRadius: 14).stroke(style: StrokeStyle(lineWidth: 1.5, dash: [6, 4])).foregroundColor(Color.zxBorder01)) + .frame(width: 120, height: 120) + if let img = coverImage { + Image(uiImage: img).resizable().scaledToFill().frame(width: 120, height: 120).clipShape(RoundedRectangle(cornerRadius: 14)) + } else { + VStack(spacing: 6) { + Image(systemName: "camera.fill").font(.system(size: 22)).foregroundColor(Color.zxF04) + Text("上传").font(.system(size: 11)).foregroundColor(Color.zxF04) + } } + if isUploadingCover { RoundedRectangle(cornerRadius: 14).fill(Color.black.opacity(0.4)).frame(width: 120, height: 120); ProgressView().tint(.white) } } - if isUploadingCover { RoundedRectangle(cornerRadius: 14).fill(Color.black.opacity(0.4)); ProgressView().tint(.white) } } - .frame(height: 140) - } - .disabled(isUploadingCover) - .confirmationDialog("封面图", isPresented: $showCoverSheet) { - Button("从相册选择") { showCoverPicker = true } - Button("取消", role: .cancel) {} + .disabled(isUploadingCover) } + .frame(maxWidth: .infinity, alignment: .leading) VStack(alignment: .leading, spacing: 8) { HStack(spacing: 2) { Text("知识库名称").font(.system(size: 12, weight: .semibold)); Text("*").foregroundColor(.red) }.foregroundColor(Color.zxF035) @@ -78,6 +77,35 @@ struct CreateLibraryPage: View { .onChange(of: coverPhotoItem) { _, item in guard let item else { return } Task { await uploadCover(item) } + } + .sheet(isPresented: $showCoverSheet) { + VStack(spacing: 0) { + RoundedRectangle(cornerRadius: 3).fill(Color.zxF03).frame(width: 36, height: 5).padding(.top, 12).padding(.bottom, 16) + Text("封面图").font(.system(size: 16, weight: .semibold)).foregroundColor(Color.zxF0).padding(.bottom, 20) + Button { + showCoverSheet = false + DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { showCoverPicker = true } + } label: { + HStack(spacing: 12) { + Image(systemName: "photo.on.rectangle").font(.system(size: 20)).foregroundColor(Color.zxPrimary).frame(width: 40, height: 40).background(Color.zxPrimarySoft).clipShape(RoundedRectangle(cornerRadius: 10)) + VStack(alignment: .leading, spacing: 2) { + Text("从相册选择").font(.system(size: 15, weight: .medium)).foregroundColor(Color.zxF0) + Text("选择一张图片作为封面").font(.system(size: 12)).foregroundColor(Color.zxF04) + } + Spacer() + Image(systemName: "chevron.right").font(.system(size: 14)).foregroundColor(Color.zxF03) + } + .padding(.horizontal, 16).padding(.vertical, 14) + .background(Color.zxFill004).clipShape(RoundedRectangle(cornerRadius: 14)) + } + .foregroundColor(.primary) + .padding(.horizontal, 20) + Spacer() + } + .frame(maxWidth: .infinity, maxHeight: .infinity) + .background(Color.zxBg0) + .presentationDetents([.height(220)]) + .presentationDragIndicator(.hidden) }} private func uploadCover(_ item: PhotosPickerItem) async {