Skip to content

Commit

Permalink
[CAT-231] FeedbackGeneratorClient 모듈 추가 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
devMinseok authored Aug 16, 2024
1 parent 205135d commit fb3032d
Show file tree
Hide file tree
Showing 20 changed files with 299 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ public enum Core: String, Modulable {
case UserNotificationClient
case DatabaseClient
case UserDefaultsClient
case FeedbackGeneratorClient
}
7 changes: 7 additions & 0 deletions Projects/Core/APIClient/Project.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//
// Project.swift
// APIClientManifests
//
// Created by devMinseok on 8/16/24.
//

import ProjectDescription
import ProjectDescriptionHelpers

Expand Down
7 changes: 7 additions & 0 deletions Projects/Core/Core/Project.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//
// Project.swift
// CoreManifests
//
// Created by devMinseok on 8/16/24.
//

import ProjectDescription
import ProjectDescriptionHelpers

Expand Down
2 changes: 1 addition & 1 deletion Projects/Core/DatabaseClient/Project.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// DatabaseClientTesting.swift
// Project.swift
// DatabaseClientManifests
//
// Created by devMinseok on 7/27/24.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"images" : [
{
"filename" : "ICON_DEMO.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13142" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12042"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
<rect key="frame" x="0.0" y="626.5" width="375" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="FeedbackGeneratorClient 모듈 데모앱" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
<rect key="frame" x="0.0" y="202" width="375" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
<constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" constant="20" symbolic="YES" id="SfN-ll-jLj"/>
<constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" constant="20" symbolic="YES" id="x7j-FC-K8j"/>
</constraints>
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//
// ContentView.swift
// FeedbackGeneratorClient
//
// Created by devMinseok on 8/16/24.
//

import SwiftUI

import Dependencies
import FeedbackGeneratorClientInterface

struct ContentView: View {
@Dependency(FeedbackGeneratorClient.self) var feedbackGeneratorClient

var body: some View {
NavigationStack {
List {
Button {
Task {
await feedbackGeneratorClient.impactOccurred(.heavy)
}
} label: {
Text("impactOccurred: heavy")
}

Button {
Task {
await feedbackGeneratorClient.impactOccurred(.light)
}
} label: {
Text("impactOccurred: light")
}

Button {
Task {
await feedbackGeneratorClient.impactOccurred(.medium)
}
} label: {
Text("impactOccurred: medium")
}

Button {
Task {
await feedbackGeneratorClient.impactOccurred(.rigid)
}
} label: {
Text("impactOccurred: rigid")
}

Button {
Task {
await feedbackGeneratorClient.impactOccurred(.soft)
}
} label: {
Text("impactOccurred: soft")
}

Button {
Task {
await feedbackGeneratorClient.notification(.error)
}
} label: {
Text("notification: error")
}

Button {
Task {
await feedbackGeneratorClient.notification(.success)
}
} label: {
Text("notification: success")
}

Button {
Task {
await feedbackGeneratorClient.notification(.warning)
}
} label: {
Text("notification: warning")
}

Button {
Task {
await feedbackGeneratorClient.selectionChanged()
}
} label: {
Text("selectionChanged")
}
}
.navigationTitle("FeedbackGenerator")
}
}
}

#Preview {
ContentView()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// FeedbackGeneratorClientApp.swift
// FeedbackGeneratorClient
//
// Created by devMinseok on 8/16/24.
//

import SwiftUI

@main
struct FeedbackGeneratorClientApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
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()
}
28 changes: 28 additions & 0 deletions Projects/Core/FeedbackGeneratorClient/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Project.swift
// FeedbackGeneratorClientManifests
//
// Created by devMinseok on 8/16/24.
//

import ProjectDescription
import ProjectDescriptionHelpers

@_spi(Core)
@_spi(Shared)
import DependencyPlugin

let project: Project = .makeTMABasedProject(
module: Core.FeedbackGeneratorClient,
scripts: [],
targets: [
.sources,
.interface,
.example
],
dependencies: [
.interface: [
.dependency(rootModule: Shared.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()
}
)
}
}
7 changes: 7 additions & 0 deletions Projects/Core/KeychainClient/Project.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//
// Project.swift
// KeychainClientManifests
//
// Created by devMinseok on 8/16/24.
//

import ProjectDescription
import ProjectDescriptionHelpers

Expand Down
2 changes: 1 addition & 1 deletion Projects/Core/UserDefaultsClient/Project.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// UserDefaultsClientTesting.swift
// Project.swift
// UserDefaultsClientManifests
//
// Created by devMinseok on 8/4/24.
Expand Down
7 changes: 7 additions & 0 deletions Projects/Core/UserNotificationClient/Project.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//
// Project.swift
// UserNotificationClientManifests
//
// Created by devMinseok on 8/16/24.
//

import ProjectDescription
import ProjectDescriptionHelpers

Expand Down
2 changes: 1 addition & 1 deletion Tuist/Templates/Framework/Stencil/Project.stencil
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// {{ name }}Testing.swift
// Project.swift
// {{ name }}Manifests
//
// Created by <#T##Author name#> on {{ nowDate }}.
Expand Down

0 comments on commit fb3032d

Please sign in to comment.