Skip to content

Commit 0fd02ca

Browse files
committed
fix: fix unavailable Colors
1 parent 361d03b commit 0fd02ca

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

Sources/DropView/Color.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// SwiftUI.swift
3+
// DropView
4+
//
5+
// Created by Stefano Bertagno on 14/05/21.
6+
//
7+
8+
import SwiftUI
9+
10+
extension Color {
11+
/// The light drop background.
12+
private static let lightDropBackground: Color = .init(red: 242/255, green: 242/255, blue: 247/255)
13+
/// The dark drop background.
14+
private static let darkDropBackground: Color = .init(red: 28/255, green: 28/255, blue: 30/255)
15+
16+
/// The drop background color.
17+
///
18+
/// - parameter scheme: A valid `ColorScheme`.
19+
/// - returns: A valid `Color`.
20+
static func dropBackground(for scheme: ColorScheme) -> Color {
21+
scheme == .dark ? darkDropBackground : lightDropBackground
22+
}
23+
24+
/// The light drop separator.
25+
private static let lightDropSeparator: Color = .init(red: 234/255, green: 234/255, blue: 237/255)
26+
/// The dark drop separator.
27+
private static let darkDropSeparator: Color = .init(red: 39/255, green: 39/255, blue: 41/255)
28+
29+
/// The separator color.
30+
///
31+
/// - parameter scheme: A valid `ColorScheme`.
32+
/// - returns: A valid `Color`.
33+
static func dropSeparator(for scheme: ColorScheme) -> Color {
34+
scheme == .dark ? darkDropSeparator : lightDropSeparator
35+
}
36+
}

Sources/DropView/DropView.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import SwiftUI
99

1010
/// A `struct` defining a view displaying `Drop`s.
1111
public struct DropView: View {
12+
/// The color scheme.
13+
@Environment(\.colorScheme) var colorScheme
1214
/// The pixel length.
1315
@Environment(\.pixelLength) var pixelLength
1416

@@ -47,9 +49,9 @@ public struct DropView: View {
4749
bottom: drop.subtitle == nil ? 15 : 10,
4850
trailing: drop.hasAction ? 12.5 : drop.hasIcon ? 40 : 50))
4951
.frame(minHeight: 50)
50-
.background(Color(.secondarySystemBackground))
52+
.background(Color.dropBackground(for: colorScheme))
5153
.mask(Capsule())
52-
.overlay(Capsule().strokeBorder(Color(.opaqueSeparator).opacity(0.25), lineWidth: pixelLength))
54+
.overlay(Capsule().strokeBorder(Color.dropSeparator(for: colorScheme), lineWidth: pixelLength))
5355
.shadow(color: .black.opacity(0.15),
5456
radius: 25,
5557
x: 0,

Sources/DropView/View+DropView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ public extension View {
2525
}
2626
}
2727

28-
#if DEBUG
29-
28+
#if DEBUG && !os(tvOS)
3029
private struct DropPreviewView: View {
3130
/// An optional `Drop` binding.
3231
@State var drop: Drop?

0 commit comments

Comments
 (0)