Skip to content

Commit

Permalink
Simplify features for Lite
Browse files Browse the repository at this point in the history
  • Loading branch information
livid committed Jun 24, 2023
1 parent d15b246 commit c5ee602
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 92 deletions.
6 changes: 3 additions & 3 deletions Planet/Quick Share/PlanetQuickShareView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -119,7 +119,7 @@ struct PlanetQuickShareView: View {
Button {
dismissAction()
} label: {
Text("Close")
Text("Cancel")
}
.keyboardShortcut(.escape, modifiers: [])
Spacer()
Expand Down
175 changes: 96 additions & 79 deletions Planet/Views/My/MyPlanetEditView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -353,90 +412,46 @@ 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 {
Text("Basic Info")
}
.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) {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Planet/versioning.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 1419
CURRENT_PROJECT_VERSION = 1420
43 changes: 34 additions & 9 deletions PlanetLite/AppWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AppWindowController: NSWindowController {
}
}
}

required init?(coder: NSCoder) {
fatalError()
}
Expand Down Expand Up @@ -65,6 +65,8 @@ class AppWindowController: NSWindowController {
newArticle()
case .showInfoItem:
showPlanetInfo()
case .shareItem:
sharePlanet()
default:
break
}
Expand All @@ -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
}
}


Expand All @@ -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
}
Expand Down Expand Up @@ -155,46 +166,59 @@ 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,
.sidebarItem,
.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<NSToolbarItem.Identifier> {
return [
.sidebarItem,
.sidebarSeparatorItem,
.showInfoItem,
.addItem
.addItem,
.shareItem
]
}

func toolbarDidRemoveItem(_ notification: Notification) {
setupToolbar()
}

func toolbarSelectableItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
return []
}
Expand All @@ -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")
}

0 comments on commit c5ee602

Please sign in to comment.