File tree Expand file tree Collapse file tree 5 files changed +37
-5
lines changed Expand file tree Collapse file tree 5 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,8 @@ import PackageDescription
66let package = Package (
77 name: " gitdiff " ,
88 platforms: [
9- . iOS( . v15)
9+ . iOS( . v15) ,
10+ . macOS( . v13)
1011 ] ,
1112 products: [
1213 . library(
Original file line number Diff line number Diff line change 1+ import SwiftUI
2+
3+ #if os(iOS) || os(tvOS) || os(watchOS)
4+ import UIKit
5+ #endif
6+ #if os(macOS)
7+ import AppKit
8+ #endif
9+
10+ /// Cross-platform system background color wrapper
11+ enum PlatformColors {
12+ static var background : Color {
13+ #if os(iOS) || os(tvOS) || os(watchOS)
14+ return Color ( UIColor . systemBackground)
15+ #elseif os(macOS)
16+ if #available( macOS 10 . 15 , * ) {
17+ // There is no NSColor.systemBackground; windowBackgroundColor is closest for content areas
18+ return Color ( NSColor . windowBackgroundColor)
19+ } else {
20+ return Color . white
21+ }
22+ #else
23+ return Color . white
24+ #endif
25+ }
26+ }
27+
28+ extension Color {
29+ /// A cross-platform background color similar to system background.
30+ public static var appBackground : Color { PlatformColors . background }
31+ }
Original file line number Diff line number Diff line change @@ -110,5 +110,5 @@ struct DiffFileView: View {
110110
111111 DiffFileView ( file: sampleFile)
112112 . padding ( )
113- . background ( Color ( . systemBackground ) )
113+ . background ( Color . appBackground )
114114}
Original file line number Diff line number Diff line change @@ -142,5 +142,5 @@ struct DiffLineView: View {
142142 )
143143 )
144144 }
145- . background ( Color ( . systemBackground ) )
145+ . background ( Color . appBackground )
146146}
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ public struct DiffRenderer: View {
6060 . padding ( )
6161 }
6262 }
63- . background ( Color ( . systemBackground ) )
63+ . background ( Color . appBackground )
6464 }
6565}
6666
@@ -103,7 +103,7 @@ public struct DiffRenderer: View {
103103
104104 // With dark theme
105105 DiffRenderer ( diffText: text)
106- . diffTheme ( . vsCodeDark )
106+ . diffTheme ( . dark )
107107
108108 // With custom configuration
109109 DiffRenderer ( diffText: text)
You can’t perform that action at this time.
0 commit comments