diff --git a/apps/ios/ItemAtlas.xcodeproj/project.pbxproj b/apps/ios/ItemAtlas.xcodeproj/project.pbxproj index b57c92d..880a00b 100644 --- a/apps/ios/ItemAtlas.xcodeproj/project.pbxproj +++ b/apps/ios/ItemAtlas.xcodeproj/project.pbxproj @@ -117,7 +117,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 19; + CURRENT_PROJECT_VERSION = 20; GENERATE_INFOPLIST_FILE = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ATLAS_API_BASE_URL = "https://api-atlas.tutudog.com"; @@ -138,7 +138,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 19; + CURRENT_PROJECT_VERSION = 20; GENERATE_INFOPLIST_FILE = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ATLAS_API_BASE_URL = "https://api-atlas.tutudog.com"; diff --git a/apps/ios/ItemAtlas/CommunityView.swift b/apps/ios/ItemAtlas/CommunityView.swift index e0add81..c8b1142 100644 --- a/apps/ios/ItemAtlas/CommunityView.swift +++ b/apps/ios/ItemAtlas/CommunityView.swift @@ -151,9 +151,17 @@ struct CommunityFeedView: View { if displayedTerm != term && error == nil { ProgressView("正在加载分享") } else if posts.isEmpty && error == nil { - ContentUnavailableView(term.isEmpty ? "还没有分享" : "没找到相关分享", - systemImage: "bubble.left.and.bubble.right", - description: Text(emptyDescription)) + ContentUnavailableView { + Label(term.isEmpty ? "还没有分享" : "没找到相关分享", systemImage: "bubble.left.and.bubble.right") + } description: { + Text(emptyDescription) + } actions: { + if !term.isEmpty { + Button("清除搜索") { query = "" }.buttonStyle(.bordered) + } else if canPublish { + Button("发布物品") { showingChooser = true }.buttonStyle(.borderedProminent) + } + } } ForEach(displayedTerm == term ? posts : []) { post in VStack(alignment: .leading, spacing: 10) { @@ -194,7 +202,7 @@ struct CommunityFeedView: View { .navigationBarTitleDisplayMode(.inline) .searchable(text: $query, prompt: publicAuthor == nil ? "搜公开物品和分享" : "搜此人的公开物品") .toolbar { - if let source, source.space.role == "OWNER" && !mine { + if canPublish { ToolbarItem(placement: .topBarTrailing) { Button { showingChooser = true } label: { Label("发布物品", systemImage: "square.and.pencil") } } @@ -212,7 +220,10 @@ struct CommunityFeedView: View { } } + private var canPublish: Bool { source?.space.role == "OWNER" && !mine && publicAuthor == nil } + private var emptyDescription: String { + if !term.isEmpty { return "试试其他关键词。" } if mine { return "你公开的物品会显示在这里。" } if publicAuthor != nil { return "这个主页会显示对方的公开分享。" } return "可以搜索公开物品,或发布自己的使用感受。" @@ -488,48 +499,76 @@ private struct CommunityItemChooser: View { @State private var query = "" @State private var items: [Item] = [] @State private var selected: Item? + @State private var showingIntake = false @State private var loading = true @State private var hasMore = false @State private var error: String? @State private var generation = UUID() @State private var revision = 0 + private var term: String { query.trimmingCharacters(in: .whitespacesAndNewlines) } + var body: some View { NavigationStack { - List { - if loading && items.isEmpty { ProgressView("正在查找物品") } - ForEach(items) { item in - Button { selected = item } label: { - HStack { - Text(item.name).foregroundStyle(.primary) - Spacer() - if item.published == true { - Text("已公开").font(.caption).foregroundStyle(.secondary) - } + if showingIntake { + IntakeView(store: store, onReturnToChooser: { + loading = true + showingIntake = false + }) + } else { + chooser + } + } + } + + private var chooser: some View { + List { + if loading && items.isEmpty { ProgressView("正在查找物品") } + ForEach(items) { item in + Button { selected = item } label: { + HStack { + Text(item.name).foregroundStyle(.primary) + Spacer() + if item.published == true { + Text("已公开").font(.caption).foregroundStyle(.secondary) } } } - if let error { - Text(error).font(.footnote).foregroundStyle(.red) - Button("重新加载") { revision += 1 } - } else if !loading && items.isEmpty { - ContentUnavailableView("没有可选物品", systemImage: "archivebox") - } else if hasMore { - Button("更多物品") { Task { await load(append: true) } }.disabled(loading) - } } - .navigationTitle("选择要分享的物品") - .navigationBarTitleDisplayMode(.inline) - .searchable(text: $query, prompt: "搜当前空间里的物品") - .toolbar { - ToolbarItem(placement: .cancellationAction) { Button("完成") { dismiss() } } + if let error { + Text(error).font(.footnote).foregroundStyle(.red) + Button("重新加载") { revision += 1 } + } else if !loading && items.isEmpty { + emptyState + } else if hasMore { + Button("更多物品") { Task { await load(append: true) } }.disabled(loading) } - .task(id: "\(revision):\(query)") { await load() } - .sheet(item: $selected) { item in - PublicationEditor(store: store, item: item) { - revision += 1 - onChange() - } + } + .navigationTitle("选择要分享的物品") + .navigationBarTitleDisplayMode(.inline) + .searchable(text: $query, prompt: "搜当前空间里的物品") + .toolbar { + ToolbarItem(placement: .cancellationAction) { Button("完成") { dismiss() } } + } + .task(id: "\(revision):\(term)") { await load() } + .sheet(item: $selected) { item in + PublicationEditor(store: store, item: item) { + revision += 1 + onChange() + } + } + } + + private var emptyState: some View { + ContentUnavailableView { + Label(term.isEmpty ? "没有可选物品" : "没找到物品", systemImage: "archivebox") + } description: { + Text(term.isEmpty ? "录入一件物品,就可以回来选它。" : "换个名字或别名试试。") + } actions: { + if term.isEmpty && store.canWrite { + Button("录入物品") { showingIntake = true }.buttonStyle(.borderedProminent) + } else if !term.isEmpty { + Button("清除搜索") { query = "" }.buttonStyle(.bordered) } } } @@ -538,16 +577,16 @@ private struct CommunityItemChooser: View { guard !append || !loading else { return } let id = UUID() generation = id - let term = query + let requested = term if !append { items = []; hasMore = false } loading = true error = nil defer { if generation == id { loading = false } } do { - if !append && !term.isEmpty { try await Task.sleep(for: .milliseconds(250)) } - let page = try await store.search(term, favorites: false, offset: append ? items.count : 0) + if !append && !requested.isEmpty { try await Task.sleep(for: .milliseconds(250)) } + let page = try await store.search(requested, favorites: false, offset: append ? items.count : 0) try Task.checkCancellation() - guard generation == id, query == term else { return } + guard generation == id, term == requested else { return } items += page hasMore = page.count == 50 } catch where !Task.isCancelled && generation == id { self.error = error.localizedDescription } diff --git a/apps/ios/ItemAtlas/Editors.swift b/apps/ios/ItemAtlas/Editors.swift index d44e0f6..fe5d73d 100644 --- a/apps/ios/ItemAtlas/Editors.swift +++ b/apps/ios/ItemAtlas/Editors.swift @@ -5,6 +5,7 @@ struct ItemEditor: View { let store: InventoryStore var initialLocation: UUID? = nil var existing: Item? = nil + var onClose: ((Bool) -> Void)? = nil @Environment(\.dismiss) private var dismiss @FocusState private var focus: Field? @State private var name = "" @@ -40,64 +41,9 @@ struct ItemEditor: View { } var body: some View { - NavigationStack { - Form { - if savedItem != nil { - Section { - Text("物品已保存,照片可以重试上传。") - Button("稍后添加照片") { dismiss() }.disabled(busy) - } - } - Section("物品") { - TextField("名称", text: $name).focused($focus, equals: .name) - TextField("别名,用逗号隔开", text: $aliases).focused($focus, equals: .aliases) - Stepper("数量:\(quantity)", value: $quantity, in: 1...9999) - TextField("购入单价(元,可选)", text: $price).keyboardType(.decimalPad) - .focused($focus, equals: .price) - if !validPrice { - Text("单价允许 0 到 999 亿元,最多两位小数。") - .font(.footnote).foregroundStyle(.secondary) - } - TextField("备注", text: $notes, axis: .vertical).focused($focus, equals: .notes) - } - .disabled(busy || savedItem != nil) - photoSection - Section("图标") { - SymbolPicker(symbols: InventorySymbol.items, color: .teal, selection: $icon) - } - .disabled(busy || savedItem != nil) - if existing == nil { - Section("存放位置(可选)") { - LocationPicker(store: store, selection: $locationID, allowsClearing: true) - if !loadingLocations && store.locations.isEmpty { - Button("新建位置") { focus = nil; showingAddLocation = true } - } - } - .disabled(busy || savedItem != nil) - } - if let error { Text(error).foregroundStyle(.red) } - } - .dismissibleKeyboard(active: focus != nil) { focus = nil } - .navigationTitle(existing == nil ? "添加物品" : "编辑物品") - .navigationBarTitleDisplayMode(.inline) - .toolbar { - ToolbarItem(placement: .cancellationAction) { - Button(savedItem == nil ? "取消" : "关闭") { dismiss() }.disabled(busy) - } - ToolbarItem(placement: .confirmationAction) { - Button(savedItem == nil ? "保存" : "重试上传") { focus = nil; Task { await save() } } - .disabled(!canSave) - } - } - .sheet(isPresented: $showingAddLocation) { - PlaceEditor(store: store) { locationID = $0 } - } - .sheet(item: $crop) { source in - CropEditor(source: source, actionTitle: "使用照片") { jpeg in - photo = jpeg - photoKey = UUID() - } - } + Group { + if onClose == nil { NavigationStack { form } } + else { form } } .interactiveDismissDisabled(busy) .task { @@ -136,6 +82,66 @@ struct ItemEditor: View { } } + private var form: some View { + Form { + if savedItem != nil { + Section { + Text("物品已保存,照片可以重试上传。") + Button("稍后添加照片", action: close).disabled(busy) + } + } + Section("物品") { + TextField("名称", text: $name).focused($focus, equals: .name) + TextField("别名,用逗号隔开", text: $aliases).focused($focus, equals: .aliases) + Stepper("数量:\(quantity)", value: $quantity, in: 1...9999) + TextField("购入单价(元,可选)", text: $price).keyboardType(.decimalPad) + .focused($focus, equals: .price) + if !validPrice { + Text("单价允许 0 到 999 亿元,最多两位小数。") + .font(.footnote).foregroundStyle(.secondary) + } + TextField("备注", text: $notes, axis: .vertical).focused($focus, equals: .notes) + } + .disabled(busy || savedItem != nil) + photoSection + Section("图标") { + SymbolPicker(symbols: InventorySymbol.items, color: .teal, selection: $icon) + } + .disabled(busy || savedItem != nil) + if existing == nil { + Section("存放位置(可选)") { + LocationPicker(store: store, selection: $locationID, allowsClearing: true) + if !loadingLocations && store.locations.isEmpty { + Button("新建位置") { focus = nil; showingAddLocation = true } + } + } + .disabled(busy || savedItem != nil) + } + if let error { Text(error).foregroundStyle(.red) } + } + .dismissibleKeyboard(active: focus != nil) { focus = nil } + .navigationTitle(existing == nil ? "添加物品" : "编辑物品") + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .cancellationAction) { + Button(savedItem == nil ? "取消" : "关闭", action: close).disabled(busy) + } + ToolbarItem(placement: .confirmationAction) { + Button(savedItem == nil ? "保存" : "重试上传") { focus = nil; Task { await save() } } + .disabled(!canSave) + } + } + .sheet(isPresented: $showingAddLocation) { + PlaceEditor(store: store) { locationID = $0 } + } + .sheet(item: $crop) { source in + CropEditor(source: source, actionTitle: "使用照片") { jpeg in + photo = jpeg + photoKey = UUID() + } + } + } + private var photoSection: some View { let pickerTitle = photo == nil ? "选择照片" : "更换待上传照片" return Section("照片") { @@ -182,9 +188,14 @@ struct ItemEditor: View { savedItem = item } if let photo { try await store.upload(photo, target: .item(item.id), idempotencyKey: photoKey) } - dismiss() + close() } catch { self.error = error.localizedDescription } } + + private func close() { + if let onClose { onClose(savedItem != nil) } + else { dismiss() } + } } struct MoveEditor: View { diff --git a/apps/ios/ItemAtlas/IntakeView.swift b/apps/ios/ItemAtlas/IntakeView.swift index 338503e..fcdeae3 100644 --- a/apps/ios/ItemAtlas/IntakeView.swift +++ b/apps/ios/ItemAtlas/IntakeView.swift @@ -3,6 +3,7 @@ import SwiftUI struct IntakeView: View { let store: InventoryStore var initialLocation: Place? = nil + var onReturnToChooser: (() -> Void)? = nil @Environment(\.scenePhase) private var scenePhase @Environment(\.dismiss) private var dismiss @AppStorage("atlas.voice.recording-mode") private var recordingMode: RecordingMode = .tap @@ -43,6 +44,23 @@ struct IntakeView: View { } var body: some View { + if let onReturnToChooser { + if showingAdd { + ItemEditor(store: store, initialLocation: initialLocation?.id, onClose: { saved in + showingAdd = false + if saved { onReturnToChooser() } + }) + } else { + intake + } + } else { + intake.sheet(isPresented: $showingAdd) { + ItemEditor(store: store, initialLocation: initialLocation?.id) + } + } + } + + private var intake: some View { ScrollViewReader { scroll in ScrollView { VStack(alignment: .leading, spacing: 14) { @@ -75,7 +93,11 @@ struct IntakeView: View { .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .cancellationAction) { - Button("关闭") { dismiss() }.disabled(busy) + Button(onReturnToChooser == nil ? "关闭" : "返回选择") { + if let onReturnToChooser { onReturnToChooser() } + else { dismiss() } + } + .disabled(busy) } ToolbarItem(placement: .topBarTrailing) { Button { showingHelp = true } label: { Label("录入说明", systemImage: "questionmark.circle") } @@ -95,7 +117,6 @@ struct IntakeView: View { } } .sheet(isPresented: $showingHelp) { help } - .sheet(isPresented: $showingAdd) { ItemEditor(store: store, initialLocation: initialLocation?.id) } } private var smartCard: some View { @@ -387,6 +408,7 @@ struct IntakeView: View { operation = status if status.status == "COMPLETED" { store.changed(inventorySummaryChanged: true) + onReturnToChooser?() return } if ["FAILED", "REJECTED", "NEEDS_REVIEW"].contains(status.status) { return } diff --git a/apps/ios/ItemAtlas/InventoryView.swift b/apps/ios/ItemAtlas/InventoryView.swift index 2c1d39d..03ad1ec 100644 --- a/apps/ios/ItemAtlas/InventoryView.swift +++ b/apps/ios/ItemAtlas/InventoryView.swift @@ -226,10 +226,22 @@ struct ItemsSection: View { var body: some View { Section { + if location != nil, let onIntake, store.canWrite { + Button(action: onIntake) { + Label("在这里录入", systemImage: "plus.circle.fill") + .font(.subheadline.weight(.semibold)) + .foregroundStyle(Color.atlasBlue) + } + } if results.error == nil && (results.loading || results.displayedQuery != input) { ProgressView("加载中") } else if results.rows.isEmpty && results.error == nil { - ContentUnavailableView(emptyTitle, systemImage: favorites ? "star" : "archivebox", - description: Text(emptyDescription)) + if location != nil { + Label("这个位置还没有物品", systemImage: "shippingbox") + .font(.subheadline).foregroundStyle(.secondary) + } else { + ContentUnavailableView(emptyTitle, systemImage: favorites ? "star" : "archivebox", + description: Text(emptyDescription)) + } } ForEach(results.displayedQuery == input ? results.rows : []) { item in NavigationLink { ItemDetailView(store: store, itemID: item.id, summary: item) } label: { @@ -262,6 +274,8 @@ struct ItemsSection: View { results.displayedQuery == input, results.rows.isEmpty, results.error == nil { Button(action: onIntake) { Label("添加物品", systemImage: "plus") } } + } header: { + if location != nil { Text("这里的物品") } } } diff --git a/apps/ios/ItemAtlas/ItemPhotos.swift b/apps/ios/ItemAtlas/ItemPhotos.swift index ae8367c..41dd0f5 100644 --- a/apps/ios/ItemAtlas/ItemPhotos.swift +++ b/apps/ios/ItemAtlas/ItemPhotos.swift @@ -63,6 +63,7 @@ struct PhotoImage: View { struct PhotoGallery: View { let store: InventoryStore let target: PhotoTarget + let embedded: Bool @State private var photos: [Photo]? @State private var picker: PhotosPickerItem? @State private var crop: CropSource? @@ -72,93 +73,98 @@ struct PhotoGallery: View { @State private var busy = false @State private var error: String? - init(store: InventoryStore, target: PhotoTarget) { + init(store: InventoryStore, target: PhotoTarget, embedded: Bool = false) { self.store = store self.target = target + self.embedded = embedded _photos = State(initialValue: store.account.cached(store.root + target.path)) } var body: some View { - Section(target.title) { - VStack(alignment: .leading, spacing: 14) { - if let photos, !photos.isEmpty { - ScrollView(.horizontal) { - HStack { - ForEach(photos) { photo in - Button { preview = photo } label: { - PhotoImage(store: store, target: target, photo: photo.id, thumbnail: true) - .frame(width: 74, height: 74).clipShape(.rect(cornerRadius: 9)) - } - .buttonStyle(.plain) - .accessibilityLabel("查看照片") + if embedded { gallery } + else { Section(target.title) { gallery } } + } + + private var gallery: some View { + VStack(alignment: .leading, spacing: embedded ? 10 : 14) { + if embedded { Text("位置照片").font(.subheadline.weight(.semibold)) } + if let photos, !photos.isEmpty { + ScrollView(.horizontal) { + HStack { + ForEach(photos) { photo in + Button { preview = photo } label: { + PhotoImage(store: store, target: target, photo: photo.id, thumbnail: true) + .frame(width: 74, height: 74).clipShape(.rect(cornerRadius: 9)) } + .buttonStyle(.plain) + .accessibilityLabel("查看照片") } } - .scrollIndicators(.hidden) - } else if photos != nil { Text("暂无照片").foregroundStyle(.secondary) } - if store.canWrite && (photos?.count ?? 0) < 6 { - HStack(spacing: 20) { - if UIImagePickerController.isSourceTypeAvailable(.camera) { - Button { Task { await openCamera() } } label: { - Label("拍照", systemImage: "camera") - } - .buttonStyle(.borderless) - } - PhotosPicker(selection: $picker, matching: .images, preferredItemEncoding: .current) { - Label("从相册选", systemImage: "photo.badge.plus") + } + .scrollIndicators(.hidden) + } else if photos != nil { Text("暂无照片").foregroundStyle(.secondary) } + if store.canWrite && (photos?.count ?? 0) < 6 { + HStack(spacing: 20) { + if UIImagePickerController.isSourceTypeAvailable(.camera) { + Button { Task { await openCamera() } } label: { + Label("拍照", systemImage: "camera") } .buttonStyle(.borderless) } - .disabled(busy) - } - if busy { ProgressView() } - if let error { Text(error).foregroundStyle(.red).font(.footnote) } - if error != nil { - Button("刷新照片") { Task { await load(refresh: true) } }.buttonStyle(.borderless) - } - } - .padding(.vertical, 4) - .task(id: store.revision) { await load() } - .task(id: picker) { - guard let selection = picker else { return } - busy = true - defer { - if picker == selection { - busy = false - picker = nil + PhotosPicker(selection: $picker, matching: .images, preferredItemEncoding: .current) { + Label("从相册选", systemImage: "photo.badge.plus") } + .buttonStyle(.borderless) } - do { - guard let source = try await selection.loadTransferable(type: CropSource.self) else { - throw AtlasError("这张图片无法读取,请重新选择。") - } - try Task.checkCancellation() - error = nil - crop = source - } catch where !Task.isCancelled { self.error = error.localizedDescription } - catch {} + .disabled(busy) } - .fullScreenCover(isPresented: $showingCamera, onDismiss: { - crop = cameraCrop - cameraCrop = nil - }) { - CameraPicker { image in - if let image { - cameraCrop = CropSource.cameraImage(image) - if cameraCrop == nil { error = "照片无法读取,请重新拍摄。" } - } - showingCamera = false - } - .ignoresSafeArea() + if busy { ProgressView() } + if let error { Text(error).foregroundStyle(.red).font(.footnote) } + if error != nil { + Button("刷新照片") { Task { await load(refresh: true) } }.buttonStyle(.borderless) } - .sheet(item: $crop) { source in - CropEditor(source: source) { image in - try await store.upload(image, target: target, idempotencyKey: source.id) + } + .padding(.vertical, 4) + .task(id: store.revision) { await load() } + .task(id: picker) { + guard let selection = picker else { return } + busy = true + defer { + if picker == selection { + busy = false + picker = nil } } - .sheet(item: $preview) { photo in - PhotoPreview(store: store, target: target, photo: photo) + do { + guard let source = try await selection.loadTransferable(type: CropSource.self) else { + throw AtlasError("这张图片无法读取,请重新选择。") + } + try Task.checkCancellation() + error = nil + crop = source + } catch where !Task.isCancelled { self.error = error.localizedDescription } + catch {} + } + .fullScreenCover(isPresented: $showingCamera, onDismiss: { + crop = cameraCrop + cameraCrop = nil + }) { + CameraPicker { image in + if let image { + cameraCrop = CropSource.cameraImage(image) + if cameraCrop == nil { error = "照片无法读取,请重新拍摄。" } + } + showingCamera = false } + .ignoresSafeArea() + } + .sheet(item: $crop) { source in + CropEditor(source: source) { image in + try await store.upload(image, target: target, idempotencyKey: source.id) + } + } + .sheet(item: $preview) { photo in + PhotoPreview(store: store, target: target, photo: photo) } } diff --git a/apps/ios/ItemAtlas/LocationView.swift b/apps/ios/ItemAtlas/LocationView.swift index d9b8f63..f124b18 100644 --- a/apps/ios/ItemAtlas/LocationView.swift +++ b/apps/ios/ItemAtlas/LocationView.swift @@ -54,46 +54,9 @@ private struct LocationContents: View { List { if let location { Section { - HStack(spacing: 11) { - LocationMark(store: store, place: location, size: 38) - VStack(alignment: .leading, spacing: 4) { - Text(location.path).font(.subheadline) - LocationLevelBadge(level: LocationLevel(depth: location.levelDepth)) - } - } - Button { editingAppearance = true } label: { - Label("图标与缩略图", systemImage: "square.on.square") - } - .disabled(busy) + locationOverview(location) } } - if let location, store.canWrite { - Section { - Button { onIntake(location) } label: { - Label { - VStack(alignment: .leading, spacing: 4) { - Text("在这里录入") - .font(.headline) - .foregroundStyle(.primary) - Text("智能录入或手动添加") - .font(.subheadline) - .foregroundStyle(.secondary) - } - } icon: { - Image(systemName: "plus") - .font(.headline.weight(.semibold)) - .foregroundStyle(.white) - .frame(width: 37, height: 37) - .background(Color.atlasBlue, in: .rect(cornerRadius: 11)) - .accessibilityHidden(true) - } - .padding(.vertical, 5) - } - } - } - if let location { - PhotoGallery(store: store, target: .location(location.id)) - } if !store.locationsReady && error == nil { ProgressView("正在加载位置") } @@ -115,7 +78,7 @@ private struct LocationContents: View { LocationLevelHeading(level: LocationLevel(depth: (location?.levelDepth ?? 0) + 1)) } if let location { - ItemsSection(store: store, results: items, location: location.id) + ItemsSection(store: store, results: items, location: location.id, onIntake: { onIntake(location) }) if store.canWrite { Button("删除位置", role: .destructive) { confirmingDelete = true }.disabled(busy) } } if let error { @@ -167,6 +130,38 @@ private struct LocationContents: View { } message: { Text("请先清空物品和子位置。删除这个位置时,里面的照片会一起删除。") } } + private func locationOverview(_ location: Place) -> some View { + VStack(alignment: .leading, spacing: 12) { + HStack(spacing: 12) { + Button { editingAppearance = true } label: { + LocationMark(store: store, place: location, size: 44) + .overlay(alignment: .bottomTrailing) { + Image(systemName: "pencil") + .font(.system(size: 9, weight: .semibold)) + .foregroundStyle(.primary) + .frame(width: 18, height: 18) + .background(Color(uiColor: .secondarySystemGroupedBackground), in: Circle()) + .overlay { Circle().strokeBorder(.quaternary, lineWidth: 1) } + .offset(x: 2, y: 2) + } + .contentShape(Rectangle()) + .accessibilityHidden(true) + } + .buttonStyle(.borderless) + .accessibilityLabel("编辑位置图标") + .accessibilityHint("选择图标或照片缩略图") + .disabled(busy) + VStack(alignment: .leading, spacing: 5) { + Text(location.path).font(.subheadline) + LocationLevelBadge(level: LocationLevel(depth: location.levelDepth)) + } + } + Divider() + PhotoGallery(store: store, target: .location(location.id), embedded: true) + } + .padding(.vertical, 5) + } + private func reloadLocations(refresh: Bool = false) async { do { try await store.refreshLocations(refresh: refresh); error = nil } catch is CancellationError {} diff --git a/docs/product/ios-experience.md b/docs/product/ios-experience.md index c9230a1..90d1da7 100644 --- a/docs/product/ios-experience.md +++ b/docs/product/ios-experience.md @@ -28,9 +28,9 @@ 空间内用小徽标标明层级。房间和区域用金色「一级」,家具和收纳区用银色「二级」,抽屉和容器用铜色「三级」。第四级起统一用灰色「内层」。位置列表、详情、图标编辑和位置选择使用同一套级别标记。设备字号较大时,图标选择器会减少每行的个数。 -打开任一级位置,点「图标与缩略图」可选择自己的图标。有详情照片时,也可以挑其中一张当作列表小图。右上角「编辑」可以改名称和空间默认图标。团队成员可各自选择显示样式。 +打开任一级位置,点带铅笔标记的图标可选择自己的显示样式。有位置照片时,也可以挑其中一张当作列表小图。右上角「编辑」可以改名称和空间默认图标。 -位置详情的「详情照片」支持拍照、相册和裁剪。删掉用作个人图标的那张照片后,位置会恢复空间默认图标。删除位置时,其照片随位置清理。 +位置照片和路径放在同一张概览卡里,支持拍照、相册和裁剪。删掉用作个人图标的那张照片后,位置会恢复空间默认图标。删除位置时,其照片随位置清理。概览下方先列子位置,再列「这里的物品」。「在这里录入」位于物品区顶部,表单会带上当前位置。 添加或编辑物品时,可以填写可选的购入单价、选择绿色物品图标、从相册选照片并裁剪。点「保存」后先保存物品,再上传照片。照片上传失败时,可以点「重试上传」,也可以稍后从详情添加。没有封面照片时,物品列表显示所选物品图标。已有照片可在物品详情继续查看、添加和删除。 @@ -54,4 +54,6 @@ 物品建好后默认只在空间里。空间所有者可从物品详情的「分享到社区」或社区右上角「发布物品」选一件,单独写标题和使用感受。社区首版分享文字,已经上传到家里的照片仍按空间权限查看。 +当前空间没有物品时,可以在选择页点「录入物品」。智能录入或手动添加成功后回到选择页,再选要分享的物品。搜索无结果时可以清除关键词,返回完整列表。 + 登录后可浏览、搜索公开分享、点星评分及发表评论。点帖子或评论里的头像和昵称,可查看该用户的社区主页及公开物品。已公开的物品可从自己的物品详情进入社区评论和评分。个人短评保存在自己的物品评价中。撤回后,帖子及其评分、评论从社区删除。物品仍在空间。家里的一件物品需要管理存放位置时,可建立相应的位置节点。例如用来放物品的架子,先按位置管理。首版没有双重身份和物品转位置操作。