Skip to content

Commit

Permalink
chore: 示例代码适配 Swift6
Browse files Browse the repository at this point in the history
  • Loading branch information
l1Dan committed Sep 30, 2024
1 parent 83e5454 commit 7e9db3f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Examples/NXNavigationExtensionDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
PRODUCT_BUNDLE_IDENTIFIER = io.github.l1dan.NXNavigationExtensionDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -227,7 +227,7 @@
PRODUCT_BUNDLE_IDENTIFIER = io.github.l1dan.NXNavigationExtensionDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ extension UIApplication {

extension UIImage {

@MainActor
static var navigationBarBackground: UIImage? {
let statusBarHeight = UIApplication.shared.statusBarHeight
return statusBarHeight <= 20.0 ? UIImage(named: "NavigationBarBackground64") : UIImage(named: "NavigationBarBackground88")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,24 @@ class ViewController06_WebView: BaseViewController, WKNavigationDelegate {
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(clickAddButton(_:)))

estimatedProgressObservation = webView.observe(\.self.estimatedProgress, options: .new) { [weak self] webView, value in
self?.progressView.alpha = 1.0
self?.progressView.setProgress(Float(webView.estimatedProgress), animated: true)

if webView.estimatedProgress >= 1.0 {
UIView.animate(withDuration: 0.3, delay: 0.3, options: .curveEaseOut) {
self?.progressView.alpha = 0.0
} completion: { finished in
self?.progressView.setProgress(0.0, animated: true)
Task { @MainActor in
self?.progressView.alpha = 1.0
self?.progressView.setProgress(Float(webView.estimatedProgress), animated: true)

if webView.estimatedProgress >= 1.0 {
UIView.animate(withDuration: 0.3, delay: 0.3, options: .curveEaseOut) {
self?.progressView.alpha = 0.0
} completion: { finished in
self?.progressView.setProgress(0.0, animated: true)
}
}
}
}

titleObservation = webView.observe(\.self.title, options: .new, changeHandler: { [weak self] webView, value in
self?.navigationItem.title = webView.title
Task { @MainActor in
self?.navigationItem.title = webView.title
}
})

if UIDevice.isPhoneDevice {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit

@MainActor
protocol FakeNavigationBarDelegate: AnyObject {
func fakeNavigationBar(_ navigationBar: FakeNavigationBar, didClickNavigationItemWith itemType: FakeNavigationBar.ItemType)
}
Expand Down Expand Up @@ -79,7 +80,7 @@ class FakeNavigationBar: UIView {
backgroundColor = .clear
titleLabel.alpha = 0.0

[backButton, titleLabel, rightButton].forEach(addSubview)
try? [backButton, titleLabel, rightButton].forEach(addSubview)

backButton.isHidden = !UIDevice.isPhoneDevice
NSLayoutConstraint.activate([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit

@MainActor
class SlidingAnimationController: NSObject {
private lazy var backgroundColorView: UIVisualEffectView = {
var effect = UIBlurEffect(style: .extraLight)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit

@MainActor
protocol SlidingInteractiveNavigation {
var swipeDirectionAction: SlidingSwipeDirectionAction { get }
}
Expand All @@ -17,6 +18,7 @@ enum SlidingSwipeDirectionAction {
}


@MainActor
fileprivate class SlidingNavigationManager: NSObject {
static let `default` = SlidingNavigationManager()

Expand Down

0 comments on commit 7e9db3f

Please sign in to comment.