Skip to content

Commit

Permalink
feat(dependencies): UIDeviceClient
Browse files Browse the repository at this point in the history
  • Loading branch information
tomokisun committed Aug 24, 2024
1 parent b93ebc9 commit 5fedb7f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Packages/Dependencies/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ var package = Package(
.library(name: "ScreenshotClient", targets: ["ScreenshotClient"]),
.library(name: "StoreKitClient", targets: ["StoreKitClient"]),
.library(name: "UIApplicationClient", targets: ["UIApplicationClient"]),
.library(name: "UIDeviceClient", targets: ["UIDeviceClient"]),
.library(name: "UIDeviceClientLive", targets: ["UIDeviceClientLive"]),
.library(name: "UIPasteboardClient", targets: ["UIPasteboardClient"]),
.library(name: "UserDefaultsClient", targets: ["UserDefaultsClient"]),
.library(name: "UserNotificationClient", targets: ["UserNotificationClient"]),
Expand Down Expand Up @@ -166,6 +168,13 @@ var package = Package(
.product(name: "Dependencies", package: "swift-dependencies"),
.product(name: "DependenciesMacros", package: "swift-dependencies"),
]),
.target(name: "UIDeviceClient", dependencies: [
.product(name: "Dependencies", package: "swift-dependencies"),
.product(name: "DependenciesMacros", package: "swift-dependencies"),
]),
.target(name: "UIDeviceClientLive", dependencies: [
"UIDeviceClient",
]),
.target(name: "UIPasteboardClient", dependencies: [
.product(name: "Dependencies", package: "swift-dependencies"),
.product(name: "DependenciesMacros", package: "swift-dependencies"),
Expand Down
7 changes: 7 additions & 0 deletions Packages/Dependencies/Sources/UIDeviceClient/Client.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Dependencies
import DependenciesMacros

@DependencyClient
public struct UIDeviceClient {
public var systemVersion: @Sendable () -> String { "0.0" }
}
12 changes: 12 additions & 0 deletions Packages/Dependencies/Sources/UIDeviceClient/TestKey.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Dependencies

extension UIDeviceClient: TestDependencyKey {
public static let testValue = Self()
}

public extension DependencyValues {
var device: UIDeviceClient {
get { self[UIDeviceClient.self] }
set { self[UIDeviceClient.self] = newValue }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import UIKit
import Dependencies
import UIDeviceClient

extension UIDeviceClient: DependencyKey {
public static let liveValue = UIDeviceClient(
systemVersion: { UIDevice.current.systemVersion }
)
}

0 comments on commit 5fedb7f

Please sign in to comment.