Fix wrong colors in PDF export

This commit is contained in:
Christoph Hagen 2023-09-19 14:50:20 +02:00
parent d25c8e1207
commit 43a1789332
8 changed files with 66 additions and 7 deletions

View File

@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
886AD6452AB9CD9100B1A00D /* ColorScheme+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 886AD6442AB9CD9100B1A00D /* ColorScheme+Extensions.swift */; };
E267D1742A8E0DE80069112B /* ResumeBuilderApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = E267D1732A8E0DE80069112B /* ResumeBuilderApp.swift */; };
E267D1762A8E0DE80069112B /* CV.swift in Sources */ = {isa = PBXBuildFile; fileRef = E267D1752A8E0DE80069112B /* CV.swift */; };
E267D1782A8E0DE90069112B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E267D1772A8E0DE90069112B /* Assets.xcassets */; };
@ -41,6 +42,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
886AD6442AB9CD9100B1A00D /* ColorScheme+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ColorScheme+Extensions.swift"; sourceTree = "<group>"; };
E2329BB12A9651E200A1270E /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
E267D1702A8E0DE80069112B /* ResumeBuilder.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ResumeBuilder.app; sourceTree = BUILT_PRODUCTS_DIR; };
E267D1732A8E0DE80069112B /* ResumeBuilderApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResumeBuilderApp.swift; sourceTree = "<group>"; };
@ -118,6 +120,7 @@
E267D17C2A8E0DE90069112B /* ResumeBuilder.entitlements */,
E267D1792A8E0DE90069112B /* Preview Content */,
E267D1822A8E0F320069112B /* Color+Extension.swift */,
886AD6442AB9CD9100B1A00D /* ColorScheme+Extensions.swift */,
E267D1932A8E38C60069112B /* Data.swift */,
E267D1A52A8EC34B0069112B /* Data */,
E267D1BE2A90095D0069112B /* Language */,
@ -230,7 +233,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1430;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1500;
TargetAttributes = {
E267D16F2A8E0DE80069112B = {
CreatedOnToolsVersion = 14.3.1;
@ -295,6 +298,7 @@
E267D18C2A8E1A890069112B /* TopViewImage.swift in Sources */,
E267D19C2A8E45470069112B /* CareerStation.swift in Sources */,
E267D1BA2A8F9D9C0069112B /* SkillStyle.swift in Sources */,
886AD6452AB9CD9100B1A00D /* ColorScheme+Extensions.swift in Sources */,
E267D1AD2A8F694A0069112B /* PublicationView.swift in Sources */,
E267D1BC2A8FFF300069112B /* TagView.swift in Sources */,
E267D1A02A8E45620069112B /* CVInfo.swift in Sources */,
@ -313,6 +317,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
@ -342,9 +347,11 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
@ -373,6 +380,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
@ -402,9 +410,11 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@ -431,6 +441,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"ResumeBuilder/Preview Content\"";
DEVELOPMENT_TEAM = H8WR4M6QQ4;
ENABLE_HARDENED_RUNTIME = YES;
@ -460,6 +471,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"ResumeBuilder/Preview Content\"";
DEVELOPMENT_TEAM = H8WR4M6QQ4;
ENABLE_HARDENED_RUNTIME = YES;

View File

@ -1,6 +1,9 @@
import SwiftUI
struct CV: View {
@Environment(\.colorScheme)
var colorScheme: ColorScheme
let info: CVInfo
@ -61,7 +64,7 @@ struct CV: View {
Spacer(minLength: 0)
Text(info.footer)
.font(.footnote)
.foregroundColor(.secondary)
.foregroundColor(colorScheme.secondaryColor)
}
.padding()
.aspectRatio(1 / sqrt(2), contentMode: .fit)

View File

@ -13,4 +13,20 @@ extension Color {
init(_ r: Double, _ g: Double, _ b: Double) {
self.init(red: r, green: g, blue: b)
}
static var lightSchemePrimaryColor: Color {
.init(r: 1, g: 1, b: 1)
}
static var darkSchemePrimaryColor: Color {
.init(r: 224, g: 224, b: 224)
}
static var lightSchemeSecondaryColor: Color {
.init(r: 128, g: 128, b: 128)
}
static var darkSchemeSecondaryColor: Color {
.init(r: 161, g: 161, b: 161)
}
}

View File

@ -0,0 +1,13 @@
import Foundation
import SwiftUI
extension ColorScheme {
var primaryColor: Color {
self == .light ? .lightSchemePrimaryColor : .darkSchemePrimaryColor
}
var secondaryColor: Color {
self == .light ? .lightSchemeSecondaryColor : .darkSchemeSecondaryColor
}
}

View File

@ -205,7 +205,7 @@ struct ContentView: View {
private var renderContent: some View {
CV(info: info, style: style)
.frame(width: style.pageWidth, height: style.pageHeight)
.preferredColorScheme(.dark)
.preferredColorScheme(colorStyle)
}
@MainActor

View File

@ -3,6 +3,9 @@ import SFSafeSymbols
struct CareerStationView: View {
@Environment(\.colorScheme)
var colorScheme: ColorScheme
let info: CareerStation
let borderSpacing: CGFloat
@ -20,7 +23,7 @@ struct CareerStationView: View {
RightImageLabel(info.location, systemSymbol: .house)
}
.font(.caption)
.foregroundColor(.secondary)
.foregroundColor(colorScheme.secondaryColor)
Text(info.title)
.font(.headline)
.fontWeight(.regular)
@ -32,7 +35,7 @@ struct CareerStationView: View {
if let text = info.text {
Text(text)
.font(.caption)
.foregroundColor(.secondary)
.foregroundColor(colorScheme.secondaryColor)
}
}
}

View File

@ -1,7 +1,10 @@
import SwiftUI
struct PublicationView: View {
@Environment(\.colorScheme)
var colorScheme: ColorScheme
let info: Publication
let borderSpacing: CGFloat
@ -15,10 +18,11 @@ struct PublicationView: View {
VStack(alignment: .leading) {
Text(info.venue)
.font(.caption)
.foregroundColor(.secondary)
.foregroundColor(colorScheme.secondaryColor)
Text(info.title)
.font(.subheadline)
.fontWeight(.regular)
.foregroundColor(colorScheme.primaryColor)
}
}
}

View File

@ -1,6 +1,9 @@
import SwiftUI
struct TitledTextSection: View {
@Environment(\.colorScheme)
var colorScheme: ColorScheme
let content: Titled<String>
@ -8,6 +11,10 @@ struct TitledTextSection: View {
let paragraphSpacing: CGFloat
private var textColor: Color {
colorScheme == .light ? .lightSchemePrimaryColor : .darkSchemePrimaryColor
}
var body: some View {
TitledSection(title: content.title, spacing: titleSpacing) {
ForEach(content.items) { text in
@ -15,6 +22,7 @@ struct TitledTextSection: View {
.font(.body)
.fontWeight(.light)
.padding(.bottom, paragraphSpacing)
.foregroundColor(textColor)
}
}
}