forked from onevcat/Kingfisher
-
Notifications
You must be signed in to change notification settings - Fork 1
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 onevcat#1574 from onevcat/combine-pods
Merge SwiftUI support to the core library
- Loading branch information
Showing
17 changed files
with
94 additions
and
769 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
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
// | ||
// Delegate.swift | ||
// SwiftUIViewController.swift | ||
// Kingfisher | ||
// | ||
// Created by onevcat on 2018/10/10. | ||
// Created by onevcat on 2020/12/16. | ||
// | ||
// Copyright (c) 2019 Wei Wang <[email protected]> | ||
// Copyright (c) 2020 Wei Wang <[email protected]> | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
|
@@ -24,30 +24,16 @@ | |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import Foundation | ||
import SwiftUI | ||
import UIKit | ||
|
||
/// A delegate helper type to "shadow" weak `self`, to prevent creating an unexpected retain cycle. | ||
class Delegate<Input, Output> { | ||
init() {} | ||
|
||
private var block: ((Input) -> Output?)? | ||
|
||
func delegate<T: AnyObject>(on target: T, block: ((T, Input) -> Output)?) { | ||
// The `target` is weak inside block, so you do not need to worry about it in the caller side. | ||
self.block = { [weak target] input in | ||
guard let target = target else { return nil } | ||
return block?(target, input) | ||
} | ||
@available(iOS 13.0, *) | ||
class SwiftUIViewController: UIHostingController<MainView> { | ||
required init?(coder: NSCoder) { | ||
super.init(coder: coder,rootView: MainView()); | ||
} | ||
|
||
func call(_ input: Input) -> Output? { | ||
return block?(input) | ||
} | ||
} | ||
|
||
extension Delegate where Input == Void { | ||
// To make syntax better for `Void` input. | ||
func call() -> Output? { | ||
return call(()) | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
98 changes: 0 additions & 98 deletions
98
Demo/Demo/Kingfisher-SwiftUI-Demo/Assets.xcassets/AppIcon.appiconset/Contents.json
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
Demo/Demo/Kingfisher-SwiftUI-Demo/Assets.xcassets/Contents.json
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.