Skip to content

Commit

Permalink
Merge pull request #184 from YAPP-Github/feat/#171-ready-2.0
Browse files Browse the repository at this point in the history
feat: 2.0.0 μ€€λΉ„μž‘μ—…
  • Loading branch information
ShapeKim98 authored Jan 24, 2025
2 parents 5e3fdd3 + 4fdf986 commit 0f501e5
Show file tree
Hide file tree
Showing 32 changed files with 771 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Projects/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let shareExtensionTarget: Target = .target(
resources: ["ShareExtension/Resources/**"],
entitlements: .file(path: .relativeToRoot("Projects/App/ShareExtension/ShareExtension.entitlements")),
dependencies: [
.project(target: "FeatureLogin", path: .relativeToRoot("Projects/Feature")),
.project(target: "FeatureIntro", path: .relativeToRoot("Projects/Feature")),
.project(target: "FeatureContentSetting", path: .relativeToRoot("Projects/Feature")),
.project(target: "FeatureCategorySetting", path: .relativeToRoot("Projects/Feature"))
],
Expand Down
14 changes: 8 additions & 6 deletions Projects/App/Resources/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23086.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23076"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -17,18 +17,20 @@
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" ambiguous="YES" image="logo_pokit" translatesAutoresizingMaskIntoConstraints="NO" id="N4N-la-jgc">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" image="logo_pokit" translatesAutoresizingMaskIntoConstraints="NO" id="N4N-la-jgc">
<rect key="frame" x="79" y="313" width="235" height="72"/>
<color key="tintColor" name="text/inverseWh"/>
<constraints>
<constraint firstAttribute="height" constant="72" id="9zI-nL-qB4"/>
<constraint firstAttribute="height" constant="72" id="ZJY-IM-p0S"/>
<constraint firstAttribute="width" constant="235" id="zXd-Y5-GFp"/>
</constraints>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
<color key="backgroundColor" name="orange/700"/>
<constraints>
<constraint firstItem="N4N-la-jgc" firstAttribute="top" secondItem="Bcu-3y-fUS" secondAttribute="top" constant="254" id="kHx-5E-p7o"/>
<constraint firstItem="N4N-la-jgc" firstAttribute="top" secondItem="Bcu-3y-fUS" secondAttribute="top" constant="254" id="5x5-8D-gix"/>
<constraint firstItem="N4N-la-jgc" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="zAv-Q1-gIH"/>
</constraints>
</view>
</viewController>
Expand All @@ -40,7 +42,7 @@
<resources>
<image name="logo_pokit" width="235" height="72"/>
<namedColor name="orange/700">
<color red="0.99607843137254903" green="0.51764705882352946" blue="0.13333333333333333" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<color red="0.99607843137254903" green="0.51764705882352946" blue="0.13333333333333333" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="text/inverseWh">
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
Expand Down
2 changes: 1 addition & 1 deletion Projects/App/ShareExtension/Sources/ShareRootFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit
import UniformTypeIdentifiers

import ComposableArchitecture
import FeatureLogin
import FeatureIntro
import FeatureContentSetting
import FeatureCategorySetting
import CoreKit
Expand Down
2 changes: 1 addition & 1 deletion Projects/App/ShareExtension/Sources/ShareRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import SwiftUI

import ComposableArchitecture
import FeatureLogin
import FeatureIntro
import FeatureContentSetting
import FeatureCategorySetting
import DSKit
Expand Down
2 changes: 1 addition & 1 deletion Projects/App/Sources/Root/RootFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

import ComposableArchitecture
import FeatureLogin
import FeatureIntro
import CoreKit

@Reducer
Expand Down
2 changes: 1 addition & 1 deletion Projects/App/Sources/Root/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import SwiftUI

import ComposableArchitecture
import FeatureLogin
import FeatureIntro
import DSKit

public struct RootView: View {
Expand Down
12 changes: 6 additions & 6 deletions Projects/DSKit/Sources/Components/PokitHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import SwiftUI

import Util

public struct PokitHeader<Content: View>: View {
private let title: String?

Expand All @@ -28,12 +30,10 @@ public struct PokitHeader<Content: View>: View {
.padding(.horizontal, 20)
.padding(.vertical, 12)
.background(.pokit(.bg(.base)))
.overlay {
if let title {
Text(title)
.pokitFont(.title3)
.foregroundStyle(.pokit(.text(.primary)))
}
.overlay(ifLet: title) { title in
Text(title)
.pokitFont(.title3)
.foregroundStyle(.pokit(.text(.primary)))
}
}
}
Expand Down
16 changes: 7 additions & 9 deletions Projects/DSKit/Sources/Components/PokitList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,13 @@ public struct PokitList<Item: PokitSelectItem>: View {
}
.padding(.vertical, 12)
.padding(.horizontal, 20)
.background {
if isSelected {
Color.pokit(.bg(.primary))
.matchedGeometryEffect(id: "SELECT", in: heroEffect)
} else {
isDisabled
? Color.pokit(.bg(.disable))
: Color.pokit(.bg(.base))
}
.background(if: isSelected) {
Color.pokit(.bg(.primary))
.matchedGeometryEffect(id: "SELECT", in: heroEffect)
} else: {
isDisabled
? Color.pokit(.bg(.disable))
: Color.pokit(.bg(.base))
}
}
.animation(.pokitDissolve, value: isSelected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ public struct ContentCardFeature {
case 메타데이터_쑰회
}

@CasePathable
public enum InnerAction: Equatable {
case 메타데이터_쑰회_μˆ˜ν–‰_반영(String)
case 즐겨찾기_API_반영(Bool)
}

@CasePathable
public enum AsyncAction: Equatable {
case 메타데이터_쑰회_μˆ˜ν–‰
case 즐겨찾기_API
Expand Down Expand Up @@ -113,16 +115,16 @@ private extension ContentCardFeature {
case .컨텐츠_ν•­λͺ©_μΌ€λ°₯_λ²„νŠΌ_λˆŒλ €μ„λ•Œ:
return .send(.delegate(.컨텐츠_ν•­λͺ©_μΌ€λ°₯_λ²„νŠΌ_λˆŒλ €μ„λ•Œ(content: state.content)))
case .메타데이터_쑰회:
return .send(.async(.메타데이터_쑰회_μˆ˜ν–‰))
return shared(.async(.메타데이터_쑰회_μˆ˜ν–‰), state: &state)
case .즐겨찾기_λ²„νŠΌ_λˆŒλ €μ„λ•Œ:
guard let isFavorite = state.content.isFavorite else {
return .none
}
UIImpactFeedbackGenerator(style: .light)
.impactOccurred()
return isFavorite
? .send(.async(.즐겨찾기_μ·¨μ†Œ_API))
: .send(.async(.즐겨찾기_API))
? shared(.async(.즐겨찾기_μ·¨μ†Œ_API), state: &state)
: shared(.async(.즐겨찾기_API), state: &state)
}
}

Expand All @@ -131,7 +133,7 @@ private extension ContentCardFeature {
switch action {
case let .메타데이터_쑰회_μˆ˜ν–‰_반영(imageURL):
state.content.thumbNail = imageURL
return .send(.async(.썸넀일_μˆ˜μ •_API))
return shared(.async(.썸넀일_μˆ˜μ •_API), state: &state)
case .즐겨찾기_API_반영(let favorite):
state.content.isFavorite = favorite
return .none
Expand Down Expand Up @@ -164,10 +166,7 @@ private extension ContentCardFeature {
return .run { [content = state.content] _ in
let request = ThumbnailRequest(thumbnail: content.thumbNail)

try await contentClient.썸넀일_μˆ˜μ •(
contentId: "\(content.id)",
model: request
)
try await contentClient.썸넀일_μˆ˜μ •("\(content.id)", request)
}
}
}
Expand All @@ -181,4 +180,19 @@ private extension ContentCardFeature {
func handleDelegateAction(_ action: Action.DelegateAction, state: inout State) -> Effect<Action> {
return .none
}

func shared(_ action: Action, state: inout State) -> Effect<Action> {
switch action {
case .view(let viewAction):
return handleViewAction(viewAction, state: &state)
case .inner(let innerAction):
return handleInnerAction(innerAction, state: &state)
case .async(let asyncAction):
return handleAsyncAction(asyncAction, state: &state)
case .scope(let scopeAction):
return handleScopeAction(scopeAction, state: &state)
case .delegate(let delegateAction):
return handleDelegateAction(delegateAction, state: &state)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,87 @@
import ComposableArchitecture
import XCTest
import Domain
import CoreKit

@testable import FeatureContentCard

final class FeatureContentCardTests: XCTestCase {
func test() {
final class SendTests: XCTestCase {

func test_primeTest() async {
let count = 10
var sharedAverage: CFAbsoluteTime = 0.0
for _ in 0..<count {
await test_shared_λ©”μ„œλ“œ_적용(&sharedAverage)
}

var noSharedAverage: CFAbsoluteTime = 0.0
for _ in 0..<count {
await test_shared_λ©”μ„œλ“œ_미적용(&noSharedAverage)
}

print(
"shared_λ©”μ„œλ“œ_적용 \(count)번 ν…ŒμŠ€νŠΈ 평균 μ†Œμš”μ‹œκ°„",
sharedAverage / CFAbsoluteTime(count)
)
print(
"shared_λ©”μ„œλ“œ_미적용 \(count)번 ν…ŒμŠ€νŠΈ 평균 μ†Œμš”μ‹œκ°„",
noSharedAverage / CFAbsoluteTime(count)
)
}

@MainActor
func test_shared_λ©”μ„œλ“œ_적용(_ average: inout CFAbsoluteTime) async {
let store = TestStore(initialState: ContentCardFeature.State(
content: ContentBaseResponse.mock(id: 0).toDomain()
)) {
ContentCardFeature()._printChanges(.actionLabels)
} withDependencies: {
$0[ContentClient.self] = .testValue
let parseOGImageURL: @Sendable (
_ url: URL
) async throws -> String? = { _ in
"https://i.ytimg.com/vi/wtSwdGJzQCQ/maxresdefault.jpg"
}

$0[SwiftSoupClient.self].parseOGImageURL = parseOGImageURL
}

let start = CFAbsoluteTimeGetCurrent()
await store.send(.view(.메타데이터_쑰회))
await store.receive(\.inner.메타데이터_쑰회_μˆ˜ν–‰_반영) {
$0.content.thumbNail = "https://i.ytimg.com/vi/wtSwdGJzQCQ/maxresdefault.jpg"
}
let end = CFAbsoluteTimeGetCurrent()
average += end - start
}

@MainActor
func test_shared_λ©”μ„œλ“œ_미적용(_ average: inout CFAbsoluteTime) async {
let store = TestStore(initialState: LegacyContentCardFeature.State(
content: ContentBaseResponse.mock(id: 0).toDomain()
)) {
LegacyContentCardFeature()._printChanges(.actionLabels)
} withDependencies: {
$0[ContentClient.self] = .testValue
let parseOGImageURL: @Sendable (
_ url: URL
) async throws -> String? = { _ in
"https://i.ytimg.com/vi/wtSwdGJzQCQ/maxresdefault.jpg"
}

$0[SwiftSoupClient.self].parseOGImageURL = parseOGImageURL
}

let start = CFAbsoluteTimeGetCurrent()
await store.send(.view(.메타데이터_쑰회))
await store.receive(\.async.메타데이터_쑰회_μˆ˜ν–‰)
await store.receive(\.inner.메타데이터_쑰회_μˆ˜ν–‰_반영) {
$0.content.thumbNail = "https://i.ytimg.com/vi/wtSwdGJzQCQ/maxresdefault.jpg"
}
await store.receive(\.async.썸넀일_μˆ˜μ •_API)
let end = CFAbsoluteTimeGetCurrent()
average += end - start
}
}


Loading

0 comments on commit 0f501e5

Please sign in to comment.