-
Notifications
You must be signed in to change notification settings - Fork 0
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
754a9e2
commit d9c25d2
Showing
8 changed files
with
163 additions
and
32 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
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
15 changes: 0 additions & 15 deletions
15
Sources/Purace/Views/Basic/Snackbar v2/Models/PuraceSnackbarConfig.swift
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
Sources/Purace/Views/Basic/Snackbar v2/Models/PuraceSnackbarContent.swift
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,15 @@ | ||
// | ||
// PuraceSnackbarContent.swift | ||
// | ||
// | ||
// Created by Juan Hurtado on 21/11/22. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct PuraceSnackbarContent { | ||
var title: String = "" | ||
var type: PuraceSnackbarType = .info | ||
var action: (() -> Void)? | ||
var actionTitle: String? | ||
} |
47 changes: 47 additions & 0 deletions
47
Sources/Purace/Views/Basic/Snackbar v2/PuraceSnackbarBuilder.swift
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,47 @@ | ||
// | ||
// PuraceSnackbarBuilder.swift | ||
// | ||
// | ||
// Created by Juan Hurtado on 14/12/22. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Snackbar builder. | ||
/// | ||
/// If you want to build and show a snackbar: | ||
/// ``` | ||
/// let builder = PuraceSnackbarBuilder() | ||
/// | ||
/// builder | ||
/// .withTitle("This is a snackbar!") | ||
/// .build() | ||
/// .show() | ||
/// ``` | ||
public class PuraceSnackbarBuilder { | ||
private var content: PuraceSnackbarContent | ||
|
||
public init() { | ||
content = PuraceSnackbarContent() | ||
} | ||
|
||
public func withTitle(_ title: String) -> PuraceSnackbarBuilder { | ||
content.title = title | ||
return self | ||
} | ||
|
||
public func withType(_ type: PuraceSnackbarType) -> PuraceSnackbarBuilder { | ||
content.type = type | ||
return self | ||
} | ||
|
||
public func withAction(title: String?, handler: @escaping () -> Void) -> PuraceSnackbarBuilder { | ||
content.actionTitle = title | ||
content.action = handler | ||
return self | ||
} | ||
|
||
public func build() -> PuraceSnackbarDisplayableContent { | ||
PuraceSnackbarDisplayableContent(content: content) | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Sources/Purace/Views/Basic/Snackbar v2/PuraceSnackbarDisplayableContent.swift
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,20 @@ | ||
// | ||
// PuraceSnackbarDisplayableContent.swift | ||
// | ||
// | ||
// Created by Juan Hurtado on 14/12/22. | ||
// | ||
|
||
import Foundation | ||
|
||
public class PuraceSnackbarDisplayableContent { | ||
private let content: PuraceSnackbarContent | ||
|
||
init(content: PuraceSnackbarContent) { | ||
self.content = content | ||
} | ||
|
||
public func show() { | ||
PuraceSnackbarManager.instance.show(using: content) | ||
} | ||
} |
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