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
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import PackageDescription
let package = Package(
name: "gitdiff",
platforms: [
.iOS(.v15)
.iOS(.v15),
.macOS(.v13)
],
products: [
.library(
Expand Down
31 changes: 31 additions & 0 deletions Sources/gitdiff/Core/PlatformColors.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import SwiftUI

#if os(iOS) || os(tvOS) || os(watchOS)
import UIKit
#endif
#if os(macOS)
import AppKit
#endif

/// Cross-platform system background color wrapper
enum PlatformColors {
static var background: Color {
#if os(iOS) || os(tvOS) || os(watchOS)
return Color(UIColor.systemBackground)
#elseif os(macOS)
if #available(macOS 10.15, *) {
// There is no NSColor.systemBackground; windowBackgroundColor is closest for content areas
return Color(NSColor.windowBackgroundColor)
} else {
return Color.white
}
#else
return Color.white
#endif
}
}

extension Color {
/// A cross-platform background color similar to system background.
public static var appBackground: Color { PlatformColors.background }
}
2 changes: 1 addition & 1 deletion Sources/gitdiff/Views/DiffFileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ struct DiffFileView: View {

DiffFileView(file: sampleFile)
.padding()
.background(Color(.systemBackground))
.background(Color.appBackground)
}
2 changes: 1 addition & 1 deletion Sources/gitdiff/Views/DiffLineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,5 @@ struct DiffLineView: View {
)
)
}
.background(Color(.systemBackground))
.background(Color.appBackground)
}
4 changes: 2 additions & 2 deletions Sources/gitdiff/Views/DiffRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public struct DiffRenderer: View {
.padding()
}
}
.background(Color(.systemBackground))
.background(Color.appBackground)
}
}

Expand Down Expand Up @@ -103,7 +103,7 @@ public struct DiffRenderer: View {

// With dark theme
DiffRenderer(diffText: text)
.diffTheme(.vsCodeDark)
.diffTheme(.dark)

// With custom configuration
DiffRenderer(diffText: text)
Expand Down