diff --git a/Planet/Quick Share/PlanetQuickShareView.swift b/Planet/Quick Share/PlanetQuickShareView.swift index 176dd0fc..11d70647 100644 --- a/Planet/Quick Share/PlanetQuickShareView.swift +++ b/Planet/Quick Share/PlanetQuickShareView.swift @@ -60,13 +60,13 @@ struct PlanetQuickShareView: View { private func attachmentSection() -> some View { if viewModel.fileURLs.count == 0 { VStack { - Text("No Attachments.") - .foregroundColor(.secondary) Button { addAttachmentsAction() } label: { Text("Add Attachments...") } + Text("Or drag and drop images here.") + .foregroundColor(.secondary) } } else { GeometryReader { g in @@ -119,7 +119,7 @@ struct PlanetQuickShareView: View { Button { dismissAction() } label: { - Text("Close") + Text("Cancel") } .keyboardShortcut(.escape, modifiers: []) Spacer() diff --git a/Planet/Views/My/MyPlanetEditView.swift b/Planet/Views/My/MyPlanetEditView.swift index 50a69775..7e5f2c8d 100644 --- a/Planet/Views/My/MyPlanetEditView.swift +++ b/Planet/Views/My/MyPlanetEditView.swift @@ -80,6 +80,63 @@ struct MyPlanetEditView: View { _filebaseAPIToken = State(wrappedValue: planet.filebaseAPIToken ?? "") } + @ViewBuilder + private func analyticsTab() -> some View { + VStack(spacing: PlanetUI.CONTROL_ROW_SPACING) { + HStack { + HStack { + Spacer() + }.frame(width: CONTROL_CAPTION_WIDTH + 10) + Toggle( + "Enable Plausible for Traffic Analytics", + isOn: $plausibleEnabled + ) + .toggleStyle(.checkbox) + .frame(alignment: .leading) + Spacer() + } + + HStack { + HStack { + Text("Domain") + Spacer() + } + .frame(width: CONTROL_CAPTION_WIDTH) + + TextField("", text: $plausibleDomain) + .textFieldStyle(.roundedBorder) + } + + HStack { + HStack { + Text("API Key") + Spacer() + } + .frame(width: CONTROL_CAPTION_WIDTH) + + SecureField("", text: $plausibleAPIKey) + .textFieldStyle(.roundedBorder) + } + + HStack { + HStack { + Text("API Server") + Spacer() + } + .frame(width: CONTROL_CAPTION_WIDTH) + + TextField("", text: $plausibleAPIServer) + .textFieldStyle(.roundedBorder) + } + + } + .padding(16) + .tabItem { + Text("Analytics") + } + .tag("analytics") + } + @ViewBuilder private func pinnableView() -> some View { HStack { @@ -118,23 +175,25 @@ struct MyPlanetEditView: View { if let cid = pinnablePinCID { if cid == planet.lastPublishedCID { Label("Pinned", systemImage: "checkmark.circle.fill") - } else { + } + else { Label("Pinning", systemImage: "ellipsis") } - } else { + } + else { Label("Error", systemImage: "exclamationmark.triangle.fill") } } Spacer() - } else { + } + else { ProgressView() .progressViewStyle(.linear) } }.onAppear { Task { - if let status = await planet.checkPinnablePinStatus() - { + if let status = await planet.checkPinnablePinStatus() { pinnablePinStatus = status if let cid = status.last_known_cid { pinnablePinCID = cid @@ -353,30 +412,36 @@ struct MyPlanetEditView: View { ) } - HStack { + if planetStore.app == .planet { HStack { - Text("Author Name") - Spacer() + HStack { + Text("Author Name") + Spacer() + } + .frame(width: CONTROL_CAPTION_WIDTH) + + TextField("", text: $authorName) + .textFieldStyle(.roundedBorder) } - .frame(width: CONTROL_CAPTION_WIDTH) - - TextField("", text: $authorName) - .textFieldStyle(.roundedBorder) } - Picker(selection: $templateName) { - ForEach(TemplateStore.shared.templates) { template in - Text(template.name) - .tag(template.name) - } - } label: { - HStack { - Text("Template") - Spacer() + if planetStore.app == .planet + || ($templateName.wrappedValue != "Croptop" && planetStore.app == .lite) + { + Picker(selection: $templateName) { + ForEach(TemplateStore.shared.templates) { template in + Text(template.name) + .tag(template.name) + } + } label: { + HStack { + Text("Template") + Spacer() + } + .frame(width: CONTROL_CAPTION_WIDTH) } - .frame(width: CONTROL_CAPTION_WIDTH) + .pickerStyle(.menu) } - .pickerStyle(.menu) } .padding(16) .tabItem { @@ -384,59 +449,9 @@ struct MyPlanetEditView: View { } .tag("basic") - VStack(spacing: PlanetUI.CONTROL_ROW_SPACING) { - HStack { - HStack { - Spacer() - }.frame(width: CONTROL_CAPTION_WIDTH + 10) - Toggle( - "Enable Plausible for Traffic Analytics", - isOn: $plausibleEnabled - ) - .toggleStyle(.checkbox) - .frame(alignment: .leading) - Spacer() - } - - HStack { - HStack { - Text("Domain") - Spacer() - } - .frame(width: CONTROL_CAPTION_WIDTH) - - TextField("", text: $plausibleDomain) - .textFieldStyle(.roundedBorder) - } - - HStack { - HStack { - Text("API Key") - Spacer() - } - .frame(width: CONTROL_CAPTION_WIDTH) - - SecureField("", text: $plausibleAPIKey) - .textFieldStyle(.roundedBorder) - } - - HStack { - HStack { - Text("API Server") - Spacer() - } - .frame(width: CONTROL_CAPTION_WIDTH) - - TextField("", text: $plausibleAPIServer) - .textFieldStyle(.roundedBorder) - } - + if planetStore.app == .planet { + analyticsTab() } - .padding(16) - .tabItem { - Text("Analytics") - } - .tag("analytics") VStack(spacing: PlanetUI.CONTROL_ROW_SPACING) { HStack(spacing: PlanetUI.CONTROL_ITEM_GAP) { @@ -492,11 +507,13 @@ struct MyPlanetEditView: View { VStack(spacing: PlanetUI.CONTROL_ROW_SPACING) { pinnableView() - Divider() - .padding(.top, 6) - .padding(.bottom, 6) + if planetStore.app == .planet { + Divider() + .padding(.top, 6) + .padding(.bottom, 6) - filebaseView() + filebaseView() + } } .padding(16) .tabItem { diff --git a/Planet/versioning.xcconfig b/Planet/versioning.xcconfig index ac1997c1..58d11067 100644 --- a/Planet/versioning.xcconfig +++ b/Planet/versioning.xcconfig @@ -1 +1 @@ -CURRENT_PROJECT_VERSION = 1419 +CURRENT_PROJECT_VERSION = 1420 diff --git a/PlanetLite/AppWindowController.swift b/PlanetLite/AppWindowController.swift index 3c095521..d4e3e0b4 100644 --- a/PlanetLite/AppWindowController.swift +++ b/PlanetLite/AppWindowController.swift @@ -31,7 +31,7 @@ class AppWindowController: NSWindowController { } } } - + required init?(coder: NSCoder) { fatalError() } @@ -65,6 +65,8 @@ class AppWindowController: NSWindowController { newArticle() case .showInfoItem: showPlanetInfo() + case .shareItem: + sharePlanet() default: break } @@ -85,11 +87,15 @@ extension AppWindowController { break } } - + func showPlanetInfo() { guard PlanetStore.shared.isShowingPlanetInfo == false else { return } PlanetStore.shared.isShowingPlanetInfo = true } + + func sharePlanet() { + // TODO: share planet with properly positioned NSSharingServicePicker + } } @@ -108,6 +114,11 @@ extension AppWindowController: NSToolbarItemValidation { return true } return false + case .shareItem: + if case .myPlanet(_) = PlanetStore.shared.selectedView { + return true + } + return false default: return false } @@ -155,11 +166,21 @@ extension AppWindowController: NSToolbarDelegate { item.isBordered = true item.image = NSImage(systemSymbolName: "info.circle", accessibilityDescription: "Show Info") return item + case .shareItem: + let item = NSToolbarItem(itemIdentifier: itemIdentifier) + item.target = self + item.action = #selector(self.toolbarItemAction(_:)) + item.label = "Share" + item.paletteLabel = "Share" + item.toolTip = "Share" + item.isBordered = true + item.image = NSImage(systemSymbolName: "square.and.arrow.up", accessibilityDescription: "Share") + return item default: return nil } } - + func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { return [ .flexibleSpace, @@ -167,34 +188,37 @@ extension AppWindowController: NSToolbarDelegate { .sidebarSeparatorItem, .flexibleSpace, .showInfoItem, - .addItem + .addItem, + .shareItem ] } - + func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { return [ .flexibleSpace, .sidebarItem, .sidebarSeparatorItem, .flexibleSpace, + // .shareItem, .showInfoItem, .addItem ] } - + func toolbarImmovableItemIdentifiers(_ toolbar: NSToolbar) -> Set { return [ .sidebarItem, .sidebarSeparatorItem, .showInfoItem, - .addItem + .addItem, + .shareItem ] } - + func toolbarDidRemoveItem(_ notification: Notification) { setupToolbar() } - + func toolbarSelectableItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { return [] } @@ -212,4 +236,5 @@ extension NSToolbarItem.Identifier { static let sidebarItem = NSToolbarItem.Identifier("PlanetLiteToolbarSidebarItem") static let addItem = NSToolbarItem.Identifier("PlanetLiteToolbarAddItem") static let showInfoItem = NSToolbarItem.Identifier("PlanetLiteToolbarShowInfoItem") + static let shareItem = NSToolbarItem.Identifier("PlanetLiteToolbarShareItem") }