@@ -23,9 +23,9 @@ struct NekiAlertModifier: ViewModifier {
2323 let hasIcon : Bool
2424
2525 // 액션 클로저
26- let onConfirm : ( ) -> Void
27- let onCancel : ( ) -> Void
28- let onSecondary : ( ) -> Void
26+ let onConfirm : ( ( ) -> Void ) ?
27+ let onCancel : ( ( ) -> Void ) ?
28+ let onSecondary : ( ( ) -> Void ) ?
2929
3030 func body( content: Content ) -> some View {
3131 ZStack {
@@ -37,7 +37,13 @@ struct NekiAlertModifier: ViewModifier {
3737 . ignoresSafeArea ( )
3838 . zIndex ( 1 )
3939 . transition ( . opacity)
40- . onTapGesture { isPresented. toggle ( ) }
40+ . onTapGesture {
41+ if let onCancel = onCancel {
42+ onCancel ( )
43+ } else {
44+ isPresented. toggle ( )
45+ }
46+ }
4147
4248 NekiAlertModal ( hasIcon: hasIcon) {
4349 VStack ( spacing: 4 ) {
@@ -86,7 +92,7 @@ struct NekiAlertModifier: ViewModifier {
8692 // 개별 버튼 컴포넌트
8793 private var confirmButton : some View {
8894 Button {
89- onConfirm ( )
95+ onConfirm ? ( )
9096 } label: {
9197 Text ( confirmText)
9298 . frame ( maxWidth: . infinity)
@@ -97,7 +103,7 @@ struct NekiAlertModifier: ViewModifier {
97103
98104 private var cancelButton : some View {
99105 Button {
100- onCancel ( )
106+ onCancel ? ( )
101107 } label: {
102108 Text ( cancelText ?? " 취소 " )
103109 . frame ( maxWidth: . infinity)
@@ -108,7 +114,7 @@ struct NekiAlertModifier: ViewModifier {
108114
109115 private var secondaryButton : some View {
110116 Button {
111- onSecondary ( )
117+ onSecondary ? ( )
112118 } label: {
113119 Text ( secondaryText ?? " 선택 " )
114120 . padding ( . horizontal, 32 )
@@ -133,9 +139,9 @@ public extension View {
133139 secondaryText: String ? = nil ,
134140 isProcessing: Bool = false ,
135141 hasIcon: Bool = true ,
136- onConfirm: @escaping ( ) -> Void = { } ,
137- onCancel: @escaping ( ) -> Void = { } ,
138- onSecondary: @escaping ( ) -> Void = { }
142+ onConfirm: ( ( ) -> Void ) ? = nil ,
143+ onCancel: ( ( ) -> Void ) ? = nil ,
144+ onSecondary: ( ( ) -> Void ) ? = nil
139145 ) -> some View {
140146 self . modifier ( NekiAlertModifier (
141147 isPresented: isPresented,
0 commit comments