-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: - Fixed a problem with native sheets covering popups (#110) - Fixed a problem with popups retaining previous @State object (#101) - Fixed a problem with KeyboardManager publishing its state outside the main thread (#120) - Fixed a problem with PopupView that was changing the position of elements (#122)
- Loading branch information
1 parent
1412c1f
commit 56c06db
Showing
14 changed files
with
158 additions
and
27 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
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,43 @@ | ||
// | ||
// ID.swift of PopupView | ||
// | ||
// Created by Tomasz Kurylik | ||
// - Twitter: https://twitter.com/tkurylik | ||
// - Mail: [email protected] | ||
// - GitHub: https://github.com/FulcrumOne | ||
// | ||
// Copyright ©2024 Mijick. Licensed under MIT License. | ||
|
||
|
||
import Foundation | ||
|
||
public struct ID { | ||
let value: String | ||
} | ||
|
||
// MARK: - Initialisers | ||
extension ID { | ||
init<P: Popup>(_ object: P) { self.init(P.self) } | ||
init<P: Popup>(_ type: P.Type) { self.value = .init(describing: P.self) + Self.separator + .init(describing: Date()) } | ||
init() { self.value = "" } | ||
} | ||
|
||
// MARK: - Equatable | ||
extension ID: Equatable { | ||
public static func ==(lhs: Self, rhs: Self) -> Bool { lhs.value == rhs.value } | ||
public static func ~=(lhs: Self, rhs: Self) -> Bool { getComponent(lhs) == getComponent(rhs) } | ||
} | ||
|
||
// MARK: - Hashing | ||
extension ID: Hashable { | ||
public func hash(into hasher: inout Hasher) { hasher.combine(Self.getComponent(self)) } | ||
} | ||
|
||
|
||
// MARK: - Helpers | ||
private extension ID { | ||
static func getComponent(_ object: Self) -> String { object.value.components(separatedBy: separator).first ?? "" } | ||
} | ||
private extension ID { | ||
static var separator: String { "/{}/" } | ||
} |
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
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,44 @@ | ||
// | ||
// Public+PopupSceneDelegate.swift of PopupView | ||
// | ||
// Created by Tomasz Kurylik | ||
// - Twitter: https://twitter.com/tkurylik | ||
// - Mail: [email protected] | ||
// - GitHub: https://github.com/FulcrumOne | ||
// | ||
// Copyright ©2024 Mijick. Licensed under MIT License. | ||
|
||
|
||
import SwiftUI | ||
|
||
#if os(iOS) | ||
open class PopupSceneDelegate: NSObject, UIWindowSceneDelegate { | ||
open var window: UIWindow? | ||
open var config: (GlobalConfig) -> (GlobalConfig) = { _ in .init() } | ||
} | ||
|
||
// MARK: - Creating Popup Scene | ||
extension PopupSceneDelegate { | ||
open func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { if let windowScene = scene as? UIWindowScene { | ||
let hostingController = UIHostingController(rootView: Rectangle() | ||
.fill(Color.clear) | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
.implementPopupView(config: config) | ||
) | ||
hostingController.view.backgroundColor = .clear | ||
|
||
window = Window(windowScene: windowScene) | ||
window?.rootViewController = hostingController | ||
window?.isHidden = false | ||
}} | ||
} | ||
|
||
|
||
// MARK: - Helpers | ||
fileprivate class Window: UIWindow { | ||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { | ||
guard let view = super.hitTest(point, with: event) else { return nil } | ||
return rootViewController?.view == view ? nil : view | ||
} | ||
} | ||
#endif |