-
Notifications
You must be signed in to change notification settings - Fork 0
[#145] 시트에 툴바를 통해 cancel, confirm 버튼을 구성한다 #153
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
912cc98
ui: iOS 26 기준 파란색 제거
opficdev b10e57f
ui: SheetToolbar 구현 및 적용
opficdev 5e481b3
ui: 인디케이터 보이게 하기
opficdev d9e493b
ui: adaptiveButtonStyle에 모양 지정과 ios 18이하에서는 클리어가 아닐 때는 material 적용 X
opficdev 0849c29
ui: .accentColor -> .blue
opficdev 5e10e2a
ui: 개선된 adaptiveButtonStyle 적용
opficdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,59 @@ | ||
| // | ||
| // SheetToolbar.swift | ||
| // DevLog | ||
| // | ||
| // Created by 최윤진 on 2/27/26. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| struct SheetToolbar: ToolbarContent { | ||
| let onCancel: () -> Void | ||
| let onConfirm: () -> Void | ||
| let isConfirmEnabled: Bool | ||
|
|
||
| init( | ||
| onCancel: @escaping () -> Void, | ||
| onConfirm: @escaping () -> Void, | ||
| isConfirmEnabled: Bool = true | ||
| ) { | ||
| self.onCancel = onCancel | ||
| self.onConfirm = onConfirm | ||
| self.isConfirmEnabled = isConfirmEnabled | ||
| } | ||
|
|
||
| var body: some ToolbarContent { | ||
| if #available(iOS 26.0, *) { | ||
| ToolbarItem(placement: .topBarLeading) { | ||
| Button(role: .cancel) { | ||
| onCancel() | ||
| } | ||
| } | ||
|
|
||
| ToolbarItem(placement: .topBarTrailing) { | ||
| Button(role: .confirm) { | ||
| onConfirm() | ||
| } | ||
| .disabled(!isConfirmEnabled) | ||
| } | ||
| } else { | ||
| ToolbarItem(placement: .topBarLeading) { | ||
| Button { | ||
| onCancel() | ||
| } label: { | ||
| Text("취소") | ||
| } | ||
| } | ||
|
|
||
| ToolbarItem(placement: .topBarTrailing) { | ||
| Button { | ||
| onConfirm() | ||
| } label: { | ||
| Text("확인") | ||
| .bold() | ||
| } | ||
| .disabled(!isConfirmEnabled) | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -9,25 +9,31 @@ import SwiftUI | |
|
|
||
| extension View { | ||
| @ViewBuilder | ||
| func adaptiveButtonStyle(_ color: Color? = nil) -> some View { | ||
| if #available(iOS 26.0, *), color == nil { | ||
| self.buttonStyle(.glass) | ||
| func adaptiveButtonStyle( | ||
| shape: some Shape = .capsule, | ||
| color: Color = .clear) | ||
| -> some View { | ||
| if #available(iOS 26.0, *) { | ||
|
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. |
||
| self.foregroundStyle(Color(.label)) | ||
| .padding(8) | ||
| .glassEffect(.regular.tint(color), in: shape) | ||
| } else { | ||
| self.foregroundStyle(Color(.label)) | ||
| .font(.footnote) | ||
| .padding(.vertical, 8) | ||
| .padding(.horizontal, 16) | ||
| .padding(8) | ||
| .background { | ||
| Capsule() | ||
| .fill(.ultraThinMaterial) | ||
| .background { | ||
| Capsule() | ||
| .fill(color ?? Color.clear) | ||
| } | ||
| .overlay { | ||
| Capsule() | ||
| .stroke(Color.white.opacity(0.2), lineWidth: 1) | ||
| Group { | ||
| if color == .clear { | ||
| shape | ||
| .fill(.ultraThinMaterial) | ||
| } else { | ||
| shape | ||
| .fill(color) | ||
| } | ||
| } | ||
| .overlay { | ||
| shape | ||
| .stroke(Color.white.opacity(0.2), lineWidth: 1) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
iOS 26.0 버전 체크는 현재 및 가까운 미래의 OS에서 항상
false를 반환하므로else블록의 코드만 실행됩니다.Button(role:)은 iOS 15.0부터 사용 가능하므로, 만약 iOS 버전을 기준으로 분기하려는 의도였다면if #available(iOS 15.0, *)과 같이 더 낮은 버전으로 수정해야 합니다.만약
visionOS를 지원하기 위한 코드라면,#if os(visionOS)전처리기 매크로를 사용하거나if #available(visionOS 1.0, *)으로 확인하는 것이 더 정확합니다. 다른 파일에서glassEffect와 같은visionOS전용 API를 사용하는 것으로 보아 후자일 가능성이 높아 보입니다.잘못된 버전 체크는 의도한 UI가 표시되지 않는 버그를 유발할 수 있으므로 수정이 필요합니다.