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
14 changes: 7 additions & 7 deletions LocalPackage/Sources/Model/Stores/CustomMetricsSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public final class CustomMetricsSettings: Composable {
public var showingFileImporter: Bool
public var showingConfirmationDialog: Bool
public var pendingRemovalSourceID: UUID?
public var showingHelpPopover: Bool
public var showingInfoPopover: Bool
public let action: (Action) async -> Void

public init(
Expand All @@ -47,7 +47,7 @@ public final class CustomMetricsSettings: Composable {
showingFileImporter: Bool = false,
showingConfirmationDialog: Bool = false,
pendingRemovalSourceID: UUID? = nil,
showingHelpPopover: Bool = false,
showingInfoPopover: Bool = false,
action: @escaping (Action) async -> Void = { _ in }
) {
self.appStateClient = appDependencies.appStateClient
Expand All @@ -60,7 +60,7 @@ public final class CustomMetricsSettings: Composable {
self.showingFileImporter = showingFileImporter
self.showingConfirmationDialog = showingConfirmationDialog
self.pendingRemovalSourceID = pendingRemovalSourceID
self.showingHelpPopover = showingHelpPopover
self.showingInfoPopover = showingInfoPopover
self.action = action
}

Expand Down Expand Up @@ -103,9 +103,6 @@ public final class CustomMetricsSettings: Composable {
case .addCustomMetricsSourceButtonTapped:
showingFileImporter = true

case .helpButtonTapped:
showingHelpPopover = true

case let .fileImporterResponse(.success(urls)):
guard let url = urls.first else { return }
do {
Expand All @@ -131,6 +128,9 @@ public final class CustomMetricsSettings: Composable {
case .removingCustomMetricsSourceCancelled:
pendingRemovalSourceID = nil

case .infoButtonTapped:
showingInfoPopover = true

case .errorOccurred:
return
}
Expand All @@ -154,10 +154,10 @@ public final class CustomMetricsSettings: Composable {
case customMetricsSourceLinkTapped(CustomMetricsSource)
case customMetricsSourceRowMoved(IndexSet, Int)
case addCustomMetricsSourceButtonTapped
case helpButtonTapped
case fileImporterResponse(Result<[URL], any Error>)
case removingCustomMetricsSourceConfirmed
case removingCustomMetricsSourceCancelled
case infoButtonTapped
case errorOccurred(RCNError)
}
}
9 changes: 8 additions & 1 deletion LocalPackage/Sources/Model/Stores/CustomRunnerSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public final class CustomRunnerSettings: Composable {
public var previewingFrameImage: FrameImage?
public var previewSpeed: Double
public var showingFileImporter: Bool
public var showingInfoPopover: Bool
public let action: (Action) async -> Void

public var canAdd: Bool {
Expand All @@ -52,6 +53,7 @@ public final class CustomRunnerSettings: Composable {
_ appDependencies: AppDependencies,
customRunnerBundleList: [RunnerBundle] = [],
showingCustomRunnerEditorSheet: Bool = false,
showingInfoPopover: Bool = false,
runnerName: String = "",
isTemplate: Bool = true,
frameImages: [FrameImage] = [],
Expand All @@ -68,6 +70,7 @@ public final class CustomRunnerSettings: Composable {
self.runnerService = .init(appDependencies)
self.customRunnerBundleList = customRunnerBundleList
self.showingCustomRunnerEditorSheet = showingCustomRunnerEditorSheet
self.showingInfoPopover = showingInfoPopover
self.runnerName = runnerName
self.isTemplate = isTemplate
self.frameImages = frameImages
Expand Down Expand Up @@ -219,7 +222,10 @@ public final class CustomRunnerSettings: Composable {
} catch {
logService.critical(.unknown(error))
}


case .infoButtonTapped:
showingInfoPopover = true

case .errorOccurred:
return
}
Expand Down Expand Up @@ -263,6 +269,7 @@ public final class CustomRunnerSettings: Composable {
case deleteFrameButtonTapped
case fileImporterResponse(Result<[URL], any Error>)
case addButtonTapped
case infoButtonTapped
case errorOccurred(RCNError)
}
}
132 changes: 132 additions & 0 deletions LocalPackage/Sources/UserInterface/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -2245,6 +2245,72 @@
}
}
},
"information" : {
"comment" : "A button that opens a popover with more information about custom metrics.",
"isCommentAutoGenerated" : true,
"localizations" : {
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Informationen"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Information"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Información"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Informations"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "情報"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"value" : "정보"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Информация"
}
},
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Thông tin"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "信息"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "資訊"
}
}
}
},
"invalidFormat" : {
"comment" : "Error message when a metrics file does not follow the schema.",
"isCommentAutoGenerated" : true,
Expand Down Expand Up @@ -5610,6 +5676,72 @@
}
}
}
},
"viewRunnerGallery" : {
"comment" : "A link to the runner gallery.",
"isCommentAutoGenerated" : true,
"localizations" : {
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Runner Gallery ansehen"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "View Runner Gallery"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ver la Runner Gallery"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Voir la Runner Gallery"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "Runner Galleryを見る"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"value" : "Runner Gallery 보기"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Посмотреть Runner Gallery"
}
},
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Xem Runner Gallery"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "查看 Runner Gallery"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "查看 Runner Gallery"
}
}
}
}
},
"version" : "1.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ struct CustomMetricsSettingsSectionView: View {
}
}
}
.confirmationDialog(
Text("removeCustomMetrics", bundle: .module),
isPresented: $store.showingConfirmationDialog,
presenting: store.pendingRemovalSourceID,
actions: { sourceID in
Button(role: .destructive) {
Task {
await store.send(.removingCustomMetricsSourceConfirmed)
}
} label: {
Text("remove", bundle: .module)
}
Button(role: .cancel) {
Task {
await store.send(.removingCustomMetricsSourceCancelled)
}
} label: {
Text("cancel", bundle: .module)
}
},
message: { _ in
Text("customMetricsConfirmationMessage", bundle: .module)
}
)
HStack {
Spacer()
Button {
Expand All @@ -58,15 +82,32 @@ struct CustomMetricsSettingsSectionView: View {
Image(systemName: "plus")
}
}
.fileImporter(
isPresented: $store.showingFileImporter,
allowedContentTypes: [.json],
allowsMultipleSelection: false,
onCompletion: { result in
Task {
await store.send(.fileImporterResponse(result))
}
}
)
.fileDialogMessage(Text("chooseJsonFile", bundle: .module))
.fileDialogConfirmationLabel(Text("add", bundle: .module))
Button {
Task {
await store.send(.helpButtonTapped)
await store.send(.infoButtonTapped)
}
} label: {
Image(systemName: "info.circle")
Label {
Text("information", bundle: .module)
} icon: {
Image(systemName: "info.circle")
}
.labelStyle(.iconOnly)
}
.buttonStyle(.borderless)
.popover(isPresented: $store.showingHelpPopover, arrowEdge: .bottom) {
.popover(isPresented: $store.showingInfoPopover, arrowEdge: .bottom) {
VStack(alignment: .leading, spacing: 4) {
Text("customMetricsDescription", bundle: .module)
.font(.caption)
Expand All @@ -81,42 +122,6 @@ struct CustomMetricsSettingsSectionView: View {
.frame(maxWidth: 360, alignment: .leading)
}
}
.fileImporter(
isPresented: $store.showingFileImporter,
allowedContentTypes: [.json],
allowsMultipleSelection: false,
onCompletion: { result in
Task {
await store.send(.fileImporterResponse(result))
}
}
)
.fileDialogMessage(Text("chooseJsonFile", bundle: .module))
.fileDialogConfirmationLabel(Text("add", bundle: .module))
.confirmationDialog(
Text("removeCustomMetrics", bundle: .module),
isPresented: $store.showingConfirmationDialog,
presenting: store.pendingRemovalSourceID,
actions: { sourceID in
Button(role: .destructive) {
Task {
await store.send(.removingCustomMetricsSourceConfirmed)
}
} label: {
Text("remove", bundle: .module)
}
Button(role: .cancel) {
Task {
await store.send(.removingCustomMetricsSourceCancelled)
}
} label: {
Text("cancel", bundle: .module)
}
},
message: { _ in
Text("customMetricsConfirmationMessage", bundle: .module)
}
)
} header: {
Text("customMetrics", bundle: .module)
}
Expand Down
Loading