-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #441 from webfrogs/namespacing
Another way of adding kf namespacing
- Loading branch information
Showing
24 changed files
with
1,215 additions
and
681 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// Kingfisher.swift | ||
// Kingfisher | ||
// | ||
// Created by WANG WEI on 2016/09/14. | ||
// Copyright © 2016年 Wei Wang. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import ImageIO | ||
|
||
#if os(macOS) | ||
import AppKit | ||
public typealias Image = NSImage | ||
public typealias Color = NSColor | ||
public typealias ImageView = NSImageView | ||
typealias Button = NSButton | ||
#else | ||
import UIKit | ||
public typealias Image = UIImage | ||
public typealias Color = UIColor | ||
#if !os(watchOS) | ||
public typealias ImageView = UIImageView | ||
typealias Button = UIButton | ||
#endif | ||
#endif | ||
|
||
public struct Kingfisher<Base> { | ||
public let base: Base | ||
public init(_ base: Base) { | ||
self.base = base | ||
} | ||
} | ||
|
||
/** | ||
A type that has Kingfisher extensions. | ||
*/ | ||
public protocol KingfisherCompatible { | ||
associatedtype CompatibleType | ||
var kf: CompatibleType { get } | ||
} | ||
|
||
public extension KingfisherCompatible { | ||
public var kf: Kingfisher<Self> { | ||
get { return Kingfisher(self) } | ||
set { } | ||
} | ||
} | ||
|
||
extension Image: KingfisherCompatible { } | ||
#if !os(watchOS) | ||
extension ImageView: KingfisherCompatible { } | ||
extension Button: KingfisherCompatible { } | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.