feat(ios): 整理位置详情和社区录入入口
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
a31c66e3e9
commit
9181ac766d
|
|
@ -117,7 +117,7 @@
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 19;
|
CURRENT_PROJECT_VERSION = 20;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ATLAS_API_BASE_URL = "https://api-atlas.tutudog.com";
|
ATLAS_API_BASE_URL = "https://api-atlas.tutudog.com";
|
||||||
|
|
@ -138,7 +138,7 @@
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 19;
|
CURRENT_PROJECT_VERSION = 20;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ATLAS_API_BASE_URL = "https://api-atlas.tutudog.com";
|
ATLAS_API_BASE_URL = "https://api-atlas.tutudog.com";
|
||||||
|
|
|
||||||
|
|
@ -151,9 +151,17 @@ struct CommunityFeedView: View {
|
||||||
if displayedTerm != term && error == nil {
|
if displayedTerm != term && error == nil {
|
||||||
ProgressView("正在加载分享")
|
ProgressView("正在加载分享")
|
||||||
} else if posts.isEmpty && error == nil {
|
} else if posts.isEmpty && error == nil {
|
||||||
ContentUnavailableView(term.isEmpty ? "还没有分享" : "没找到相关分享",
|
ContentUnavailableView {
|
||||||
systemImage: "bubble.left.and.bubble.right",
|
Label(term.isEmpty ? "还没有分享" : "没找到相关分享", systemImage: "bubble.left.and.bubble.right")
|
||||||
description: Text(emptyDescription))
|
} 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
|
ForEach(displayedTerm == term ? posts : []) { post in
|
||||||
VStack(alignment: .leading, spacing: 10) {
|
VStack(alignment: .leading, spacing: 10) {
|
||||||
|
|
@ -194,7 +202,7 @@ struct CommunityFeedView: View {
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.searchable(text: $query, prompt: publicAuthor == nil ? "搜公开物品和分享" : "搜此人的公开物品")
|
.searchable(text: $query, prompt: publicAuthor == nil ? "搜公开物品和分享" : "搜此人的公开物品")
|
||||||
.toolbar {
|
.toolbar {
|
||||||
if let source, source.space.role == "OWNER" && !mine {
|
if canPublish {
|
||||||
ToolbarItem(placement: .topBarTrailing) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
Button { showingChooser = true } label: { Label("发布物品", systemImage: "square.and.pencil") }
|
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 {
|
private var emptyDescription: String {
|
||||||
|
if !term.isEmpty { return "试试其他关键词。" }
|
||||||
if mine { return "你公开的物品会显示在这里。" }
|
if mine { return "你公开的物品会显示在这里。" }
|
||||||
if publicAuthor != nil { return "这个主页会显示对方的公开分享。" }
|
if publicAuthor != nil { return "这个主页会显示对方的公开分享。" }
|
||||||
return "可以搜索公开物品,或发布自己的使用感受。"
|
return "可以搜索公开物品,或发布自己的使用感受。"
|
||||||
|
|
@ -488,14 +499,29 @@ private struct CommunityItemChooser: View {
|
||||||
@State private var query = ""
|
@State private var query = ""
|
||||||
@State private var items: [Item] = []
|
@State private var items: [Item] = []
|
||||||
@State private var selected: Item?
|
@State private var selected: Item?
|
||||||
|
@State private var showingIntake = false
|
||||||
@State private var loading = true
|
@State private var loading = true
|
||||||
@State private var hasMore = false
|
@State private var hasMore = false
|
||||||
@State private var error: String?
|
@State private var error: String?
|
||||||
@State private var generation = UUID()
|
@State private var generation = UUID()
|
||||||
@State private var revision = 0
|
@State private var revision = 0
|
||||||
|
|
||||||
|
private var term: String { query.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
|
if showingIntake {
|
||||||
|
IntakeView(store: store, onReturnToChooser: {
|
||||||
|
loading = true
|
||||||
|
showingIntake = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
chooser
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var chooser: some View {
|
||||||
List {
|
List {
|
||||||
if loading && items.isEmpty { ProgressView("正在查找物品") }
|
if loading && items.isEmpty { ProgressView("正在查找物品") }
|
||||||
ForEach(items) { item in
|
ForEach(items) { item in
|
||||||
|
|
@ -513,7 +539,7 @@ private struct CommunityItemChooser: View {
|
||||||
Text(error).font(.footnote).foregroundStyle(.red)
|
Text(error).font(.footnote).foregroundStyle(.red)
|
||||||
Button("重新加载") { revision += 1 }
|
Button("重新加载") { revision += 1 }
|
||||||
} else if !loading && items.isEmpty {
|
} else if !loading && items.isEmpty {
|
||||||
ContentUnavailableView("没有可选物品", systemImage: "archivebox")
|
emptyState
|
||||||
} else if hasMore {
|
} else if hasMore {
|
||||||
Button("更多物品") { Task { await load(append: true) } }.disabled(loading)
|
Button("更多物品") { Task { await load(append: true) } }.disabled(loading)
|
||||||
}
|
}
|
||||||
|
|
@ -524,7 +550,7 @@ private struct CommunityItemChooser: View {
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .cancellationAction) { Button("完成") { dismiss() } }
|
ToolbarItem(placement: .cancellationAction) { Button("完成") { dismiss() } }
|
||||||
}
|
}
|
||||||
.task(id: "\(revision):\(query)") { await load() }
|
.task(id: "\(revision):\(term)") { await load() }
|
||||||
.sheet(item: $selected) { item in
|
.sheet(item: $selected) { item in
|
||||||
PublicationEditor(store: store, item: item) {
|
PublicationEditor(store: store, item: item) {
|
||||||
revision += 1
|
revision += 1
|
||||||
|
|
@ -532,22 +558,35 @@ private struct CommunityItemChooser: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func load(append: Bool = false) async {
|
private func load(append: Bool = false) async {
|
||||||
guard !append || !loading else { return }
|
guard !append || !loading else { return }
|
||||||
let id = UUID()
|
let id = UUID()
|
||||||
generation = id
|
generation = id
|
||||||
let term = query
|
let requested = term
|
||||||
if !append { items = []; hasMore = false }
|
if !append { items = []; hasMore = false }
|
||||||
loading = true
|
loading = true
|
||||||
error = nil
|
error = nil
|
||||||
defer { if generation == id { loading = false } }
|
defer { if generation == id { loading = false } }
|
||||||
do {
|
do {
|
||||||
if !append && !term.isEmpty { try await Task.sleep(for: .milliseconds(250)) }
|
if !append && !requested.isEmpty { try await Task.sleep(for: .milliseconds(250)) }
|
||||||
let page = try await store.search(term, favorites: false, offset: append ? items.count : 0)
|
let page = try await store.search(requested, favorites: false, offset: append ? items.count : 0)
|
||||||
try Task.checkCancellation()
|
try Task.checkCancellation()
|
||||||
guard generation == id, query == term else { return }
|
guard generation == id, term == requested else { return }
|
||||||
items += page
|
items += page
|
||||||
hasMore = page.count == 50
|
hasMore = page.count == 50
|
||||||
} catch where !Task.isCancelled && generation == id { self.error = error.localizedDescription }
|
} catch where !Task.isCancelled && generation == id { self.error = error.localizedDescription }
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ struct ItemEditor: View {
|
||||||
let store: InventoryStore
|
let store: InventoryStore
|
||||||
var initialLocation: UUID? = nil
|
var initialLocation: UUID? = nil
|
||||||
var existing: Item? = nil
|
var existing: Item? = nil
|
||||||
|
var onClose: ((Bool) -> Void)? = nil
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
@FocusState private var focus: Field?
|
@FocusState private var focus: Field?
|
||||||
@State private var name = ""
|
@State private var name = ""
|
||||||
|
|
@ -40,12 +41,53 @@ struct ItemEditor: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
Group {
|
||||||
|
if onClose == nil { NavigationStack { form } }
|
||||||
|
else { form }
|
||||||
|
}
|
||||||
|
.interactiveDismissDisabled(busy)
|
||||||
|
.task {
|
||||||
|
guard !initialized else { return }
|
||||||
|
initialized = true
|
||||||
|
name = existing?.name ?? ""
|
||||||
|
aliases = existing?.aliases.joined(separator: "、") ?? ""
|
||||||
|
quantity = existing?.quantity ?? 1
|
||||||
|
notes = existing?.notes ?? ""
|
||||||
|
price = existing?.priceCents.map(PurchasePrice.input) ?? ""
|
||||||
|
icon = InventorySymbol.item(existing?.icon).id
|
||||||
|
locationID = existing?.locationId ?? initialLocation
|
||||||
|
do { if existing == nil { try await store.refreshLocations() } }
|
||||||
|
catch { self.error = error.localizedDescription }
|
||||||
|
loadingLocations = false
|
||||||
|
}
|
||||||
|
.task(id: photoSelection) {
|
||||||
|
guard let selection = photoSelection else { return }
|
||||||
|
loadingPhoto = true
|
||||||
|
defer {
|
||||||
|
if photoSelection == selection {
|
||||||
|
loadingPhoto = false
|
||||||
|
photoSelection = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
guard let source = try await selection.loadTransferable(type: CropSource.self) else {
|
||||||
|
throw AtlasError("这张照片无法打开,请重新选择。")
|
||||||
|
}
|
||||||
|
try Task.checkCancellation()
|
||||||
|
focus = nil
|
||||||
|
error = nil
|
||||||
|
crop = source
|
||||||
|
} catch where !Task.isCancelled { self.error = error.localizedDescription }
|
||||||
|
catch {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var form: some View {
|
||||||
Form {
|
Form {
|
||||||
if savedItem != nil {
|
if savedItem != nil {
|
||||||
Section {
|
Section {
|
||||||
Text("物品已保存,照片可以重试上传。")
|
Text("物品已保存,照片可以重试上传。")
|
||||||
Button("稍后添加照片") { dismiss() }.disabled(busy)
|
Button("稍后添加照片", action: close).disabled(busy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Section("物品") {
|
Section("物品") {
|
||||||
|
|
@ -82,7 +124,7 @@ struct ItemEditor: View {
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .cancellationAction) {
|
ToolbarItem(placement: .cancellationAction) {
|
||||||
Button(savedItem == nil ? "取消" : "关闭") { dismiss() }.disabled(busy)
|
Button(savedItem == nil ? "取消" : "关闭", action: close).disabled(busy)
|
||||||
}
|
}
|
||||||
ToolbarItem(placement: .confirmationAction) {
|
ToolbarItem(placement: .confirmationAction) {
|
||||||
Button(savedItem == nil ? "保存" : "重试上传") { focus = nil; Task { await save() } }
|
Button(savedItem == nil ? "保存" : "重试上传") { focus = nil; Task { await save() } }
|
||||||
|
|
@ -99,42 +141,6 @@ struct ItemEditor: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.interactiveDismissDisabled(busy)
|
|
||||||
.task {
|
|
||||||
guard !initialized else { return }
|
|
||||||
initialized = true
|
|
||||||
name = existing?.name ?? ""
|
|
||||||
aliases = existing?.aliases.joined(separator: "、") ?? ""
|
|
||||||
quantity = existing?.quantity ?? 1
|
|
||||||
notes = existing?.notes ?? ""
|
|
||||||
price = existing?.priceCents.map(PurchasePrice.input) ?? ""
|
|
||||||
icon = InventorySymbol.item(existing?.icon).id
|
|
||||||
locationID = existing?.locationId ?? initialLocation
|
|
||||||
do { if existing == nil { try await store.refreshLocations() } }
|
|
||||||
catch { self.error = error.localizedDescription }
|
|
||||||
loadingLocations = false
|
|
||||||
}
|
|
||||||
.task(id: photoSelection) {
|
|
||||||
guard let selection = photoSelection else { return }
|
|
||||||
loadingPhoto = true
|
|
||||||
defer {
|
|
||||||
if photoSelection == selection {
|
|
||||||
loadingPhoto = false
|
|
||||||
photoSelection = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
do {
|
|
||||||
guard let source = try await selection.loadTransferable(type: CropSource.self) else {
|
|
||||||
throw AtlasError("这张照片无法打开,请重新选择。")
|
|
||||||
}
|
|
||||||
try Task.checkCancellation()
|
|
||||||
focus = nil
|
|
||||||
error = nil
|
|
||||||
crop = source
|
|
||||||
} catch where !Task.isCancelled { self.error = error.localizedDescription }
|
|
||||||
catch {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private var photoSection: some View {
|
private var photoSection: some View {
|
||||||
let pickerTitle = photo == nil ? "选择照片" : "更换待上传照片"
|
let pickerTitle = photo == nil ? "选择照片" : "更换待上传照片"
|
||||||
|
|
@ -182,9 +188,14 @@ struct ItemEditor: View {
|
||||||
savedItem = item
|
savedItem = item
|
||||||
}
|
}
|
||||||
if let photo { try await store.upload(photo, target: .item(item.id), idempotencyKey: photoKey) }
|
if let photo { try await store.upload(photo, target: .item(item.id), idempotencyKey: photoKey) }
|
||||||
dismiss()
|
close()
|
||||||
} catch { self.error = error.localizedDescription }
|
} catch { self.error = error.localizedDescription }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func close() {
|
||||||
|
if let onClose { onClose(savedItem != nil) }
|
||||||
|
else { dismiss() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MoveEditor: View {
|
struct MoveEditor: View {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import SwiftUI
|
||||||
struct IntakeView: View {
|
struct IntakeView: View {
|
||||||
let store: InventoryStore
|
let store: InventoryStore
|
||||||
var initialLocation: Place? = nil
|
var initialLocation: Place? = nil
|
||||||
|
var onReturnToChooser: (() -> Void)? = nil
|
||||||
@Environment(\.scenePhase) private var scenePhase
|
@Environment(\.scenePhase) private var scenePhase
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
@AppStorage("atlas.voice.recording-mode") private var recordingMode: RecordingMode = .tap
|
@AppStorage("atlas.voice.recording-mode") private var recordingMode: RecordingMode = .tap
|
||||||
|
|
@ -43,6 +44,23 @@ struct IntakeView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some 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
|
ScrollViewReader { scroll in
|
||||||
ScrollView {
|
ScrollView {
|
||||||
VStack(alignment: .leading, spacing: 14) {
|
VStack(alignment: .leading, spacing: 14) {
|
||||||
|
|
@ -75,7 +93,11 @@ struct IntakeView: View {
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .cancellationAction) {
|
ToolbarItem(placement: .cancellationAction) {
|
||||||
Button("关闭") { dismiss() }.disabled(busy)
|
Button(onReturnToChooser == nil ? "关闭" : "返回选择") {
|
||||||
|
if let onReturnToChooser { onReturnToChooser() }
|
||||||
|
else { dismiss() }
|
||||||
|
}
|
||||||
|
.disabled(busy)
|
||||||
}
|
}
|
||||||
ToolbarItem(placement: .topBarTrailing) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
Button { showingHelp = true } label: { Label("录入说明", systemImage: "questionmark.circle") }
|
Button { showingHelp = true } label: { Label("录入说明", systemImage: "questionmark.circle") }
|
||||||
|
|
@ -95,7 +117,6 @@ struct IntakeView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.sheet(isPresented: $showingHelp) { help }
|
.sheet(isPresented: $showingHelp) { help }
|
||||||
.sheet(isPresented: $showingAdd) { ItemEditor(store: store, initialLocation: initialLocation?.id) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var smartCard: some View {
|
private var smartCard: some View {
|
||||||
|
|
@ -387,6 +408,7 @@ struct IntakeView: View {
|
||||||
operation = status
|
operation = status
|
||||||
if status.status == "COMPLETED" {
|
if status.status == "COMPLETED" {
|
||||||
store.changed(inventorySummaryChanged: true)
|
store.changed(inventorySummaryChanged: true)
|
||||||
|
onReturnToChooser?()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ["FAILED", "REJECTED", "NEEDS_REVIEW"].contains(status.status) { return }
|
if ["FAILED", "REJECTED", "NEEDS_REVIEW"].contains(status.status) { return }
|
||||||
|
|
|
||||||
|
|
@ -226,11 +226,23 @@ struct ItemsSection: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Section {
|
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("加载中") }
|
if results.error == nil && (results.loading || results.displayedQuery != input) { ProgressView("加载中") }
|
||||||
else if results.rows.isEmpty && results.error == nil {
|
else if results.rows.isEmpty && results.error == nil {
|
||||||
|
if location != nil {
|
||||||
|
Label("这个位置还没有物品", systemImage: "shippingbox")
|
||||||
|
.font(.subheadline).foregroundStyle(.secondary)
|
||||||
|
} else {
|
||||||
ContentUnavailableView(emptyTitle, systemImage: favorites ? "star" : "archivebox",
|
ContentUnavailableView(emptyTitle, systemImage: favorites ? "star" : "archivebox",
|
||||||
description: Text(emptyDescription))
|
description: Text(emptyDescription))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ForEach(results.displayedQuery == input ? results.rows : []) { item in
|
ForEach(results.displayedQuery == input ? results.rows : []) { item in
|
||||||
NavigationLink { ItemDetailView(store: store, itemID: item.id, summary: item) } label: {
|
NavigationLink { ItemDetailView(store: store, itemID: item.id, summary: item) } label: {
|
||||||
HStack(spacing: 12) {
|
HStack(spacing: 12) {
|
||||||
|
|
@ -262,6 +274,8 @@ struct ItemsSection: View {
|
||||||
results.displayedQuery == input, results.rows.isEmpty, results.error == nil {
|
results.displayedQuery == input, results.rows.isEmpty, results.error == nil {
|
||||||
Button(action: onIntake) { Label("添加物品", systemImage: "plus") }
|
Button(action: onIntake) { Label("添加物品", systemImage: "plus") }
|
||||||
}
|
}
|
||||||
|
} header: {
|
||||||
|
if location != nil { Text("这里的物品") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ struct PhotoImage: View {
|
||||||
struct PhotoGallery: View {
|
struct PhotoGallery: View {
|
||||||
let store: InventoryStore
|
let store: InventoryStore
|
||||||
let target: PhotoTarget
|
let target: PhotoTarget
|
||||||
|
let embedded: Bool
|
||||||
@State private var photos: [Photo]?
|
@State private var photos: [Photo]?
|
||||||
@State private var picker: PhotosPickerItem?
|
@State private var picker: PhotosPickerItem?
|
||||||
@State private var crop: CropSource?
|
@State private var crop: CropSource?
|
||||||
|
|
@ -72,15 +73,21 @@ struct PhotoGallery: View {
|
||||||
@State private var busy = false
|
@State private var busy = false
|
||||||
@State private var error: String?
|
@State private var error: String?
|
||||||
|
|
||||||
init(store: InventoryStore, target: PhotoTarget) {
|
init(store: InventoryStore, target: PhotoTarget, embedded: Bool = false) {
|
||||||
self.store = store
|
self.store = store
|
||||||
self.target = target
|
self.target = target
|
||||||
|
self.embedded = embedded
|
||||||
_photos = State(initialValue: store.account.cached(store.root + target.path))
|
_photos = State(initialValue: store.account.cached(store.root + target.path))
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Section(target.title) {
|
if embedded { gallery }
|
||||||
VStack(alignment: .leading, spacing: 14) {
|
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 {
|
if let photos, !photos.isEmpty {
|
||||||
ScrollView(.horizontal) {
|
ScrollView(.horizontal) {
|
||||||
HStack {
|
HStack {
|
||||||
|
|
@ -160,7 +167,6 @@ struct PhotoGallery: View {
|
||||||
PhotoPreview(store: store, target: target, photo: photo)
|
PhotoPreview(store: store, target: target, photo: photo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private func openCamera() async {
|
private func openCamera() async {
|
||||||
guard !busy, UIImagePickerController.isSourceTypeAvailable(.camera) else { return }
|
guard !busy, UIImagePickerController.isSourceTypeAvailable(.camera) else { return }
|
||||||
|
|
|
||||||
|
|
@ -54,46 +54,9 @@ private struct LocationContents: View {
|
||||||
List {
|
List {
|
||||||
if let location {
|
if let location {
|
||||||
Section {
|
Section {
|
||||||
HStack(spacing: 11) {
|
locationOverview(location)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 {
|
if !store.locationsReady && error == nil {
|
||||||
ProgressView("正在加载位置")
|
ProgressView("正在加载位置")
|
||||||
}
|
}
|
||||||
|
|
@ -115,7 +78,7 @@ private struct LocationContents: View {
|
||||||
LocationLevelHeading(level: LocationLevel(depth: (location?.levelDepth ?? 0) + 1))
|
LocationLevelHeading(level: LocationLevel(depth: (location?.levelDepth ?? 0) + 1))
|
||||||
}
|
}
|
||||||
if let location {
|
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 store.canWrite { Button("删除位置", role: .destructive) { confirmingDelete = true }.disabled(busy) }
|
||||||
}
|
}
|
||||||
if let error {
|
if let error {
|
||||||
|
|
@ -167,6 +130,38 @@ private struct LocationContents: View {
|
||||||
} message: { Text("请先清空物品和子位置。删除这个位置时,里面的照片会一起删除。") }
|
} 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 {
|
private func reloadLocations(refresh: Bool = false) async {
|
||||||
do { try await store.refreshLocations(refresh: refresh); error = nil }
|
do { try await store.refreshLocations(refresh: refresh); error = nil }
|
||||||
catch is CancellationError {}
|
catch is CancellationError {}
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@
|
||||||
|
|
||||||
空间内用小徽标标明层级。房间和区域用金色「一级」,家具和收纳区用银色「二级」,抽屉和容器用铜色「三级」。第四级起统一用灰色「内层」。位置列表、详情、图标编辑和位置选择使用同一套级别标记。设备字号较大时,图标选择器会减少每行的个数。
|
空间内用小徽标标明层级。房间和区域用金色「一级」,家具和收纳区用银色「二级」,抽屉和容器用铜色「三级」。第四级起统一用灰色「内层」。位置列表、详情、图标编辑和位置选择使用同一套级别标记。设备字号较大时,图标选择器会减少每行的个数。
|
||||||
|
|
||||||
打开任一级位置,点「图标与缩略图」可选择自己的图标。有详情照片时,也可以挑其中一张当作列表小图。右上角「编辑」可以改名称和空间默认图标。团队成员可各自选择显示样式。
|
打开任一级位置,点带铅笔标记的图标可选择自己的显示样式。有位置照片时,也可以挑其中一张当作列表小图。右上角「编辑」可以改名称和空间默认图标。
|
||||||
|
|
||||||
位置详情的「详情照片」支持拍照、相册和裁剪。删掉用作个人图标的那张照片后,位置会恢复空间默认图标。删除位置时,其照片随位置清理。
|
位置照片和路径放在同一张概览卡里,支持拍照、相册和裁剪。删掉用作个人图标的那张照片后,位置会恢复空间默认图标。删除位置时,其照片随位置清理。概览下方先列子位置,再列「这里的物品」。「在这里录入」位于物品区顶部,表单会带上当前位置。
|
||||||
|
|
||||||
添加或编辑物品时,可以填写可选的购入单价、选择绿色物品图标、从相册选照片并裁剪。点「保存」后先保存物品,再上传照片。照片上传失败时,可以点「重试上传」,也可以稍后从详情添加。没有封面照片时,物品列表显示所选物品图标。已有照片可在物品详情继续查看、添加和删除。
|
添加或编辑物品时,可以填写可选的购入单价、选择绿色物品图标、从相册选照片并裁剪。点「保存」后先保存物品,再上传照片。照片上传失败时,可以点「重试上传」,也可以稍后从详情添加。没有封面照片时,物品列表显示所选物品图标。已有照片可在物品详情继续查看、添加和删除。
|
||||||
|
|
||||||
|
|
@ -54,4 +54,6 @@
|
||||||
|
|
||||||
物品建好后默认只在空间里。空间所有者可从物品详情的「分享到社区」或社区右上角「发布物品」选一件,单独写标题和使用感受。社区首版分享文字,已经上传到家里的照片仍按空间权限查看。
|
物品建好后默认只在空间里。空间所有者可从物品详情的「分享到社区」或社区右上角「发布物品」选一件,单独写标题和使用感受。社区首版分享文字,已经上传到家里的照片仍按空间权限查看。
|
||||||
|
|
||||||
|
当前空间没有物品时,可以在选择页点「录入物品」。智能录入或手动添加成功后回到选择页,再选要分享的物品。搜索无结果时可以清除关键词,返回完整列表。
|
||||||
|
|
||||||
登录后可浏览、搜索公开分享、点星评分及发表评论。点帖子或评论里的头像和昵称,可查看该用户的社区主页及公开物品。已公开的物品可从自己的物品详情进入社区评论和评分。个人短评保存在自己的物品评价中。撤回后,帖子及其评分、评论从社区删除。物品仍在空间。家里的一件物品需要管理存放位置时,可建立相应的位置节点。例如用来放物品的架子,先按位置管理。首版没有双重身份和物品转位置操作。
|
登录后可浏览、搜索公开分享、点星评分及发表评论。点帖子或评论里的头像和昵称,可查看该用户的社区主页及公开物品。已公开的物品可从自己的物品详情进入社区评论和评分。个人短评保存在自己的物品评价中。撤回后,帖子及其评分、评论从社区删除。物品仍在空间。家里的一件物品需要管理存放位置时,可建立相应的位置节点。例如用来放物品的架子,先按位置管理。首版没有双重身份和物品转位置操作。
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue