Equipment
This template allows you to customize the Equipment section of the Preferences page.
- Boilerplate
- Full Example
import SwiftUI
import mealzcore
import MealziOSSDK
@available(iOS 14, *)
public struct MyCustomPreferencesEquipmentView: PreferencesEquipmentProtocol {
public func content(params: PreferencesEquipmentParameters) -> some View {
// your imp here
}
}
import SwiftUI
import mealzcore
import MealziOSSDK
@available(iOS 14, *)
public struct MyCustomPreferencesDietView: PreferencesEquipmentProtocol {
public init() {}
public func content(params: PreferencesEquipmentParameters) -> some View {
VStack {
ToggleTitle(title: Localization.preferences.cookingEquipmentTitle.localised, isExpanded: params.isExpanded, toggleIsExpanded: { withAnimation { params.isExpanded.toggle() } })
if params.isExpanded {
ForEach(params.dietsTag, id: \.self) { checkableTag in
RadioOrCheckButton(label: checkableTag.tag.attributes?.name ?? "", isSelected: checkableTag.isChecked, typeOfButton: params.typeOfInput, selectOption: {
params.onTogglePreference(checkableTag.tag.id)
})
}
}
}
.padding(.horizontal, Dimension.sharedInstance.mlPadding)
}
}
Params
public struct PreferencesEquipmentParameters {
/// The differerent types of equipment (like Oven)
public let equipmentsTag: [CheckableTag]
/// Whether or not all options are available to be seen
@Binding public var isExpanded: Bool
/// Boolean indicating if the input is a checkbox (multiple options) or radioButton (one option)
public let typeOfInput: TypeOfInput
/// A closure that selects this diet option. Multiple options can be selected at the same time
public let onTogglePreference: (String) -> Void