Skip to content

Commit 2751c48

Browse files
authored
Merge pull request #18 from andreyoshev/master
Hard support old iOS versions improvements
2 parents 7d440bd + fbb9f69 commit 2751c48

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,16 @@ import UIKit
5555

5656
extension UIColor {
5757
static var primaryText: UIColor {
58-
UIColor { traitCollection -> UIColor in
59-
if traitCollection.userInterfaceStyle == .dark {
60-
return UIColor(red: 0.000, green: 0.000, blue: 0.000, alpha: 1.000)
61-
} else {
62-
return UIColor(red: 1.000, green: 1.000, blue: 1.000, alpha: 1.000)
58+
if #available(iOS 13.0, *) {
59+
return UIColor { traitCollection -> UIColor in
60+
if traitCollection.userInterfaceStyle == .dark {
61+
return UIColor(red: 0.000, green: 0.000, blue: 0.000, alpha: 1.000)
62+
} else {
63+
return UIColor(red: 1.000, green: 1.000, blue: 1.000, alpha: 1.000)
64+
}
6365
}
66+
} else {
67+
return UIColor(red: 1.000, green: 1.000, blue: 1.000, alpha: 1.000)
6468
}
6569
}
6670
static var backgroundVideo: UIColor {

Sources/XcodeExport/XcodeColorExporter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ final public class XcodeColorExporter {
8888
contents.append("""
8989
static var \(colorPair.light.name): UIColor {
9090
if #available(iOS 13.0, *) {
91-
UIColor { traitCollection -> UIColor in
91+
return UIColor { traitCollection -> UIColor in
9292
if traitCollection.userInterfaceStyle == .dark {
9393
return UIColor(red: \(darkComponents.red), green: \(darkComponents.green), blue: \(darkComponents.blue), alpha: \(darkComponents.alpha))
9494
} else {

Tests/XcodeExportTests/XcodeColorExporterTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ final class XcodeColorExporterTests: XCTestCase {
4545
extension UIColor {
4646
static var colorPair1: UIColor {
4747
if #available(iOS 13.0, *) {
48-
UIColor { traitCollection -> UIColor in
48+
return UIColor { traitCollection -> UIColor in
4949
if traitCollection.userInterfaceStyle == .dark {
5050
return UIColor(red: 0.000, green: 0.000, blue: 0.000, alpha: 1.000)
5151
} else {

0 commit comments

Comments
 (0)