mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-20 16:42:44 +02:00
Improve InlineTextButton API
This commit is contained in:
@@ -39,10 +39,11 @@ struct InlineTextButton: View {
|
||||
/// - mainText: The main text that shouldn't appear tappable. This must contain a single `%@` placeholder somewhere within.
|
||||
/// - tappableText: The tappable text that will be substituted into the `%@` placeholder.
|
||||
/// - action: The action to perform when tapping the button.
|
||||
internal init(_ mainText: String, tappableText: String, action: @escaping () -> Void) {
|
||||
/// - alwaysCallAction: If true calls the action on tap action even if the `tappableText` isn't found inside the `mainText`
|
||||
init(_ mainText: String, tappableText: String, alwaysCallAction: Bool = true, action: @escaping () -> Void) {
|
||||
guard let range = mainText.range(of: "%@") else {
|
||||
components = [StringComponent(string: Substring(mainText), isTinted: false)]
|
||||
self.action = action
|
||||
self.action = alwaysCallAction ? action : { }
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user