Skip to content

Commit cd2b6b1

Browse files
committed
[add] strict concurrency checking
1 parent ea2d605 commit cd2b6b1

9 files changed

+32
-14
lines changed

Package.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.5
1+
// swift-tools-version: 5.9
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
@@ -12,7 +12,10 @@ let package = Package(
1212
.library(name: "TabBarModule", targets: ["TabBarModule"])
1313
],
1414
targets: [
15-
.target(name: "TabBarModule"),
15+
.target(
16+
name: "TabBarModule",
17+
swiftSettings: [.enableExperimentalFeature("StrictConcurrency")]
18+
),
1619
.testTarget(name: "TabBarTests", dependencies: ["TabBarModule"]),
1720
]
1821
)

[email protected]

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// swift-tools-version: 5.5
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "swiftui-tab-bar",
8+
platforms: [
9+
.iOS(.v15)
10+
],
11+
products: [
12+
.library(name: "TabBarModule", targets: ["TabBarModule"])
13+
],
14+
targets: [
15+
.target(name: "TabBarModule"),
16+
.testTarget(name: "TabBarTests", dependencies: ["TabBarModule"]),
17+
]
18+
)

Sources/TabBarModule/Internal/EnvironmentKey/BarFillStyleEnvironmentKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import SwiftUI
1212

1313
struct BarFillStyleEnvironmentKey: EnvironmentKey {
14-
static var defaultValue: FillStyle = .init()
14+
static var defaultValue: FillStyle { .init() }
1515
}
1616

1717
extension EnvironmentValues {

Sources/TabBarModule/Internal/EnvironmentKey/BarShadowEnvironmentKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import SwiftUI
1212

1313
struct BarShadowEnvironmentKey: EnvironmentKey {
14-
static var defaultValue: Shadow = .init(color: .clear, radius: 0, x: 0, y: 0)
14+
static var defaultValue: Shadow { .init(color: .clear, radius: 0, x: 0, y: 0) }
1515
}
1616

1717
struct Shadow {

Sources/TabBarModule/Internal/EnvironmentKey/BarShapeEnvironmentKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import SwiftUI
1212

1313
struct BarShapeEnvironmentKey: EnvironmentKey {
14-
static var defaultValue: (any Shape)? = nil
14+
static var defaultValue: (any Shape)? { nil }
1515
}
1616

1717
extension EnvironmentValues {

Sources/TabBarModule/Internal/EnvironmentKey/BarShapeStyleEnvironmentKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import SwiftUI
1212

1313
struct BarShapeStyleEnvironmentKey: EnvironmentKey {
14-
static var defaultValue: AnyShapeStyle = .init(Material.bar)
14+
static var defaultValue: AnyShapeStyle { .init(Material.bar) }
1515
}
1616

1717
extension EnvironmentValues {

Sources/TabBarModule/Internal/EnvironmentKey/BarSpacingEnvironmentKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import SwiftUI
1212

1313
struct BarSpacingEnvironmentKey: EnvironmentKey {
14-
static var defaultValue: CGFloat? = nil
14+
static var defaultValue: CGFloat? { nil }
1515
}
1616

1717
extension EnvironmentValues {

Sources/TabBarModule/Internal/KeyboardObserver.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import SwiftUI
1212

13+
@MainActor
1314
class KeyboardObserver: ObservableObject {
1415
static let shared: KeyboardObserver = .init()
1516

@@ -18,16 +19,12 @@ class KeyboardObserver: ObservableObject {
1819
private init() {
1920
NotificationCenter.default
2021
.addObserver(forName: UIResponder.keyboardWillShowNotification, object: nil, queue: .main) { _ in
21-
Task {
22-
await MainActor.run { self.keyboardWillShow = true }
23-
}
22+
Task { @MainActor in self.keyboardWillShow = true }
2423
}
2524

2625
NotificationCenter.default
2726
.addObserver(forName: UIResponder.keyboardWillHideNotification, object: nil, queue: .main) { _ in
28-
Task {
29-
await MainActor.run { self.keyboardWillShow = false }
30-
}
27+
Task { @MainActor in self.keyboardWillShow = false }
3128
}
3229
}
3330
}

Sources/TabBarModule/Public/TabBarHeightPreferenceKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import SwiftUI
4444
/// ```
4545
///
4646
public struct TabBarHeightPreferenceKey: PreferenceKey {
47-
public static var defaultValue: CGFloat = .zero
47+
public static var defaultValue: CGFloat { .zero }
4848
public static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
4949
value = max(value, nextValue())
5050
}

0 commit comments

Comments
 (0)