Skip to content

Commit 0285e20

Browse files
committed
Updated swiftui extension.
1 parent 4b79d13 commit 0285e20

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

Sources/SPAlert/Extensions/SwiftUIExtension.swift

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ extension View {
3333
duration: TimeInterval = 2.0,
3434
haptic: SPAlertHaptic = .none
3535
) -> some View {
36+
3637
if isPresent.wrappedValue {
3738
let alertCompletion = alertView.completion
3839
let alertDismiss = {
@@ -45,36 +46,37 @@ extension View {
4546
return self
4647
}
4748

48-
public func SPAlert(isPresent: Binding<Bool>,
49-
title: String = "",
50-
message: String? = nil,
51-
duration: TimeInterval = 2.0,
52-
dismissOnTap: Bool = true,
53-
preset: SPAlertIconPreset = .done,
54-
haptic: SPAlertHaptic = .none,
55-
layout: SPAlertLayout? = nil,
56-
completion: (()-> Void)? = nil
49+
public func SPAlert(
50+
isPresent: Binding<Bool>,
51+
title: String = "",
52+
message: String? = nil,
53+
duration: TimeInterval = 2.0,
54+
dismissOnTap: Bool = true,
55+
preset: SPAlertIconPreset = .done,
56+
haptic: SPAlertHaptic = .none,
57+
layout: SPAlertLayout? = nil,
58+
completion: (()-> Void)? = nil
5759
) -> some View {
60+
5861
let alertView = SPAlertView(title: title, message: message, preset: preset)
5962
alertView.dismissByTap = dismissOnTap
6063
alertView.layout = layout ?? SPAlertLayout(for: preset)
6164
alertView.completion = completion
62-
6365
return SPAlert(isPresent: isPresent, alertView: alertView, duration: duration, haptic: haptic)
6466
}
6567

66-
public func SPAlert(isPresent: Binding<Bool>,
67-
message: String,
68-
duration: TimeInterval = 2.0,
69-
dismissOnTap: Bool = true,
70-
haptic: SPAlertHaptic = .none,
71-
completion: (()-> Void)? = nil
68+
public func SPAlert(
69+
isPresent: Binding<Bool>,
70+
message: String,
71+
duration: TimeInterval = 2.0,
72+
dismissOnTap: Bool = true,
73+
haptic: SPAlertHaptic = .none,
74+
completion: (()-> Void)? = nil
7275
) -> some View {
7376

7477
let alertView = SPAlertView(message: message)
7578
alertView.dismissByTap = dismissOnTap
7679
alertView.completion = completion
77-
7880
return SPAlert(isPresent: isPresent, alertView: alertView, duration: duration, haptic: haptic)
7981
}
8082
}

0 commit comments

Comments
 (0)