@@ -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 {
@@ -38,8 +38,11 @@ struct NekiAlertModifier: ViewModifier {
3838 . zIndex ( 1 )
3939 . transition ( . opacity)
4040 . onTapGesture {
41- // 필요 시 배경 탭으로 닫기 로직 추가 가능
42- // isPresented.toggle()
41+ if let onCancel = onCancel {
42+ onCancel ( )
43+ } else {
44+ isPresented. toggle ( )
45+ }
4346 }
4447
4548 NekiAlertModal ( hasIcon: hasIcon) {
@@ -89,7 +92,7 @@ struct NekiAlertModifier: ViewModifier {
8992 // 개별 버튼 컴포넌트
9093 private var confirmButton : some View {
9194 Button {
92- onConfirm ( )
95+ onConfirm ? ( )
9396 } label: {
9497 Text ( confirmText)
9598 . frame ( maxWidth: . infinity)
@@ -100,7 +103,7 @@ struct NekiAlertModifier: ViewModifier {
100103
101104 private var cancelButton : some View {
102105 Button {
103- onCancel ( )
106+ onCancel ? ( )
104107 } label: {
105108 Text ( cancelText ?? " 취소 " )
106109 . frame ( maxWidth: . infinity)
@@ -111,7 +114,7 @@ struct NekiAlertModifier: ViewModifier {
111114
112115 private var secondaryButton : some View {
113116 Button {
114- onSecondary ( )
117+ onSecondary ? ( )
115118 } label: {
116119 Text ( secondaryText ?? " 선택 " )
117120 . padding ( . horizontal, 32 )
@@ -136,9 +139,9 @@ public extension View {
136139 secondaryText: String ? = nil ,
137140 isProcessing: Bool = false ,
138141 hasIcon: Bool = true ,
139- onConfirm: @escaping ( ) -> Void = { } ,
140- onCancel: @escaping ( ) -> Void = { } ,
141- onSecondary: @escaping ( ) -> Void = { }
142+ onConfirm: ( ( ) -> Void ) ? = nil ,
143+ onCancel: ( ( ) -> Void ) ? = nil ,
144+ onSecondary: ( ( ) -> Void ) ? = nil
142145 ) -> some View {
143146 self . modifier ( NekiAlertModifier (
144147 isPresented: isPresented,
0 commit comments