Skip to content
Closed
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
7 changes: 7 additions & 0 deletions SwiftLeeds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
7B31C8F12ED0A7BF00FEEDF7 /* Settings in Frameworks */ = {isa = PBXBuildFile; productRef = 7B31C8F02ED0A7BF00FEEDF7 /* Settings */; };
7B31C8F32ED0AB0E00FEEDF7 /* Settings in Frameworks */ = {isa = PBXBuildFile; productRef = 7B31C8F22ED0AB0E00FEEDF7 /* Settings */; };
7B31C8F52ED0AB1600FEEDF7 /* Settings in Frameworks */ = {isa = PBXBuildFile; productRef = 7B31C8F42ED0AB1600FEEDF7 /* Settings */; };
7B8C3ECF2EE4A9F70089C6CF /* SharedAssets in Frameworks */ = {isa = PBXBuildFile; productRef = 7B8C3ECE2EE4A9F70089C6CF /* SharedAssets */; };
AE1C8010289E9F3800996659 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE1C800F289E9F3800996659 /* String.swift */; };
AE1C801428A7BCD000996659 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = AE1C801328A7BCD000996659 /* Settings.bundle */; };
AE32CDF0286CCF9D00DF0AFF /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE32CDEF286CCF9D00DF0AFF /* Constants.swift */; };
Expand Down Expand Up @@ -307,6 +308,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7B8C3ECF2EE4A9F70089C6CF /* SharedAssets in Frameworks */,
7B31C8E52ED08DD100FEEDF7 /* Networking in Frameworks */,
7B31C8F12ED0A7BF00FEEDF7 /* Settings in Frameworks */,
74F5EF8C2A4B4352008D9413 /* ReadabilityModifier in Frameworks */,
Expand Down Expand Up @@ -676,6 +678,7 @@
7B31C8E42ED08DD100FEEDF7 /* Networking */,
7B31C8EA2ED0959000FEEDF7 /* DesignKit */,
7B31C8F02ED0A7BF00FEEDF7 /* Settings */,
7B8C3ECE2EE4A9F70089C6CF /* SharedAssets */,
);
productName = SwiftLeeds;
productReference = AECB295327417F9D00CDC983 /* SwiftLeeds.app */;
Expand Down Expand Up @@ -1525,6 +1528,10 @@
isa = XCSwiftPackageProductDependency;
productName = Settings;
};
7B8C3ECE2EE4A9F70089C6CF /* SharedAssets */ = {
isa = XCSwiftPackageProductDependency;
productName = SharedAssets;
};
AE5EFD72289DC1D000464FE1 /* CachedAsyncImage */ = {
isa = XCSwiftPackageProductDependency;
package = AE5EFD71289DC1D000464FE1 /* XCRemoteSwiftPackageReference "swiftui-cached-async-image" */;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions SwiftLeedsPackage/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion SwiftLeedsPackage/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ let package = Package(
"Settings",
]
),
.library(
name: "SharedAssets",
targets: [
"SharedAssets",
]
)
],
dependencies: [
.package(url: "https://github.com/shadone/SwiftGenPlugin", branch: "6.6.2+deriveddatafix"),
],
targets: [
.target(
Expand All @@ -51,7 +60,13 @@ let package = Package(
),
.target(
name: "ColorTheme"
)
),
.target(
name: "SharedAssets",
plugins: [
.plugin(name: "SwiftGenPlugin", package: "SwiftGenPlugin"),
]
),
],
// Set to v5 to avoid strict concurrency checking in pre swift 6 code
swiftLanguageModes: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// swiftlint:disable all
#if canImport(UIKit)
import UIKit
#endif
#if canImport(SwiftUI)
import SwiftUI
#endif

// MARK: - Backwards Deployment Support -

/// A color resource.
public struct SLColorResource: Swift.Hashable, Swift.Sendable {
/// An asset catalog color resource name.
let name: Swift.String

/// An asset catalog color resource bundle.
let bundle: Foundation.Bundle

/// Initialize a `SLColorResource` with `name` and `bundle`.
init(name: Swift.String, bundle: Foundation.Bundle) {
self.name = name
self.bundle = bundle
}
}

#if canImport(SwiftUI)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension SwiftUI.Color {
private init?(thinnableResource: SLColorResource?) {
if let resource = thinnableResource {
self.init(resource)
} else {
return nil
}
}

}

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension SwiftUI.ShapeStyle where Self == SwiftUI.Color {
private init?(thinnableResource: SLColorResource?) {
if let resource = thinnableResource {
self.init(resource)
} else {
return nil
}
}

}

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public extension SwiftUI.Color {
/// Initialize a `Color` with a color resource.
init(_ resource: SLColorResource) {
self.init(resource.name, bundle: resource.bundle)
}

}
#endif

#if canImport(UIKit)
@available(iOS 11.0, tvOS 11.0, *)
@available(watchOS, unavailable)
public extension UIKit.UIColor {
/// Initialize a `UIColor` with a color resource.
convenience init(resource: SLColorResource) {
#if !os(watchOS)
self.init(named: resource.name, in: resource.bundle, compatibleWith: nil)!
#else
self.init()
#endif
}

}
#endif
// swiftlint:enable all
105 changes: 105 additions & 0 deletions SwiftLeedsPackage/Sources/SharedAssets/Models/SLImageResource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// swiftlint:disable all
#if canImport(UIKit)
import UIKit
#endif
#if canImport(SwiftUI)
import SwiftUI
#endif

// MARK: - Backwards Deployment Support -

/// An image resource.
public struct SLImageResource: Swift.Hashable, Swift.Sendable {
/// An asset catalog image resource name.
fileprivate let name: Swift.String

/// An asset catalog image resource bundle.
fileprivate let bundle: Foundation.Bundle

/// Initialize an `SLImageResource` with `name` and `bundle`.
init(name: Swift.String, bundle: Foundation.Bundle) {
self.name = name
self.bundle = bundle
}
}

#if canImport(SwiftUI)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public extension SwiftUI.Image {
/// Initialize an `Image` with an image resource.
init(_ resource: SLImageResource) {
self.init(resource.name, bundle: resource.bundle)
}

}
#endif

#if canImport(UIKit)
@available(iOS 11.0, tvOS 11.0, *)
@available(watchOS, unavailable)
public extension UIKit.UIImage {
/// Initialize a `UIImage` with an image resource.
convenience init(resource: SLImageResource) {
#if !os(watchOS)
self.init(named: resource.name, in: resource.bundle, compatibleWith: nil)!
#else
self.init()
#endif
}

}

@available(iOS 11.0, tvOS 11.0, *)
@available(watchOS, unavailable)
extension UIKit.UIImage {
private convenience init?(thinnableResource: SLImageResource?) {
#if !os(watchOS)
if let resource = thinnableResource {
self.init(resource: resource)
} else {
return nil
}
#else
return nil
#endif
}

}
#endif

#if canImport(AppKit)
@available(macOS 10.7, *)
@available(macCatalyst, unavailable)
extension AppKit.NSImage {
private convenience init?(thinnableResource: SLImageResource?) {
#if !targetEnvironment(macCatalyst)
if let resource = thinnableResource {
self.init(resource: resource)
} else {
return nil
}
#else
return nil
#endif
}

}
#endif

@available(iOS 11.0, macOS 10.7, tvOS 11.0, *)
@available(watchOS, unavailable)
extension SLImageResource {
private init?(thinnableName: Swift.String, bundle: Foundation.Bundle) {
#if canImport(UIKit) && !os(watchOS)
if UIKit.UIImage(named: thinnableName, in: bundle, compatibleWith: nil) != nil {
self.init(name: thinnableName, bundle: bundle)
} else {
return nil
}
#else
return nil
#endif
}

}
// swiftlint:enable all
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// File needed to avoid Swift Package compilation error

import SwiftUI

struct Test: View {
let color: SLColorResource = .accent

var body: some View {
Color(color)
}
}

#Preview {
Test()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x30",
"green" : "0x3B",
"red" : "0xFF"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "SwiftLeedsIcon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "original"
}
}
Binary file not shown.
Loading
Loading