RecipeDetailUnavailableIngredientsToggleButton
UnavailableIngredientsToggleButton
To create your own toggle button that programmatically shows the unavailable ingredients, you create a class that implements BaseButtonProtocol.
- Boilerplate
- Full Example
import SwiftUI
import MealziOSSDK
@available(iOS 14, *)
public struct MyCustomButtonView: BaseButtonProtocol {
public func content(params: BaseButtonParameters) -> some View {
// your implementation here
}
}
import SwiftUI
import MealziOSSDK
@available(iOS 14, *)
public struct MyCustomButtonView: BaseButtonProtocol {
public init() {}
public func content(params: BaseButtonParameters) -> some View {
Button {
params.onButtonAction()
} label: {
Text(params.buttonText)
.padding(8)
}
}
}
with
public struct BaseButtonParameters {
/// Text that displays on the button
public let buttonText: String
/// Boolean on whether or not the button has been pressed yet
public let buttonPressed: Bool
/// A closure that executes the function passed in
public let onButtonAction: () -> Void