Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageMaker - Create data representation model #65

Merged
merged 7 commits into from
Oct 19, 2024
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
xcuserdata/
DerivedData/
.netrc
.vscode

.index-build/
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"configurations": [
{
"type": "swift-lldb",
"request": "launch",
"name": "Debug Csv2ImgCmd",
"program": "${workspaceFolder:Csv2Img}/.build/debug/Csv2ImgCmd",
"args": [],
"cwd": "${workspaceFolder:Csv2Img}",
"preLaunchTask": "swift: Build Debug Csv2ImgCmd"
},
{
"type": "swift-lldb",
"request": "launch",
"name": "Release Csv2ImgCmd",
"program": "${workspaceFolder:Csv2Img}/.build/release/Csv2ImgCmd",
"args": [],
"cwd": "${workspaceFolder:Csv2Img}",
"preLaunchTask": "swift: Build Release Csv2ImgCmd"
}
]
}
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"editor.formatOnSave": true,
"swift.diagnostics": true,
"apple-swift-format.enable": true,
"swift.autoGenerateLaunchConfigurations": true,
"swift.buildArguments": [],
"swift.testEnvironmentVariables": {},
"[swift]": {
"editor.tabSize": 4,
"editor.insertSpaces": true
},
"editor.formatOnSaveMode": "file",
"editor.defaultFormatter": "vknabel.vscode-apple-swift-format",
"makefile.configureOnOpen": false,
"swift.sourcekit-lsp.serverArguments": [
"-Xswiftc",
"-sdk",
"-Xswiftc",
"/Applications/Xcode-16.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.0.sdk",
]
}
Binary file modified Fixtures/outputs/category.png
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review-note

I should check this diff later.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 8 additions & 21 deletions Sources/Csv2ImgCore/Csv.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
Never
>
{
isLoadingSubject.eraseToAnyPublisher()

Check warning on line 87 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build Csv2ImgCmd

actor-isolated property 'isLoadingSubject' can not be referenced from a nonisolated context; this is an error in the Swift 6 language mode

Check warning on line 87 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build CsvBuilder

actor-isolated property 'isLoadingSubject' can not be referenced from a nonisolated context; this is an error in the Swift 6 language mode

Check warning on line 87 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build CsvBuilder

actor-isolated property 'isLoadingSubject' can not be referenced from a nonisolated context; this is an error in the Swift 6 language mode
}

/// `CurrentValueSubject` to store ``isLoading``.
Expand All @@ -109,7 +109,7 @@
Never
>
{
progressSubject.eraseToAnyPublisher()

Check warning on line 112 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build Csv2ImgCmd

actor-isolated property 'progressSubject' can not be referenced from a nonisolated context; this is an error in the Swift 6 language mode

Check warning on line 112 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build CsvBuilder

actor-isolated property 'progressSubject' can not be referenced from a nonisolated context; this is an error in the Swift 6 language mode

Check warning on line 112 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build CsvBuilder

actor-isolated property 'progressSubject' can not be referenced from a nonisolated context; this is an error in the Swift 6 language mode
}

/// `CurrentValueSubject` to store ``progress``.
Expand Down Expand Up @@ -507,45 +507,32 @@
}
if let maker = maker as? ImageMaker {
if let fontSize = fontSize {
maker.set(
fontSize: fontSize
)
maker.set(fontSize: fontSize)
}
let exportable: any CsvExportable = try await withCheckedThrowingContinuation {
let image: CGImage = try await withCheckedThrowingContinuation {
continuation in
queue.async { [weak self] in
guard let self = self else {
continuation.resume(
throwing: Csv.Error.underlying(
nil
)
)
continuation.resume(throwing: Csv.Error.underlying(nil))
return
}
Task {
do {
let img = try maker.make(
let image = try maker.make(
columns: await self.columns,
rows: await self.rows
) { progress in
self.progressSubject.value = progress

Check warning on line 525 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build Csv2ImgCmd

actor-isolated property 'progressSubject' can not be mutated from a nonisolated context; this is an error in the Swift 6 language mode

Check warning on line 525 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build CsvBuilder

actor-isolated property 'progressSubject' can not be mutated from a nonisolated context; this is an error in the Swift 6 language mode

Check warning on line 525 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build CsvBuilder

actor-isolated property 'progressSubject' can not be mutated from a nonisolated context; this is an error in the Swift 6 language mode
}
continuation.resume(
returning: img
)
continuation.resume(returning: image)
} catch {
continuation.resume(
throwing: Csv.Error.underlying(
error
)
)
continuation.resume(throwing: Csv.Error.underlying(error))
}
}
}
}
return AnyCsvExportable(
exportable
)

return AnyCsvExportable(image)
} else if let maker = maker as? PdfMaker {
if let fontSize = fontSize {
maker.set(
Expand Down Expand Up @@ -574,14 +561,14 @@
columns: await self.columns,
rows: await self.rows
) { progress in
self.progressSubject.value = progress

Check warning on line 564 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build Csv2ImgCmd

actor-isolated property 'progressSubject' can not be mutated from a nonisolated context; this is an error in the Swift 6 language mode

Check warning on line 564 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build CsvBuilder

actor-isolated property 'progressSubject' can not be mutated from a nonisolated context; this is an error in the Swift 6 language mode

Check warning on line 564 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build CsvBuilder

actor-isolated property 'progressSubject' can not be mutated from a nonisolated context; this is an error in the Swift 6 language mode
}
} else {
doc = try maker.make(
columns: await self.columns,
rows: await self.rows
) { progress in
self.progressSubject.value = progress

Check warning on line 571 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build Csv2ImgCmd

actor-isolated property 'progressSubject' can not be mutated from a nonisolated context; this is an error in the Swift 6 language mode

Check warning on line 571 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build CsvBuilder

actor-isolated property 'progressSubject' can not be mutated from a nonisolated context; this is an error in the Swift 6 language mode

Check warning on line 571 in Sources/Csv2ImgCore/Csv.swift

View workflow job for this annotation

GitHub Actions / Build CsvBuilder

actor-isolated property 'progressSubject' can not be mutated from a nonisolated context; this is an error in the Swift 6 language mode
}
}
continuation.resume(
Expand Down
2 changes: 2 additions & 0 deletions Sources/Csv2ImgCore/CsvError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ extension Csv {
case emptyData
/// Csv denied execution because it is generating another contents.
case workInProgress
/// Failed to render image from `CsvImageRepresentation`.
case failedToRenderImage
case underlying(
Swift.Error?
)
Expand Down
22 changes: 22 additions & 0 deletions Sources/Csv2ImgCore/CsvImageRepresentation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import CoreGraphics
import Foundation

public struct CsvImageRepresentation: Equatable {
let width: Int
let height: Int
let backgroundColor: CGColor
let fontSize: CGFloat
let columns: [ColumnRepresentation]
let rows: [RowRepresentation]

struct ColumnRepresentation: Equatable {
let name: String
let style: Csv.Column.Style
let frame: CGRect
}

struct RowRepresentation: Equatable {
let values: [String]
let frames: [CGRect]
}
}
Loading
Loading