|
|
@@ -30,24 +30,47 @@ extension Main {
|
|
|
router.alertMessage
|
|
|
.receive(on: DispatchQueue.main)
|
|
|
.sink { message in
|
|
|
- SwiftMessages.show {
|
|
|
- let view = MessageView.viewFromNib(layout: .messageView)
|
|
|
+ var config = SwiftMessages.defaultConfig
|
|
|
+ let view = MessageView.viewFromNib(layout: .cardView)
|
|
|
+
|
|
|
+ let titleContent: String
|
|
|
+
|
|
|
+ view.configureContent(
|
|
|
+ title: "title",
|
|
|
+ body: NSLocalizedString(message.content, comment: "Info message"),
|
|
|
+ iconImage: nil,
|
|
|
+ iconText: nil,
|
|
|
+ buttonImage: nil,
|
|
|
+ buttonTitle: nil,
|
|
|
+ buttonTapHandler: nil
|
|
|
+ )
|
|
|
+
|
|
|
+ switch message.type {
|
|
|
+ case .info:
|
|
|
view.backgroundColor = .secondarySystemGroupedBackground
|
|
|
- view.titleLabel?.textColor = .label
|
|
|
- view.bodyLabel?.textColor = .label
|
|
|
- view.configureContent(
|
|
|
- title: NSLocalizedString("Info", comment: "Info title"),
|
|
|
- body: NSLocalizedString(message, comment: "Info message"),
|
|
|
- iconImage: nil,
|
|
|
- iconText: nil,
|
|
|
- buttonImage: nil,
|
|
|
- buttonTitle: nil,
|
|
|
- buttonTapHandler: nil
|
|
|
- )
|
|
|
+ config.duration = .automatic
|
|
|
|
|
|
- view.bodyLabel?.text = message
|
|
|
- return view
|
|
|
+ titleContent = NSLocalizedString("Info", comment: "Info title")
|
|
|
+ case .warning:
|
|
|
+ view.configureTheme(.warning, iconStyle: .subtle)
|
|
|
+ config.duration = .forever
|
|
|
+ view.button?.setImage(Icon.warningSubtle.image, for: .normal)
|
|
|
+ titleContent = NSLocalizedString("Warning", comment: "Warning title")
|
|
|
+ view.buttonTapHandler = { _ in SwiftMessages.hide() }
|
|
|
+ case .error:
|
|
|
+ view.configureTheme(.error, iconStyle: .subtle)
|
|
|
+ config.duration = .forever
|
|
|
+ view.button?.setImage(Icon.errorSubtle.image, for: .normal)
|
|
|
+ titleContent = NSLocalizedString("Error", comment: "Error title")
|
|
|
+ view.buttonTapHandler = { _ in
|
|
|
+ SwiftMessages.hide()
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ view.titleLabel?.text = titleContent
|
|
|
+ config.dimMode = .gray(interactive: true)
|
|
|
+
|
|
|
+ SwiftMessages.show(config: config, view: view)
|
|
|
}
|
|
|
.store(in: &lifetime)
|
|
|
|