-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ✨ Make lineHeight optional in FontModifier * ✨ Prepare SwiftUI colors bridge * 🔥 Ditch static theme * ♻️ Publish SwiftUIColorsTheme subscript * ✨ Add ACKHostingController * ♻️ Make ACKHostingController subclass of UIHostingController * 📝 Update CHANGELOG
- Loading branch information
Showing
12 changed files
with
126 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
15.2 | ||
15.4 |
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
53 changes: 53 additions & 0 deletions
53
Sources/ACKategories/SwiftUIExtensions/ACKHostingController.swift
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,53 @@ | ||
#if !os(macOS) && !os(watchOS) | ||
import os.log | ||
import SwiftUI | ||
|
||
@available(iOS 13.0, tvOS 13.0, *) | ||
open class ACKHostingController<RootView: View>: UIHostingController<RootView> { | ||
/// Navigation bar is shown/hidden in viewWillAppear according to this flag | ||
public var hasNavigationBar = true | ||
|
||
#if !os(tvOS) | ||
public override var preferredStatusBarStyle: UIStatusBarStyle { | ||
get { _preferredStatusBarStyle } | ||
set { | ||
_preferredStatusBarStyle = newValue | ||
setNeedsStatusBarAppearanceUpdate() | ||
} | ||
} | ||
|
||
private var _preferredStatusBarStyle: UIStatusBarStyle = .default | ||
#endif | ||
|
||
// MARK: - Initializers | ||
|
||
public override init(rootView: RootView) { | ||
super.init(rootView: rootView) | ||
|
||
navigationItem.backButtonTitle = "" | ||
|
||
if Base.memoryLoggingEnabled && Base.viewControllerMemoryLoggingEnabled { | ||
os_log("📱 👶 %@", log: Logger.lifecycleLog(), type: .info, self) | ||
} | ||
} | ||
|
||
@available(*, unavailable) | ||
public required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
deinit { | ||
if Base.memoryLoggingEnabled && Base.viewControllerMemoryLoggingEnabled { | ||
os_log("📱 ⚰️ %@", log: Logger.lifecycleLog(), type: .info, self) | ||
} | ||
} | ||
|
||
// MARK: - View life cycle | ||
|
||
override open func viewWillAppear(_ animated: Bool) { | ||
super.viewWillAppear(animated) | ||
|
||
navigationController?.setNavigationBarHidden(!hasNavigationBar, animated: animated) | ||
} | ||
} | ||
#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
33 changes: 33 additions & 0 deletions
33
Sources/ACKategories/SwiftUIExtensions/SwiftUIColorsTheme.swift
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,33 @@ | ||
#if canImport(UIKit) | ||
import SwiftUI | ||
import UIKit | ||
|
||
/// Using this namespace you can define your colors in ``Theme`` extension of `UIColor` | ||
/// and they will automatically appear in `Color.theme` namespace. | ||
/// | ||
/// Make sure your extensions are not defined as static, only instance variables with type `UIColor` will be bridged. | ||
/// | ||
/// ## Example | ||
/// | ||
/// ```swift | ||
/// extension Theme<UIColor> { | ||
/// var primary: UIColor { .red } | ||
/// } | ||
/// ``` | ||
/// | ||
/// Then you can use `Color.theme.primary` in SwiftUI | ||
@available(iOS 14.0, tvOS 14.0, watchOS 7.0, *) | ||
@dynamicMemberLookup | ||
public struct SwiftUIColorsTheme { | ||
public subscript(dynamicMember keyPath: KeyPath<Theme<UIColor>, UIColor>) -> SwiftUI.Color { | ||
let uiColor = Theme<UIColor>()[keyPath: keyPath] | ||
return .init(uiColor) | ||
} | ||
} | ||
|
||
@available(iOS 14.0, tvOS 14.0, watchOS 7.0, *) | ||
public extension Color { | ||
/// Namespace for bridged ``Theme`` colors from `Theme<UIColor>` extension, see ``SwiftUIColorsTheme``. | ||
static let theme = SwiftUIColorsTheme() | ||
} | ||
#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