Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions OpenASO.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@
D34D00000000000000000002 /* KeywordResearchHistoryModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34D00000000000000000012 /* KeywordResearchHistoryModelTests.swift */; };
D34E00000000000000000001 /* KeywordResearchModelFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34E00000000000000000011 /* KeywordResearchModelFactory.swift */; };
D34E00000000000000000002 /* KeywordResearchModelFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34E00000000000000000012 /* KeywordResearchModelFactoryTests.swift */; };
D34E00000000000000000003 /* KeywordResearchWorkspaceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34E00000000000000000013 /* KeywordResearchWorkspaceView.swift */; };
D34E00000000000000000004 /* KeywordResearchProjectEditorSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34E00000000000000000014 /* KeywordResearchProjectEditorSheet.swift */; };
D34F00000000000000000002 /* KeywordResearchWorkspaceSelectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34F00000000000000000012 /* KeywordResearchWorkspaceSelectionTests.swift */; };
D20B00000000000000000007 /* Persistence/EstimatedKeywordDifficultyStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20B00000000000000000014 /* Persistence/EstimatedKeywordDifficultyStore.swift */; };
D20B00000000000000000008 /* Persistence/EstimatedKeywordDifficultyStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20B00000000000000000014 /* Persistence/EstimatedKeywordDifficultyStore.swift */; };
D20B00000000000000000009 /* EstimatedKeywordDifficultyStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20B00000000000000000015 /* EstimatedKeywordDifficultyStoreTests.swift */; };
Expand Down Expand Up @@ -435,6 +438,9 @@
D34D00000000000000000012 /* KeywordResearchHistoryModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeywordResearchHistoryModelTests.swift; sourceTree = "<group>"; };
D34E00000000000000000011 /* KeywordResearchModelFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeywordResearchModelFactory.swift; sourceTree = "<group>"; };
D34E00000000000000000012 /* KeywordResearchModelFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeywordResearchModelFactoryTests.swift; sourceTree = "<group>"; };
D34E00000000000000000013 /* KeywordResearchWorkspaceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeywordResearchWorkspaceView.swift; sourceTree = "<group>"; };
D34E00000000000000000014 /* KeywordResearchProjectEditorSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeywordResearchProjectEditorSheet.swift; sourceTree = "<group>"; };
D34F00000000000000000012 /* KeywordResearchWorkspaceSelectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeywordResearchWorkspaceSelectionTests.swift; sourceTree = "<group>"; };
D20B00000000000000000014 /* Persistence/EstimatedKeywordDifficultyStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Persistence/EstimatedKeywordDifficultyStore.swift; sourceTree = "<group>"; };
D20B00000000000000000015 /* EstimatedKeywordDifficultyStoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EstimatedKeywordDifficultyStoreTests.swift; sourceTree = "<group>"; };
A20000000000000000000011 /* KeywordTableCells.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeywordTableCells.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -590,6 +596,7 @@
D34C00000000000000000012 /* KeywordResearchProjectDetailModelTests.swift */,
D34D00000000000000000012 /* KeywordResearchHistoryModelTests.swift */,
D34E00000000000000000012 /* KeywordResearchModelFactoryTests.swift */,
D34F00000000000000000012 /* KeywordResearchWorkspaceSelectionTests.swift */,
D09D00000000000000000007 /* TrackedKeywordRefreshStatusTests.swift */,
D20B00000000000000000015 /* EstimatedKeywordDifficultyStoreTests.swift */,
D02000000000000000000004 /* v0.3.2-v1 */,
Expand Down Expand Up @@ -663,6 +670,8 @@
D34C00000000000000000011 /* KeywordResearchProjectDetailModel.swift */,
D34D00000000000000000011 /* KeywordResearchHistoryModel.swift */,
D34E00000000000000000011 /* KeywordResearchModelFactory.swift */,
D34E00000000000000000013 /* KeywordResearchWorkspaceView.swift */,
D34E00000000000000000014 /* KeywordResearchProjectEditorSheet.swift */,
);
path = KeywordResearch;
sourceTree = "<group>";
Expand Down Expand Up @@ -1246,6 +1255,8 @@
D34C00000000000000000001 /* KeywordResearchProjectDetailModel.swift in Sources */,
D34D00000000000000000001 /* KeywordResearchHistoryModel.swift in Sources */,
D34E00000000000000000001 /* KeywordResearchModelFactory.swift in Sources */,
D34E00000000000000000003 /* KeywordResearchWorkspaceView.swift in Sources */,
D34E00000000000000000004 /* KeywordResearchProjectEditorSheet.swift in Sources */,
9A6937276AF0E3CAEDA90C36 /* RankingSource.swift in Sources */,
A40000000000000000000003 /* RatingsDetail.swift in Sources */,
A40000000000000000000001 /* RatingsDashboardSupport.swift in Sources */,
Expand Down Expand Up @@ -1300,6 +1311,7 @@
D34C00000000000000000002 /* KeywordResearchProjectDetailModelTests.swift in Sources */,
D34D00000000000000000002 /* KeywordResearchHistoryModelTests.swift in Sources */,
D34E00000000000000000002 /* KeywordResearchModelFactoryTests.swift in Sources */,
D34F00000000000000000002 /* KeywordResearchWorkspaceSelectionTests.swift in Sources */,
D09D00000000000000000008 /* TrackedKeywordRefreshStatusTests.swift in Sources */,
D20B00000000000000000009 /* EstimatedKeywordDifficultyStoreTests.swift in Sources */,
D14000000000000000000002 /* AppMetadataRefreshProgressStoreTests.swift in Sources */,
Expand Down
14 changes: 14 additions & 0 deletions OpenASO/App/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ struct RootView: View {
@Environment(AppServices.self) private var services

@State private var selectedApp: TrackedApp?
@State private var isPresentingKeywordResearch = false

var body: some View {
NavigationSplitView {
Expand All @@ -13,6 +14,19 @@ struct RootView: View {
RootDetailView(selectedApp: selectedApp)
}
.navigationTitle("OpenASO")
.toolbar {
ToolbarItem(placement: .primaryAction) {
Button {
isPresentingKeywordResearch = true
} label: {
Label("Keyword Research", systemImage: "magnifyingglass")
}
.help("Open the pre-live keyword research workspace")
}
}
.sheet(isPresented: $isPresentingKeywordResearch) {
KeywordResearchWorkspaceLauncher()
}
.task {
guard !Self.isRunningUnderTests else {
return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
import SwiftUI

struct ProjectEditorContext: Identifiable {
let id: UUID
let project: KeywordResearchProjectSnapshot?
let initialDraft: KeywordResearchProjectDraft

static func create() -> Self {
let draft = KeywordResearchProjectDraft()
return Self(id: draft.id, project: nil, initialDraft: draft)
}

static func edit(_ project: KeywordResearchProjectSnapshot) -> Self {
Self(
id: project.id,
project: project,
initialDraft: KeywordResearchProjectDraft(project: project)
)
}
}

struct ProjectEditorOutcome: Sendable {
let project: KeywordResearchProjectSnapshot?
let error: KeywordResearchErrorPresentation?
}

struct KeywordResearchProjectEditorSheet: View {
@Environment(\.dismiss) private var dismiss

let context: ProjectEditorContext
let storefronts: [BundledStorefront]
let save: @MainActor (
_ context: ProjectEditorContext,
_ draft: KeywordResearchProjectDraft
) async -> ProjectEditorOutcome

@State private var draft: KeywordResearchProjectDraft
@State private var isSaving = false
@State private var error: KeywordResearchErrorPresentation?

init(
context: ProjectEditorContext,
storefronts: [BundledStorefront],
save: @escaping @MainActor (
_ context: ProjectEditorContext,
_ draft: KeywordResearchProjectDraft
) async -> ProjectEditorOutcome
) {
self.context = context
self.storefronts = storefronts
self.save = save
_draft = State(initialValue: context.initialDraft)
}

var body: some View {
VStack(alignment: .leading, spacing: 20) {
Text(context.project == nil ? "New Research Project" : "Edit Research Project")
.font(.title2)
.fontWeight(.semibold)

Form {
TextField("Name", text: $draft.name)
TextField("Bundle identifier (optional)", text: $draft.bundleID)

if storefronts.isEmpty {
TextField("Default storefront", text: $draft.defaultStorefront)
} else {
Picker("Default storefront", selection: $draft.defaultStorefront) {
ForEach(storefronts, id: \.code) { storefront in
Text("\(storefront.flagEmoji) \(storefront.name)")
.tag(storefront.code.lowercased())
}
}
}

Picker("Default platform", selection: $draft.defaultPlatform) {
ForEach(AppPlatform.allCases) { platform in
Text(platform.displayName).tag(platform)
}
}

TextField("Notes (optional)", text: $draft.notes, axis: .vertical)
.lineLimit(3...8)
}
.formStyle(.grouped)

if let error {
VStack(alignment: .leading, spacing: 4) {
Label(error.title, systemImage: "exclamationmark.triangle")
.fontWeight(.medium)
Text(error.message)
if let recoverySuggestion = error.recoverySuggestion {
Text(recoverySuggestion)
.foregroundStyle(.secondary)
}
}
.accessibilityElement(children: .ignore)
.accessibilityLabel(error.accessibilityLabel)
}

HStack {
Spacer()
Button("Cancel") {
dismiss()
}
.keyboardShortcut(.cancelAction)
.disabled(isSaving)

Button {
submit()
} label: {
if isSaving {
HStack(spacing: 6) {
ProgressView()
.controlSize(.small)
.accessibilityHidden(true)
Text("Saving…")
}
} else {
Text(context.project == nil ? "Create" : "Save")
}
}
.accessibilityLabel(
isSaving
? "Saving Research Project"
: (context.project == nil ? "Create Research Project" : "Save Research Project")
)
.keyboardShortcut(.defaultAction)
.disabled(isSaving || draft.name.trimmingCharacters(
in: .whitespacesAndNewlines
).isEmpty)
}
}
.padding(24)
.frame(minWidth: 520, minHeight: 460)
.interactiveDismissDisabled(isSaving)
}

private func submit() {
guard !isSaving else { return }
isSaving = true
error = nil

Task {
let outcome = await save(context, draft)
isSaving = false
if outcome.project != nil {
dismiss()
} else {
error = outcome.error ?? .presenting(OpenASOError.unexpectedResponse)
}
}
}
}
Loading
Loading