Implement custom view styles with ViewStyle
mainFor more control, such as implementing a root body that applies to all styles (e.g., a mandatory ViewModifier), implement the ViewStyle and ViewStyledView protocols manually instead of using the macro.
ViewStyle: Defines theConfigurationand themakeBody(configuration:)method.ViewStyledView: Defines theConfigurationand adefaultStyle.
public protocol ViewStyle {
associatedtype Configuration
associatedtype Body: View
@ViewBuilder
func makeBody(configuration: Configuration) -> Body
}
public protocol ViewStyledView: View {
associatedtype Configuration
var configuration: Configuration { get }
associatedtype DefaultStyle: ViewStyle where DefaultStyle.Configuration == Configuration
static var defaultStyle: DefaultStyle { get }
}