Guest
This template allows you to customize the Guest section of the Preferences page.
- Boilerplate
- Full Example
import SwiftUI
import mealzcore
import MealziOSSDK
@available(iOS 14, *)
public struct MyCustomPreferencesGuestView: PreferencesGuestProtocol {
public func content(params: PreferencesGuestParameters) -> some View {
// your imp here
}
}
import SwiftUI
import mealzcore
import MealziOSSDK
@available(iOS 14, *)
public struct MyCustomPreferencesGuestView: PreferencesGuestProtocol {
public init() {}
public func content(params: PreferencesGuestParameters) -> some View {
VStack {
HStack {
Text(Localization.preferences.numberOfGuests.localised)
.miamFontStyle(style: MiamFontStyleProvider.sharedInstance.titleMediumStyle)
Spacer()
MealzGuestCounter(currentGuests: params.guests, withBorder: true) { count in
params.onGuestChanged(count)
}
}
.padding(Dimension.sharedInstance.mPadding)
}
.frame(maxWidth: .infinity)
}
}
Params
public struct PreferencesGuestParameters {
/// The number of guests that the recipes will be optimizing for
@Binding public var guests: Int
/// A closure to update the number of guests
public let onGuestChanged: (Int) -> Void