-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6e7b85
commit e0d14d9
Showing
5 changed files
with
94 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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,35 @@ | ||
import Foundation | ||
import SwiftMessages | ||
import UIKit | ||
|
||
struct AlertPresenter { | ||
enum MessageType { | ||
case warning | ||
case error | ||
case info | ||
case success | ||
} | ||
|
||
static func present(message: String, type: AlertPresenter.MessageType) { | ||
DispatchQueue.main.async { | ||
let view = MessageView.viewFromNib(layout: .cardView) | ||
switch type { | ||
case .warning: | ||
view.configureTheme(.warning, iconStyle: .subtle) | ||
case .error: | ||
view.configureTheme(.error, iconStyle: .subtle) | ||
case .info: | ||
view.configureTheme(.info, iconStyle: .subtle) | ||
case .success: | ||
view.configureTheme(.success, iconStyle: .subtle) | ||
} | ||
view.button?.isHidden = true | ||
view.layoutMarginAdditions = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20) | ||
view.configureContent(title: "", body: message) | ||
var config = SwiftMessages.Config() | ||
config.presentationStyle = .top | ||
config.duration = .seconds(seconds: 1.5) | ||
SwiftMessages.show(config: config, view: view) | ||
} | ||
} | ||
} |
This file contains 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 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 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