-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/#157 keyboard #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/#157 keyboard #170
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,74 +29,99 @@ struct TargetDdaySettingView: View { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Binding var month: String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Binding var day: String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Binding var warningMessage: String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @State private var keyboardHeight: CGFloat = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var body: some View { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ScrollView(.vertical, showsIndicators: false) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VStack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spacer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 50.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HStack(spacing:0){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VStack(alignment: .leading, spacing: 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TypographyText("ํ๋ณต์ ๊ณํํ ๋ ๊ณ ๋ คํด์ผ ํ ", style: .title1_sb_18, color: .gray1000) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 27.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TypographyText("์ค์ํ ์ผ์ ์ด ์๋์?", style: .title1_sb_18, color: .gray1000) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 27.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ScrollViewReader { proxy in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ScrollView(.vertical, showsIndicators: false) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VStack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spacer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 50.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HStack(spacing:0){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VStack(alignment: .leading, spacing: 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TypographyText("ํ๋ณต์ ๊ณํํ ๋ ๊ณ ๋ คํด์ผ ํ ", style: .title1_sb_18, color: .gray1000) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 27.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TypographyText("์ค์ํ ์ผ์ ์ด ์๋์?", style: .title1_sb_18, color: .gray1000) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 27.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spacer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spacer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spacer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 40.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HStack(spacing: 12.adjustedW) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ForEach(DdayState.allCases, id: \.self) { state in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SelectionChip( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: state.title, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isSelected: Binding( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| get: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dDayState == state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set: {isSelected in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard isSelected else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 40.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HStack(spacing: 12.adjustedW) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ForEach(DdayState.allCases, id: \.self) { state in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SelectionChip( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: state.title, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isSelected: Binding( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| get: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dDayState == state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set: {isSelected in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard isSelected else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dDayState = state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dDayState = state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spacer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 56.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if let state = dDayState { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HStack(spacing: 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VStack(alignment: .leading, spacing: 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch state { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case .yes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TypographyText("์ธ์ ๊น์ง ํ๋ณต์ด ์๋ฃ๋๋ฉด ์ข์๊น์?", style: .title1_sb_18, color: .gray1000) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 27.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case .no: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TypographyText("๋๋ต์ ์ธ ํ๋ณต ๋ชฉํ์ผ์ ์ ํด๋ณผ๊น์?", style: .title1_sb_18, color: .gray1000) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 27.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spacer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 56.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if let state = dDayState { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HStack(spacing: 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VStack(alignment: .leading, spacing: 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch state { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case .yes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TypographyText("์ธ์ ๊น์ง ํ๋ณต์ด ์๋ฃ๋๋ฉด ์ข์๊น์?", style: .title1_sb_18, color: .gray1000) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 27.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case .no: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TypographyText("๋๋ต์ ์ธ ํ๋ณต ๋ชฉํ์ผ์ ์ ํด๋ณผ๊น์?", style: .title1_sb_18, color: .gray1000) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 27.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spacer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spacer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 24.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DateTextBox(year: $year, month: $month, day: $day) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .id("inputField") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .padding(.bottom, 12.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TreatmentWarningMessgeView(text: warningMessage) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spacer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: keyboardHeight) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spacer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .frame(height: 24.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DateTextBox(year: $year, month: $month, day: $day) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .padding(.bottom, 12.adjustedH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TreatmentWarningMessgeView(text: warningMessage) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spacer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .padding(.horizontal, 34.adjustedW) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification)) { notification in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| keyboardHeight = keyboardFrame.height | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillHideNotification)) { _ in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| withAnimation(.easeOut(duration: 0.25)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| keyboardHeight = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .onChange(of: keyboardHeight) { _, newValue in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if newValue > 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| withAnimation(.easeOut(duration: 0.25)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| proxy.scrollTo("inputField", anchor: .center) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+107
to
122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐งฉ Analysis chain๐ Script executed: find . -name "TargetDdaySettingView.swift" -type f 2>/dev/nullRepository: TEAM-Cherrish/Cherrish-iOS Length of output: 170 ๐ Script executed: cat -n Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/Treatment/View/TargetDdaySettingView.swift | sed -n '100,130p'Repository: TEAM-Cherrish/Cherrish-iOS Length of output: 1342 ๐ Script executed: wc -l Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/Treatment/View/TargetDdaySettingView.swiftRepository: TEAM-Cherrish/Cherrish-iOS Length of output: 172 ๐ Script executed: cat -n Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/Treatment/View/TargetDdaySettingView.swift | head -50Repository: TEAM-Cherrish/Cherrish-iOS Length of output: 1826 ๐ Script executed: rg "keyboardHeight|keyboardWill" Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/Treatment/View/TargetDdaySettingView.swiftRepository: TEAM-Cherrish/Cherrish-iOS Length of output: 576 ๐ Web query:
๐ก Result: Short answer
Practical notes
Sources
๐ Web query:
๐ก Result: Short summary / recipe
Minimal example (Swift):
References
If you want, I can paste a ready-to-use Swift handler class using these practices. ๐ Web query:
๐ก Result: Short answer โ use the keyboardโs end frame in the keyboardโs coordinate space and convert it into your viewโs coordinate space, then take the intersection height with your view bounds (that intersection is the keyboard overlap / safe-area bottom inset to apply). This avoids orientation/rotation and homeโindicator double-counting. Recommended Swift pattern (concise):
Example: let info = notification.userInfo! Notes:
ํค๋ณด๋ ํ๋ ์ ๋ณ๊ฒฝ(ํ์ /ํ์ ์ ํ)์ ๋์ด๊ฐ ๊ฐฑ์ ๋์ง ์์ต๋๋ค.
๐ง ๊ฐ์ ์ ์- .onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification)) { notification in
- if let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect {
- keyboardHeight = keyboardFrame.height
- }
- }
- .onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillHideNotification)) { _ in
- withAnimation(.easeOut(duration: 0.25)) {
- keyboardHeight = 0
- }
- }
+ .onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillChangeFrameNotification)) { notification in
+ guard
+ let info = notification.userInfo,
+ let keyboardFrame = info[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect,
+ let duration = info[UIResponder.keyboardAnimationDurationUserInfoKey] as? Double
+ else { return }
+ let screenHeight = UIScreen.main.bounds.height
+ let height = max(0, screenHeight - keyboardFrame.minY)
+ withAnimation(.easeOut(duration: duration)) {
+ keyboardHeight = height
+ }
+ }๐ Committable suggestion
Suggested change
๐ค Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .padding(.horizontal, 34.adjustedW) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .scrollDismissesKeyboard(.interactively) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์์ฐ๊ตฟ ์๊ณ ํ์ จ์ต๋๋ค