-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CAT-231] FeedbackGeneratorClient 모듈 추가 (#27)
- Loading branch information
1 parent
205135d
commit fb3032d
Showing
20 changed files
with
299 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...eedbackGeneratorClient/Example/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Projects/Core/FeedbackGeneratorClient/Example/Resources/Assets.xcassets/contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+1.58 MB
Projects/Core/FeedbackGeneratorClient/Example/Resources/Font/Pretendard-Bold.otf
Binary file not shown.
Binary file added
BIN
+1.59 MB
Projects/Core/FeedbackGeneratorClient/Example/Resources/Font/Pretendard-Medium.otf
Binary file not shown.
Binary file added
BIN
+1.58 MB
Projects/Core/FeedbackGeneratorClient/Example/Resources/Font/Pretendard-Regular.otf
Binary file not shown.
Binary file added
BIN
+1.59 MB
Projects/Core/FeedbackGeneratorClient/Example/Resources/Font/Pretendard-SemiBold.otf
Binary file not shown.
48 changes: 48 additions & 0 deletions
48
Projects/Core/FeedbackGeneratorClient/Example/Resources/LaunchScreen.storyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
98 changes: 98 additions & 0 deletions
98
Projects/Core/FeedbackGeneratorClient/Example/Sources/ContentView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
17 changes: 17 additions & 0 deletions
17
Projects/Core/FeedbackGeneratorClient/Example/Sources/FeedbackGeneratorClientApp.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Projects/Core/FeedbackGeneratorClient/Interface/FeedbackGeneratorClientInterface.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
] | ||
] | ||
) |
33 changes: 33 additions & 0 deletions
33
Projects/Core/FeedbackGeneratorClient/Sources/FeedbackGeneratorClient.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters