Skip to content

Commit 61753ec

Browse files
committed
[feat] #193 KeyboardClient ์ถ”๊ฐ€
- ํ‚ค๋ณด๋“œ๊ฐ€ ๋‚˜ํƒ€๋‚˜๊ณ  ์‚ฌ๋ผ์ง€๋Š” ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›์•„ ํŒจ๋”ฉ๊ฐ’์„ ์„ค์ •ํ•ด์ฃผ๊ธฐ ์œ„ํ•ด ์ถ”๊ฐ€
1 parent 3d0fe2a commit 61753ec

File tree

4 files changed

+80
-3
lines changed

4 files changed

+80
-3
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// KeyboardClient+LiveKey.swift
3+
// CoreKit
4+
//
5+
// Created by ๊น€๋ฏผํ˜ธ on 3/31/25.
6+
//
7+
8+
import UIKit
9+
import Combine
10+
import Dependencies
11+
12+
extension KeyboardClient: DependencyKey {
13+
public static let liveValue: Self = {
14+
.init(
15+
isVisible: {
16+
AsyncStream { continuation in
17+
let notificationCenter = NotificationCenter.default
18+
19+
let showObserver = notificationCenter
20+
.publisher(for: UIResponder.keyboardWillShowNotification)
21+
.map { _ in true }
22+
23+
let hideObserver = notificationCenter
24+
.publisher(for: UIResponder.keyboardWillHideNotification)
25+
.map { _ in false }
26+
27+
let cancellable = Publishers.Merge(showObserver, hideObserver)
28+
.removeDuplicates()
29+
.sink { isVisible in
30+
continuation.yield(isVisible)
31+
}
32+
33+
continuation.onTermination = { _ in cancellable.cancel() }
34+
}
35+
}
36+
)
37+
}()
38+
}
39+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// KeyboardClient+TestKey.swift
3+
// CoreKit
4+
//
5+
// Created by ๊น€๋ฏผํ˜ธ on 3/31/25.
6+
//
7+
8+
import Foundation
9+
10+
import Dependencies
11+
12+
extension KeyboardClient: TestDependencyKey {
13+
public static let previewValue = Self.noop
14+
}
15+
16+
extension KeyboardClient {
17+
public static let noop = Self(
18+
isVisible: { .finished }
19+
)
20+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// KeyboardClient.swift
3+
// CoreKit
4+
//
5+
// Created by ๊น€๋ฏผํ˜ธ on 3/31/25.
6+
//
7+
8+
import Foundation
9+
10+
import DependenciesMacros
11+
12+
@DependencyClient
13+
public struct KeyboardClient: Sendable {
14+
public var isVisible: @Sendable () async -> AsyncStream<Bool> = { .finished }
15+
}

โ€ŽProjects/Feature/FeatureCategorySetting/Sources/PokitCategorySettingView.swiftโ€Ž

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ public extension PokitCategorySettingView {
3737
openTypeSettingSection
3838
keywordSection
3939
Spacer()
40+
}
41+
.padding(.top, 16)
42+
.pokitNavigationBar { navigationBar }
43+
.overlay(alignment: .bottom) {
4044
saveButton
45+
.padding(.bottom, store.isKeyboardVisible ? -26 : 0)
4146
}
4247
.padding(.horizontal, 20)
43-
.padding(.top, 16)
4448
.pokitMaxWidth()
45-
.pokitNavigationBar { navigationBar }
46-
.ignoresSafeArea(edges: isFocused ? [] : .bottom)
49+
.ignoresSafeArea(.container, edges: .bottom)
4750
.sheet(isPresented: $store.isProfileSheetPresented) {
4851
PokitProfileBottomSheet(
4952
selectedImage: store.selectedProfile,

0 commit comments

Comments
ย (0)