Skip to content

Commit b63123e

Browse files
authored
[#782] 버튼 배경에 텍스트의 색상을 적용한다 (#784)
* feat: role: confirm 기준 prominent 효과 구성 * refactor: 모디파이어 적용 * chore: superpowers git 추적 제거 * fix: os별 Alert 버튼 역할 적용 * chore: superpowers 문서 Git 추적 제거
1 parent 91f4723 commit b63123e

19 files changed

Lines changed: 85 additions & 448 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## AI
2+
docs/superpowers
3+
14
# MACOS
25
.DS_Store
36

Application/Presentation/Entry/Sources/Login/LoginView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct LoginView: View {
5959
.multilineTextAlignment(.center)
6060
.padding(.vertical)
6161
}
62-
.alert($store.scope(state: \.alert, action: \.alert))
62+
.prominentAlert(store, state: \.alert, action: \.alert)
6363
.background {
6464
WindowSceneIdentifierReader {
6565
store.send(.setPresentationContext(

Application/Presentation/Entry/Sources/Main/MainView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct MainView: View {
7474
profileViewCoordinator.fetchData()
7575
}
7676
}
77-
.alert($store.scope(state: \.alert, action: \.alert))
77+
.prominentAlert(store, state: \.alert, action: \.alert)
7878
.toastHost()
7979
}
8080

Application/Presentation/Entry/Sources/Root/RootView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public struct RootView: View {
6666
guard let mainTab = widgetURLTab(url) else { return }
6767
store.send(.openWidgetRoute(mainTab))
6868
}
69-
.alert($store.scope(state: \.alert, action: \.alert))
69+
.prominentAlert(store, state: \.alert, action: \.alert)
7070
.sheet(item: $store.scope(state: \.sheet, action: \.sheet)) { sheetStore in
7171
sheetContent(todoId: sheetStore.todoId) {
7272
sheetStore.send(.tapCloseButton)

Application/Presentation/HomeTab/Sources/Home/Category/CategoryManageView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct CategoryManageView: View {
5555
.sheet(item: $store.scope(state: \.categorySheet, action: \.categorySheet)) { sheetStore in
5656
sheetContent(sheetStore)
5757
}
58-
.alert($store.scope(state: \.alert, action: \.alert))
58+
.prominentAlert(store, state: \.alert, action: \.alert)
5959
.toolbar {
6060
ToolbarItem(placement: .navigationBarLeading) {
6161
Button {

Application/Presentation/HomeTab/Sources/Home/Home/HomeView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public struct HomeView: View {
3535
.listStyle(.insetGrouped)
3636
.navigationTitle(String(localized: "nav_home"))
3737
.toolbar { toolbar }
38-
.alert($store.scope(state: \.alert, action: \.alert))
38+
.prominentAlert(store, state: \.alert, action: \.alert)
3939
.sheet(item: $store.scope(state: \.sheet, action: \.sheet), content: sheetContent)
4040
.fullScreenCover(item: $store.scope(state: \.fullScreenCover, action: \.fullScreenCover), content: coverContent)
4141
}

Application/Presentation/HomeTab/Sources/Home/Search/SearchView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct SearchView: View {
5555
dismiss()
5656
}
5757
}
58-
.alert($store.scope(state: \.alert, action: \.alert))
58+
.prominentAlert(store, state: \.alert, action: \.alert)
5959
}
6060
}
6161

Application/Presentation/NotificationTab/Sources/PushNotification/PushNotificationListView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public struct PushNotificationListView: View {
4646
.navigationTitle(String(localized: "nav_push_notifications"))
4747
.listStyle(.plain)
4848
}
49-
.alert($store.scope(state: \.alert, action: \.alert))
49+
.prominentAlert(store, state: \.alert, action: \.alert)
5050
.sheet(item: sheetStore) { store in
5151
sheetContent(store)
5252
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//
2+
// View+Alert.swift
3+
// PresentationShared
4+
//
5+
// Created by opfic on 7/30/26.
6+
//
7+
8+
import ComposableArchitecture
9+
import SwiftUI
10+
11+
public extension View {
12+
@preconcurrency @MainActor
13+
@ViewBuilder
14+
func prominentAlert<State, Action, AlertAction>(
15+
_ store: Store<State, Action>,
16+
state: KeyPath<State, AlertState<AlertAction>?>,
17+
action: CaseKeyPath<Action, PresentationAction<AlertAction>>
18+
) -> some View where State: ObservableState {
19+
@Bindable var store = store
20+
let item = $store.scope(state: state, action: action)
21+
let alertStore = item.wrappedValue
22+
let alertState = store.state[keyPath: state]
23+
24+
alert(
25+
alertState.map(\.title).map(Text.init) ?? Text(verbatim: ""),
26+
isPresented: Binding(item),
27+
presenting: alertState,
28+
actions: { alertState in
29+
ForEach(alertState.buttons) { button in
30+
let usesDefaultAction = alertState.usesDefaultAction(for: button)
31+
32+
Button(
33+
role: alertState.buttonRole(for: button),
34+
action: {
35+
button.withAction { action in
36+
if let action {
37+
alertStore?.send(action)
38+
}
39+
}
40+
}
41+
) {
42+
Text(button.label)
43+
}
44+
.keyboardShortcut(
45+
usesDefaultAction ? .defaultAction : nil
46+
)
47+
}
48+
},
49+
message: {
50+
$0.message.map(Text.init)
51+
}
52+
)
53+
}
54+
}
55+
56+
extension AlertState {
57+
func buttonRole(for button: ButtonState<Action>) -> ButtonRole? {
58+
if #available(iOS 26, *), usesDefaultAction(for: button) { return .confirm }
59+
if buttons.count == 1 { return nil }
60+
return button.role.map(ButtonRole.init)
61+
}
62+
63+
func usesDefaultAction(for button: ButtonState<Action>) -> Bool {
64+
guard 1 < buttons.count else { return true }
65+
return buttons.first { $0.role == .destructive }?.id == button.id
66+
}
67+
}

Application/Presentation/PresentationShared/Sources/Todo/Detail/TodoDetailView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public struct TodoDetailView: View {
3737
}
3838
.onAppear { store.send(.onAppear) }
3939
.navigationBarTitleDisplayMode(.inline)
40-
.alert($store.scope(state: \.alert, action: \.alert))
40+
.prominentAlert(store, state: \.alert, action: \.alert)
4141
.sheet(item: $store.scope(state: \.sheet, action: \.sheet)) { store in
4242
sheetContent(store)
4343
}

0 commit comments

Comments
 (0)