Skip to content

Commit

Permalink
feature: 기능 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
devMinseok committed Aug 16, 2024
1 parent 9fa2f3d commit 123f85d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// FeedbackGeneratorClientInterface.swift
// FeedbackGeneratorClient
//
// Created by devMinseok on 8/16/24.
//

import UIKit

import Dependencies
import DependenciesMacros

@DependencyClient
public struct FeedbackGeneratorClient {
public var notification: @Sendable (UINotificationFeedbackGenerator.FeedbackType) async -> Void
public var selectionChanged: @Sendable () async -> Void
public var impactOccurred: @Sendable (UIImpactFeedbackGenerator.FeedbackStyle) async -> Void
}

extension FeedbackGeneratorClient: TestDependencyKey {
public static let previewValue = Self()
public static let testValue = Self()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// FeedbackGeneratorClient.swift
// FeedbackGeneratorClient
//
// Created by devMinseok on 8/16/24.
//

import UIKit

import FeedbackGeneratorClientInterface

import Dependencies

extension FeedbackGeneratorClient: DependencyKey {
public static let liveValue: FeedbackGeneratorClient = .live()

public static func live() -> FeedbackGeneratorClient {
return .init(
notification: { type in
let generator = await UINotificationFeedbackGenerator()
await generator.notificationOccurred(type)
},
selectionChanged: {
let generator = await UISelectionFeedbackGenerator()
await generator.selectionChanged()
},
impactOccurred: { style in
let generator = await UIImpactFeedbackGenerator(style: style)
await generator.impactOccurred()
}
)
}
}

0 comments on commit 123f85d

Please sign in to comment.